transpec 0.2.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +1 -1
  4. data/CHANGELOG.md +10 -0
  5. data/README.md +111 -56
  6. data/README.md.erb +117 -62
  7. data/lib/transpec/ast/node.rb +41 -0
  8. data/lib/transpec/base_rewriter.rb +55 -0
  9. data/lib/transpec/cli.rb +43 -153
  10. data/lib/transpec/configuration.rb +13 -9
  11. data/lib/transpec/{rewriter.rb → converter.rb} +44 -71
  12. data/lib/transpec/dynamic_analyzer/rewriter.rb +94 -0
  13. data/lib/transpec/dynamic_analyzer/runtime_data.rb +27 -0
  14. data/lib/transpec/dynamic_analyzer.rb +166 -0
  15. data/lib/transpec/file_finder.rb +53 -0
  16. data/lib/transpec/option_parser.rb +166 -0
  17. data/lib/transpec/{context.rb → static_context_inspector.rb} +2 -2
  18. data/lib/transpec/syntax/be_close.rb +7 -9
  19. data/lib/transpec/syntax/double.rb +6 -10
  20. data/lib/transpec/syntax/expect.rb +35 -0
  21. data/lib/transpec/syntax/have.rb +195 -0
  22. data/lib/transpec/syntax/method_stub.rb +22 -27
  23. data/lib/transpec/syntax/mixin/allow_no_message.rb +73 -0
  24. data/lib/transpec/syntax/mixin/any_instance.rb +22 -0
  25. data/lib/transpec/syntax/mixin/expectizable.rb +26 -0
  26. data/lib/transpec/syntax/mixin/have_matcher.rb +23 -0
  27. data/lib/transpec/syntax/mixin/monkey_patch.rb +37 -0
  28. data/lib/transpec/syntax/mixin/send.rb +109 -0
  29. data/lib/transpec/syntax/{matcher.rb → operator_matcher.rb} +27 -14
  30. data/lib/transpec/syntax/raise_error.rb +6 -10
  31. data/lib/transpec/syntax/rspec_configure.rb +29 -28
  32. data/lib/transpec/syntax/should.rb +45 -15
  33. data/lib/transpec/syntax/should_receive.rb +44 -16
  34. data/lib/transpec/syntax.rb +29 -21
  35. data/lib/transpec/util.rb +12 -2
  36. data/lib/transpec/version.rb +3 -3
  37. data/spec/spec_helper.rb +8 -6
  38. data/spec/support/cache_helper.rb +50 -0
  39. data/spec/support/shared_context.rb +49 -1
  40. data/spec/transpec/ast/node_spec.rb +65 -0
  41. data/spec/transpec/cli_spec.rb +33 -242
  42. data/spec/transpec/commit_message_spec.rb +2 -2
  43. data/spec/transpec/configuration_spec.rb +12 -8
  44. data/spec/transpec/{rewriter_spec.rb → converter_spec.rb} +198 -148
  45. data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +183 -0
  46. data/spec/transpec/dynamic_analyzer_spec.rb +164 -0
  47. data/spec/transpec/file_finder_spec.rb +118 -0
  48. data/spec/transpec/option_parser_spec.rb +185 -0
  49. data/spec/transpec/{context_spec.rb → static_context_inspector_spec.rb} +27 -12
  50. data/spec/transpec/syntax/be_close_spec.rb +8 -4
  51. data/spec/transpec/syntax/double_spec.rb +105 -12
  52. data/spec/transpec/syntax/expect_spec.rb +83 -0
  53. data/spec/transpec/syntax/have_spec.rb +599 -0
  54. data/spec/transpec/syntax/method_stub_spec.rb +276 -115
  55. data/spec/transpec/syntax/{matcher_spec.rb → operator_matcher_spec.rb} +277 -98
  56. data/spec/transpec/syntax/raise_error_spec.rb +92 -46
  57. data/spec/transpec/syntax/should_receive_spec.rb +298 -92
  58. data/spec/transpec/syntax/should_spec.rb +230 -44
  59. data/spec/transpec/util_spec.rb +2 -9
  60. data/tasks/lib/transpec_demo.rb +1 -1
  61. data/tasks/lib/transpec_test.rb +5 -7
  62. data/tasks/test.rake +5 -1
  63. data/transpec.gemspec +1 -1
  64. metadata +46 -22
  65. data/lib/transpec/syntax/able_to_allow_no_message.rb +0 -73
  66. data/lib/transpec/syntax/able_to_target_any_instance.rb +0 -24
  67. data/lib/transpec/syntax/expectizable.rb +0 -27
  68. data/lib/transpec/syntax/send_node_syntax.rb +0 -57
@@ -14,12 +14,15 @@ module Transpec
14
14
  return MethodStub.new(
15
15
  node,
16
16
  ancestor_nodes,
17
- source_rewriter
17
+ source_rewriter,
18
+ runtime_data
18
19
  )
19
20
  end
20
21
  fail 'No method stub node is found!'
21
22
  end
22
23
 
24
+ let(:runtime_data) { nil }
25
+
23
26
  let(:record) { method_stub_object.report.records.first }
24
27
 
25
28
  describe '.target_node?' do
@@ -36,8 +39,10 @@ module Transpec
36
39
  context 'when #stub node is passed' do
37
40
  let(:source) do
38
41
  <<-END
39
- it 'responds to #foo' do
40
- subject.stub(:foo)
42
+ describe 'example' do
43
+ it 'responds to #foo' do
44
+ subject.stub(:foo)
45
+ end
41
46
  end
42
47
  END
43
48
  end
@@ -47,31 +52,44 @@ module Transpec
47
52
  end
48
53
  end
49
54
 
50
- context 'when #stub node with Typhoeus receiver is passed' do
51
- let(:source) do
52
- <<-END
53
- it "is not RSpec's #stub" do
54
- ::Typhoeus.stub(url, :method => method).and_return(response)
55
- end
56
- END
57
- end
55
+ context 'with runtime information' do
56
+ include_context 'dynamic analysis objects'
58
57
 
59
- it 'returns false' do
60
- MethodStub.target_node?(send_node).should be_false
61
- end
62
- end
58
+ context "when RSpec's #stub node is passed" do
59
+ let(:source) do
60
+ <<-END
61
+ describe 'example' do
62
+ it 'responds to #foo' do
63
+ subject.stub(:foo)
64
+ end
65
+ end
66
+ END
67
+ end
63
68
 
64
- context 'when #stub node with Excon receiver is passed' do
65
- let(:source) do
66
- <<-END
67
- it "is not RSpec's #stub" do
68
- ::Excon.stub({}, {:body => 'body', :status => 200})
69
- end
70
- END
69
+ it 'returns true' do
70
+ MethodStub.target_node?(send_node, runtime_data).should be_true
71
+ end
71
72
  end
72
73
 
73
- it 'returns false' do
74
- MethodStub.target_node?(send_node).should be_false
74
+ context 'when another #stub node is passed' do
75
+ let(:source) do
76
+ <<-END
77
+ module AnotherStubProvider
78
+ def self.stub(*args)
79
+ end
80
+ end
81
+
82
+ describe 'example' do
83
+ it "is not RSpec's #stub" do
84
+ AnotherStubProvider.stub(:something)
85
+ end
86
+ end
87
+ END
88
+ end
89
+
90
+ it 'returns false' do
91
+ MethodStub.target_node?(send_node, runtime_data).should be_false
92
+ end
75
93
  end
76
94
  end
77
95
  end
@@ -79,8 +97,10 @@ module Transpec
79
97
  describe '#method_name' do
80
98
  let(:source) do
81
99
  <<-END
82
- it 'responds to #foo' do
83
- subject.stub(:foo)
100
+ describe 'example' do
101
+ it 'responds to #foo' do
102
+ subject.stub(:foo)
103
+ end
84
104
  end
85
105
  END
86
106
  end
@@ -91,57 +111,127 @@ module Transpec
91
111
  end
92
112
 
93
113
  describe '#allowize!' do
94
- before do
95
- method_stub_object.context.stub(:allow_to_receive_available?).and_return(true)
96
- method_stub_object.allowize!
97
- end
98
-
99
114
  [:stub, :stub!].each do |method|
100
115
  context "when it is `subject.#{method}(:method)` form" do
101
116
  let(:source) do
102
117
  <<-END
103
- it 'responds to #foo' do
104
- subject.#{method}(:foo)
118
+ describe 'example' do
119
+ it 'responds to #foo' do
120
+ subject.#{method}(:foo)
121
+ end
105
122
  end
106
123
  END
107
124
  end
108
125
 
109
126
  let(:expected_source) do
110
127
  <<-END
111
- it 'responds to #foo' do
112
- allow(subject).to receive(:foo)
128
+ describe 'example' do
129
+ it 'responds to #foo' do
130
+ allow(subject).to receive(:foo)
131
+ end
113
132
  end
114
133
  END
115
134
  end
116
135
 
117
136
  it 'converts into `allow(subject).to receive(:method)` form' do
137
+ method_stub_object.allowize!
118
138
  rewritten_source.should == expected_source
119
139
  end
120
140
 
121
141
  it "adds record \"`obj.#{method}(:message)` -> `allow(obj).to receive(:message)`\"" do
142
+ method_stub_object.allowize!
122
143
  record.original_syntax.should == "obj.#{method}(:message)"
123
144
  record.converted_syntax.should == 'allow(obj).to receive(:message)'
124
145
  end
146
+
147
+ context 'and #allow and #receive are not available in the context' do
148
+ context 'and the context is determinable statically' do
149
+ let(:source) do
150
+ <<-END
151
+ describe 'example' do
152
+ class TestRunner
153
+ def run
154
+ 'something'.#{method}(:foo)
155
+ end
156
+ end
157
+
158
+ it 'responds to #foo' do
159
+ TestRunner.new.run
160
+ end
161
+ end
162
+ END
163
+ end
164
+
165
+ context 'with runtime information' do
166
+ include_context 'dynamic analysis objects'
167
+
168
+ it 'raises InvalidContextError' do
169
+ -> { method_stub_object.allowize! }.should raise_error(InvalidContextError)
170
+ end
171
+ end
172
+
173
+ context 'without runtime information' do
174
+ it 'raises InvalidContextError' do
175
+ -> { method_stub_object.allowize! }.should raise_error(InvalidContextError)
176
+ end
177
+ end
178
+ end
179
+
180
+ context 'and the context is not determinable statically' do
181
+ let(:source) do
182
+ <<-END
183
+ def my_eval(&block)
184
+ Object.new.instance_eval(&block)
185
+ end
186
+
187
+ describe 'example' do
188
+ it 'responds to #foo' do
189
+ my_eval { 'something'.#{method}(:foo) }
190
+ end
191
+ end
192
+ END
193
+ end
194
+
195
+ context 'with runtime information' do
196
+ include_context 'dynamic analysis objects'
197
+
198
+ it 'raises InvalidContextError' do
199
+ -> { method_stub_object.allowize! }.should raise_error(InvalidContextError)
200
+ end
201
+ end
202
+
203
+ context 'without runtime information' do
204
+ it 'does not raise InvalidContextError' do
205
+ -> { method_stub_object.allowize! }.should_not raise_error
206
+ end
207
+ end
208
+ end
209
+ end
125
210
  end
126
211
 
127
212
  context "when it is `subject.#{method}(:method).and_return(value)` form" do
128
213
  let(:source) do
129
214
  <<-END
130
- it 'responds to #foo and returns 1' do
131
- subject.#{method}(:foo).and_return(1)
215
+ describe 'example' do
216
+ it 'responds to #foo and returns 1' do
217
+ subject.#{method}(:foo).and_return(1)
218
+ end
132
219
  end
133
220
  END
134
221
  end
135
222
 
136
223
  let(:expected_source) do
137
224
  <<-END
138
- it 'responds to #foo and returns 1' do
139
- allow(subject).to receive(:foo).and_return(1)
225
+ describe 'example' do
226
+ it 'responds to #foo and returns 1' do
227
+ allow(subject).to receive(:foo).and_return(1)
228
+ end
140
229
  end
141
230
  END
142
231
  end
143
232
 
144
233
  it 'converts into `allow(subject).to receive(:method).and_return(value)` form' do
234
+ method_stub_object.allowize!
145
235
  rewritten_source.should == expected_source
146
236
  end
147
237
  end
@@ -149,21 +239,26 @@ module Transpec
149
239
  context "when it is `subject.#{method}(:method).and_raise(RuntimeError)` form" do
150
240
  let(:source) do
151
241
  <<-END
152
- it 'responds to #foo and raises RuntimeError' do
153
- subject.#{method}(:foo).and_raise(RuntimeError)
242
+ describe 'example' do
243
+ it 'responds to #foo and raises RuntimeError' do
244
+ subject.#{method}(:foo).and_raise(RuntimeError)
245
+ end
154
246
  end
155
247
  END
156
248
  end
157
249
 
158
250
  let(:expected_source) do
159
251
  <<-END
160
- it 'responds to #foo and raises RuntimeError' do
161
- allow(subject).to receive(:foo).and_raise(RuntimeError)
252
+ describe 'example' do
253
+ it 'responds to #foo and raises RuntimeError' do
254
+ allow(subject).to receive(:foo).and_raise(RuntimeError)
255
+ end
162
256
  end
163
257
  END
164
258
  end
165
259
 
166
260
  it 'converts into `allow(subject).to receive(:method).and_raise(RuntimeError)` form' do
261
+ method_stub_object.allowize!
167
262
  rewritten_source.should == expected_source
168
263
  end
169
264
  end
@@ -171,31 +266,36 @@ module Transpec
171
266
  context 'when the statement continues over multi lines' do
172
267
  let(:source) do
173
268
  <<-END
174
- it 'responds to #foo and returns 1' do
175
- subject.#{method}(
176
- :foo
177
- ).
178
- and_return(
179
- 1
180
- )
269
+ describe 'example' do
270
+ it 'responds to #foo and returns 1' do
271
+ subject.#{method}(
272
+ :foo
273
+ ).
274
+ and_return(
275
+ 1
276
+ )
277
+ end
181
278
  end
182
279
  END
183
280
  end
184
281
 
185
282
  let(:expected_source) do
186
283
  <<-END
187
- it 'responds to #foo and returns 1' do
188
- allow(subject).to receive(
189
- :foo
190
- ).
191
- and_return(
192
- 1
193
- )
284
+ describe 'example' do
285
+ it 'responds to #foo and returns 1' do
286
+ allow(subject).to receive(
287
+ :foo
288
+ ).
289
+ and_return(
290
+ 1
291
+ )
292
+ end
194
293
  end
195
294
  END
196
295
  end
197
296
 
198
297
  it 'keeps the style as far as possible' do
298
+ method_stub_object.allowize!
199
299
  rewritten_source.should == expected_source
200
300
  end
201
301
  end
@@ -203,26 +303,32 @@ module Transpec
203
303
  context "when it is `subject.#{method}(:method => value)` form" do
204
304
  let(:source) do
205
305
  <<-END
206
- it 'responds to #foo and returns 1' do
207
- subject.#{method}(:foo => 1)
306
+ describe 'example' do
307
+ it 'responds to #foo and returns 1' do
308
+ subject.#{method}(:foo => 1)
309
+ end
208
310
  end
209
311
  END
210
312
  end
211
313
 
212
314
  let(:expected_source) do
213
315
  <<-END
214
- it 'responds to #foo and returns 1' do
215
- allow(subject).to receive(:foo).and_return(1)
316
+ describe 'example' do
317
+ it 'responds to #foo and returns 1' do
318
+ allow(subject).to receive(:foo).and_return(1)
319
+ end
216
320
  end
217
321
  END
218
322
  end
219
323
 
220
324
  it 'converts into `allow(subject).to receive(:method).and_return(value)` form' do
325
+ method_stub_object.allowize!
221
326
  rewritten_source.should == expected_source
222
327
  end
223
328
 
224
329
  it 'adds record ' +
225
330
  "\"`obj.#{method}(:message => value)` -> `allow(obj).to receive(:message).and_return(value)`\"" do
331
+ method_stub_object.allowize!
226
332
  record.original_syntax.should == "obj.#{method}(:message => value)"
227
333
  record.converted_syntax.should == 'allow(obj).to receive(:message).and_return(value)'
228
334
  end
@@ -231,26 +337,32 @@ module Transpec
231
337
  context "when it is `subject.#{method}(method: value)` form" do
232
338
  let(:source) do
233
339
  <<-END
234
- it 'responds to #foo and returns 1' do
235
- subject.#{method}(foo: 1)
340
+ describe 'example' do
341
+ it 'responds to #foo and returns 1' do
342
+ subject.#{method}(foo: 1)
343
+ end
236
344
  end
237
345
  END
238
346
  end
239
347
 
240
348
  let(:expected_source) do
241
349
  <<-END
242
- it 'responds to #foo and returns 1' do
243
- allow(subject).to receive(:foo).and_return(1)
350
+ describe 'example' do
351
+ it 'responds to #foo and returns 1' do
352
+ allow(subject).to receive(:foo).and_return(1)
353
+ end
244
354
  end
245
355
  END
246
356
  end
247
357
 
248
358
  it 'converts into `allow(subject).to receive(:method).and_return(value)` form' do
359
+ method_stub_object.allowize!
249
360
  rewritten_source.should == expected_source
250
361
  end
251
362
 
252
363
  it 'adds record ' +
253
364
  "\"`obj.#{method}(:message => value)` -> `allow(obj).to receive(:message).and_return(value)`\"" do
365
+ method_stub_object.allowize!
254
366
  record.original_syntax.should == "obj.#{method}(:message => value)"
255
367
  record.converted_syntax.should == 'allow(obj).to receive(:message).and_return(value)'
256
368
  end
@@ -259,28 +371,34 @@ module Transpec
259
371
  context "when it is `subject.#{method}(:a_method => a_value, b_method => b_value)` form" do
260
372
  let(:source) do
261
373
  <<-END
262
- it 'responds to #foo and returns 1, and responds to #bar and returns 2' do
263
- subject.#{method}(:foo => 1, :bar => 2)
374
+ describe 'example' do
375
+ it 'responds to #foo and returns 1, and responds to #bar and returns 2' do
376
+ subject.#{method}(:foo => 1, :bar => 2)
377
+ end
264
378
  end
265
379
  END
266
380
  end
267
381
 
268
382
  let(:expected_source) do
269
383
  <<-END
270
- it 'responds to #foo and returns 1, and responds to #bar and returns 2' do
271
- allow(subject).to receive(:foo).and_return(1)
272
- allow(subject).to receive(:bar).and_return(2)
384
+ describe 'example' do
385
+ it 'responds to #foo and returns 1, and responds to #bar and returns 2' do
386
+ allow(subject).to receive(:foo).and_return(1)
387
+ allow(subject).to receive(:bar).and_return(2)
388
+ end
273
389
  end
274
390
  END
275
391
  end
276
392
 
277
393
  it 'converts into `allow(subject).to receive(:a_method).and_return(a_value)` ' +
278
394
  'and `allow(subject).to receive(:b_method).and_return(b_value)` form' do
395
+ method_stub_object.allowize!
279
396
  rewritten_source.should == expected_source
280
397
  end
281
398
 
282
399
  it 'adds record ' +
283
400
  "\"`obj.#{method}(:message => value)` -> `allow(obj).to receive(:message).and_return(value)`\"" do
401
+ method_stub_object.allowize!
284
402
  record.original_syntax.should == "obj.#{method}(:message => value)"
285
403
  record.converted_syntax.should == 'allow(obj).to receive(:message).and_return(value)'
286
404
  end
@@ -288,28 +406,33 @@ module Transpec
288
406
  context 'when the statement continues over multi lines' do
289
407
  let(:source) do
290
408
  <<-END
291
- it 'responds to #foo and returns 1, and responds to #bar and returns 2' do
292
- subject
293
- .#{method}(
294
- :foo => 1,
295
- :bar => 2
296
- )
409
+ describe 'example' do
410
+ it 'responds to #foo and returns 1, and responds to #bar and returns 2' do
411
+ subject
412
+ .#{method}(
413
+ :foo => 1,
414
+ :bar => 2
415
+ )
416
+ end
297
417
  end
298
418
  END
299
419
  end
300
420
 
301
421
  let(:expected_source) do
302
422
  <<-END
303
- it 'responds to #foo and returns 1, and responds to #bar and returns 2' do
304
- allow(subject)
305
- .to receive(:foo).and_return(1)
306
- allow(subject)
307
- .to receive(:bar).and_return(2)
423
+ describe 'example' do
424
+ it 'responds to #foo and returns 1, and responds to #bar and returns 2' do
425
+ allow(subject)
426
+ .to receive(:foo).and_return(1)
427
+ allow(subject)
428
+ .to receive(:bar).and_return(2)
429
+ end
308
430
  end
309
431
  END
310
432
  end
311
433
 
312
434
  it 'keeps the style except around the hash' do
435
+ method_stub_object.allowize!
313
436
  rewritten_source.should == expected_source
314
437
  end
315
438
  end
@@ -320,17 +443,21 @@ module Transpec
320
443
  context "when it is `subject.#{method}(:method)` form" do
321
444
  let(:source) do
322
445
  <<-END
323
- it 'does not respond to #foo' do
324
- subject.#{method}(:foo)
446
+ describe 'example' do
447
+ it 'does not respond to #foo' do
448
+ subject.#{method}(:foo)
449
+ end
325
450
  end
326
451
  END
327
452
  end
328
453
 
329
454
  it 'does nothing' do
455
+ method_stub_object.allowize!
330
456
  rewritten_source.should == source
331
457
  end
332
458
 
333
459
  it 'reports nothing' do
460
+ method_stub_object.allowize!
334
461
  method_stub_object.report.records.should be_empty
335
462
  end
336
463
  end
@@ -340,26 +467,32 @@ module Transpec
340
467
  context "when it is `SomeClass.any_instance.#{method}(:method)` form" do
341
468
  let(:source) do
342
469
  <<-END
343
- it 'responds to #foo' do
344
- SomeClass.any_instance.#{method}(:foo)
470
+ describe 'example' do
471
+ it 'responds to #foo' do
472
+ SomeClass.any_instance.#{method}(:foo)
473
+ end
345
474
  end
346
475
  END
347
476
  end
348
477
 
349
478
  let(:expected_source) do
350
479
  <<-END
351
- it 'responds to #foo' do
352
- allow_any_instance_of(SomeClass).to receive(:foo)
480
+ describe 'example' do
481
+ it 'responds to #foo' do
482
+ allow_any_instance_of(SomeClass).to receive(:foo)
483
+ end
353
484
  end
354
485
  END
355
486
  end
356
487
 
357
488
  it 'converts into `allow_any_instance_of(SomeClass).to receive(:method)` form' do
489
+ method_stub_object.allowize!
358
490
  rewritten_source.should == expected_source
359
491
  end
360
492
 
361
493
  it "adds record \"`SomeClass.any_instance.#{method}(:message)` " +
362
494
  '-> `allow_any_instance_of(obj).to receive(:message)`"' do
495
+ method_stub_object.allowize!
363
496
  record.original_syntax.should == "SomeClass.any_instance.#{method}(:message)"
364
497
  record.converted_syntax.should == 'allow_any_instance_of(SomeClass).to receive(:message)'
365
498
  end
@@ -370,26 +503,30 @@ module Transpec
370
503
  context "when it is `SomeClass.any_instance.#{method}(:method)` form" do
371
504
  let(:source) do
372
505
  <<-END
373
- it 'does not respond to #foo' do
374
- SomeClass.any_instance.#{method}(:foo)
506
+ describe 'example' do
507
+ it 'does not respond to #foo' do
508
+ SomeClass.any_instance.#{method}(:foo)
509
+ end
375
510
  end
376
511
  END
377
512
  end
378
513
 
379
514
  it 'does nothing' do
515
+ method_stub_object.allowize!
380
516
  rewritten_source.should == source
381
517
  end
382
518
 
383
519
  it 'reports nothing' do
520
+ method_stub_object.allowize!
384
521
  method_stub_object.report.records.should be_empty
385
522
  end
386
523
  end
387
524
  end
388
525
  end
389
526
 
390
- describe '#replace_deprecated_method!' do
527
+ describe '#convert_deprecated_method!' do
391
528
  before do
392
- method_stub_object.replace_deprecated_method!
529
+ method_stub_object.convert_deprecated_method!
393
530
  end
394
531
 
395
532
  [
@@ -399,16 +536,20 @@ module Transpec
399
536
  context "when it is ##{method}" do
400
537
  let(:source) do
401
538
  <<-END
402
- it '#{description} #foo' do
403
- subject.#{method}(:foo)
539
+ describe 'example' do
540
+ it '#{description} #foo' do
541
+ subject.#{method}(:foo)
542
+ end
404
543
  end
405
544
  END
406
545
  end
407
546
 
408
547
  let(:expected_source) do
409
548
  <<-END
410
- it '#{description} #foo' do
411
- subject.#{replacement_method}(:foo)
549
+ describe 'example' do
550
+ it '#{description} #foo' do
551
+ subject.#{replacement_method}(:foo)
552
+ end
412
553
  end
413
554
  END
414
555
  end
@@ -432,8 +573,10 @@ module Transpec
432
573
  context "when it is ##{method}" do
433
574
  let(:source) do
434
575
  <<-END
435
- it '#{description} #foo' do
436
- subject.#{method}(:foo)
576
+ describe 'example' do
577
+ it '#{description} #foo' do
578
+ subject.#{method}(:foo)
579
+ end
437
580
  end
438
581
  END
439
582
  end
@@ -455,8 +598,10 @@ module Transpec
455
598
  context 'when it is `subject.stub(:method).any_number_of_times` form' do
456
599
  let(:source) do
457
600
  <<-END
458
- it 'responds to #foo' do
459
- subject.stub(:foo).any_number_of_times
601
+ describe 'example' do
602
+ it 'responds to #foo' do
603
+ subject.stub(:foo).any_number_of_times
604
+ end
460
605
  end
461
606
  END
462
607
  end
@@ -467,8 +612,10 @@ module Transpec
467
612
  context 'when it is `subject.stub(:method).with(arg).any_number_of_times` form' do
468
613
  let(:source) do
469
614
  <<-END
470
- it 'responds to #foo with 1' do
471
- subject.stub(:foo).with(1).any_number_of_times
615
+ describe 'example' do
616
+ it 'responds to #foo with 1' do
617
+ subject.stub(:foo).with(1).any_number_of_times
618
+ end
472
619
  end
473
620
  END
474
621
  end
@@ -479,8 +626,10 @@ module Transpec
479
626
  context 'when it is `subject.stub(:method).at_least(0)` form' do
480
627
  let(:source) do
481
628
  <<-END
482
- it 'responds to #foo' do
483
- subject.stub(:foo).at_least(0)
629
+ describe 'example' do
630
+ it 'responds to #foo' do
631
+ subject.stub(:foo).at_least(0)
632
+ end
484
633
  end
485
634
  END
486
635
  end
@@ -491,8 +640,10 @@ module Transpec
491
640
  context 'when it is `subject.stub(:method)` form' do
492
641
  let(:source) do
493
642
  <<-END
494
- it 'responds to #foo' do
495
- subject.stub(:foo)
643
+ describe 'example' do
644
+ it 'responds to #foo' do
645
+ subject.stub(:foo)
646
+ end
496
647
  end
497
648
  END
498
649
  end
@@ -509,16 +660,20 @@ module Transpec
509
660
  context 'when it is `subject.stub(:method).any_number_of_times` form' do
510
661
  let(:source) do
511
662
  <<-END
512
- it 'responds to #foo' do
513
- subject.stub(:foo).any_number_of_times
663
+ describe 'example' do
664
+ it 'responds to #foo' do
665
+ subject.stub(:foo).any_number_of_times
666
+ end
514
667
  end
515
668
  END
516
669
  end
517
670
 
518
671
  let(:expected_source) do
519
672
  <<-END
520
- it 'responds to #foo' do
521
- subject.stub(:foo)
673
+ describe 'example' do
674
+ it 'responds to #foo' do
675
+ subject.stub(:foo)
676
+ end
522
677
  end
523
678
  END
524
679
  end
@@ -531,16 +686,20 @@ module Transpec
531
686
  context 'when it is `subject.stub(:method).at_least(0)` form' do
532
687
  let(:source) do
533
688
  <<-END
534
- it 'responds to #foo' do
535
- subject.stub(:foo).at_least(0)
689
+ describe 'example' do
690
+ it 'responds to #foo' do
691
+ subject.stub(:foo).at_least(0)
692
+ end
536
693
  end
537
694
  END
538
695
  end
539
696
 
540
697
  let(:expected_source) do
541
698
  <<-END
542
- it 'responds to #foo' do
543
- subject.stub(:foo)
699
+ describe 'example' do
700
+ it 'responds to #foo' do
701
+ subject.stub(:foo)
702
+ end
544
703
  end
545
704
  END
546
705
  end
@@ -553,8 +712,10 @@ module Transpec
553
712
  context 'when it is `subject.stub(:method)` form' do
554
713
  let(:source) do
555
714
  <<-END
556
- it 'responds to #foo' do
557
- subject.stub(:foo)
715
+ describe 'example' do
716
+ it 'responds to #foo' do
717
+ subject.stub(:foo)
718
+ end
558
719
  end
559
720
  END
560
721
  end