|
212 | 212 | end |
213 | 213 |
|
214 | 214 | context 'and successfully generate the node graph' do |
215 | | - let(:relationship_graph) { double('graph') } |
| 215 | + let(:relationship_graph) { MockRelationshipGraph.new() } |
216 | 216 | before(:each) do |
217 | | - expect(relationship_graph).to receive(:to_dot).with(Hash).and_return(dot_content) |
218 | 217 | expect(PuppetLanguageServer::PuppetParserHelper).to receive(:compile_to_pretty_relationship_graph).with(file_content).and_return(relationship_graph) |
219 | 218 | end |
220 | 219 |
|
221 | | - it 'should reply with dotContent' do |
222 | | - expect(request).to receive(:reply_result).with(hash_including('dotContent' => dot_content)) |
| 220 | + context 'with one or more resources' do |
| 221 | + before(:each) do |
| 222 | + relationship_graph.vertices = [double('node1'),double('node2')] |
| 223 | + expect(relationship_graph).to receive(:to_dot).with(Hash).and_return(dot_content) |
| 224 | + end |
223 | 225 |
|
224 | | - subject.receive_request(request) |
| 226 | + it 'should reply with dotContent' do |
| 227 | + expect(request).to receive(:reply_result).with(hash_including('dotContent' => dot_content)) |
| 228 | + |
| 229 | + subject.receive_request(request) |
| 230 | + end |
| 231 | + |
| 232 | + it 'should not reply with error' do |
| 233 | + expect(request).to_not receive(:reply_result).with(hash_including('error')) |
| 234 | + |
| 235 | + subject.receive_request(request) |
| 236 | + end |
225 | 237 | end |
226 | 238 |
|
227 | | - it 'should not reply with error' do |
228 | | - expect(request).to_not receive(:reply_result).with(hash_including('error')) |
| 239 | + context 'with zero resources' do |
| 240 | + before(:each) do |
| 241 | + relationship_graph.vertices = [] |
| 242 | + expect(relationship_graph).to receive(:to_dot).with(Hash).never |
| 243 | + end |
229 | 244 |
|
230 | | - subject.receive_request(request) |
| 245 | + it 'should reply with the error text' do |
| 246 | + expect(request).to receive(:reply_result).with(hash_including('error' => /no resources/)) |
| 247 | + |
| 248 | + subject.receive_request(request) |
| 249 | + end |
| 250 | + |
| 251 | + it 'should not reply with dotContent' do |
| 252 | + expect(request).to_not receive(:reply_result).with(hash_including('dotContent')) |
| 253 | + |
| 254 | + subject.receive_request(request) |
| 255 | + end |
231 | 256 | end |
232 | 257 | end |
233 | 258 | end |
|
0 commit comments