transpec 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +4 -0
- data/README.md +15 -0
- data/README.md.erb +15 -0
- data/Rakefile +42 -7
- data/lib/transpec/rewriter.rb +9 -1
- data/lib/transpec/syntax/any_number_of_timesable.rb +42 -0
- data/lib/transpec/syntax/expectizable.rb +8 -2
- data/lib/transpec/syntax/method_stub.rb +2 -1
- data/lib/transpec/syntax/should_receive.rb +34 -27
- data/lib/transpec/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/transpec/cli_spec.rb +4 -4
- data/spec/transpec/rewriter_spec.rb +307 -126
- data/spec/transpec/syntax/be_close_spec.rb +19 -17
- data/spec/transpec/syntax/matcher_spec.rb +6 -6
- data/spec/transpec/syntax/method_stub_spec.rb +98 -18
- data/spec/transpec/syntax/should_receive_spec.rb +128 -8
- metadata +3 -2
@@ -29,28 +29,87 @@ module Transpec
|
|
29
29
|
|
30
30
|
let(:source) do
|
31
31
|
<<-END
|
32
|
-
RSpec.configure do |config|
|
33
|
-
config.expect_with :rspec do |c|
|
34
|
-
c.syntax = :should
|
35
|
-
end
|
36
|
-
|
37
|
-
config.mock_with :rspec do |c|
|
38
|
-
c.syntax = :should
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
32
|
describe 'example group' do
|
43
33
|
it 'is an example' do
|
44
|
-
something
|
45
|
-
something.stub!(:message)
|
34
|
+
something.should == 'foo'
|
46
35
|
something.should_receive(:message)
|
47
|
-
something.should_not == 'foo'
|
48
|
-
expect(1.0 / 3.0).to be_close(0.333, 0.001)
|
49
36
|
end
|
50
37
|
end
|
51
38
|
END
|
52
39
|
end
|
53
40
|
|
41
|
+
it 'dispatches found syntax objects to each handler method' do
|
42
|
+
rewriter.should_receive(:process_should).with(an_instance_of(Syntax::Should))
|
43
|
+
rewriter.should_receive(:process_should_receive).with(an_instance_of(Syntax::ShouldReceive))
|
44
|
+
rewriter.rewrite(source)
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when the source has overlapped rewrite targets' do
|
48
|
+
let(:source) do
|
49
|
+
<<-END
|
50
|
+
describe 'example group' do
|
51
|
+
it 'is an example' do
|
52
|
+
object.stub(:message => mock('something'))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
END
|
56
|
+
end
|
57
|
+
|
58
|
+
let(:expected_source) do
|
59
|
+
<<-END
|
60
|
+
describe 'example group' do
|
61
|
+
it 'is an example' do
|
62
|
+
allow(object).to receive(:message).and_return(double('something'))
|
63
|
+
end
|
64
|
+
end
|
65
|
+
END
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'rewrites all targets properly' do
|
69
|
+
should == expected_source
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when the source has a monkey-patched expectation outside of example group context' do
|
74
|
+
before do
|
75
|
+
configuration.convert_to_expect_to_matcher = true
|
76
|
+
rewriter.stub(:warn)
|
77
|
+
end
|
78
|
+
|
79
|
+
let(:source) do
|
80
|
+
<<-END
|
81
|
+
describe 'example group' do
|
82
|
+
class SomeClass
|
83
|
+
def some_method
|
84
|
+
1.should == 1
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'is an example' do
|
89
|
+
SomeClass.new.some_method
|
90
|
+
end
|
91
|
+
end
|
92
|
+
END
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'does not rewrite the expectation to non-monkey-patch syntax' do
|
96
|
+
should == source
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'warns to user' do
|
100
|
+
rewriter.should_receive(:warn) do |message|
|
101
|
+
message.should =~ /cannot/i
|
102
|
+
message.should =~ /context/i
|
103
|
+
end
|
104
|
+
|
105
|
+
rewriter.rewrite(source)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#process_should' do
|
111
|
+
let(:should_object) { double('should_object').as_null_object }
|
112
|
+
|
54
113
|
context 'when Configuration#convert_to_expect_to_matcher? is true' do
|
55
114
|
before { configuration.convert_to_expect_to_matcher = true }
|
56
115
|
|
@@ -58,8 +117,8 @@ module Transpec
|
|
58
117
|
before { configuration.negative_form_of_to = 'not_to' }
|
59
118
|
|
60
119
|
it 'invokes Should#expectize! with "not_to"' do
|
61
|
-
|
62
|
-
rewriter.
|
120
|
+
should_object.should_receive(:expectize!).with('not_to', anything)
|
121
|
+
rewriter.process_should(should_object)
|
63
122
|
end
|
64
123
|
end
|
65
124
|
|
@@ -67,8 +126,8 @@ module Transpec
|
|
67
126
|
before { configuration.negative_form_of_to = 'to_not' }
|
68
127
|
|
69
128
|
it 'invokes Should#expectize! with "to_not"' do
|
70
|
-
|
71
|
-
rewriter.
|
129
|
+
should_object.should_receive(:expectize!).with('to_not', anything)
|
130
|
+
rewriter.process_should(should_object)
|
72
131
|
end
|
73
132
|
end
|
74
133
|
|
@@ -76,8 +135,8 @@ module Transpec
|
|
76
135
|
before { configuration.parenthesize_matcher_arg = true }
|
77
136
|
|
78
137
|
it 'invokes Should#expectize! with true as second argument' do
|
79
|
-
|
80
|
-
rewriter.
|
138
|
+
should_object.should_receive(:expectize!).with(anything, true)
|
139
|
+
rewriter.process_should(should_object)
|
81
140
|
end
|
82
141
|
end
|
83
142
|
|
@@ -85,8 +144,8 @@ module Transpec
|
|
85
144
|
before { configuration.parenthesize_matcher_arg = false }
|
86
145
|
|
87
146
|
it 'invokes Should#expectize! with false as second argument' do
|
88
|
-
|
89
|
-
rewriter.
|
147
|
+
should_object.should_receive(:expectize!).with(anything, false)
|
148
|
+
rewriter.process_should(should_object)
|
90
149
|
end
|
91
150
|
end
|
92
151
|
end
|
@@ -95,87 +154,273 @@ module Transpec
|
|
95
154
|
before { configuration.convert_to_expect_to_matcher = false }
|
96
155
|
|
97
156
|
it 'does not invoke Should#expectize!' do
|
98
|
-
|
99
|
-
rewriter.
|
157
|
+
should_object.should_not_receive(:expectize!)
|
158
|
+
rewriter.process_should(should_object)
|
100
159
|
end
|
101
160
|
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#process_should_receive' do
|
164
|
+
let(:should_receive_object) { double('should_receive_object').as_null_object }
|
102
165
|
|
103
166
|
context 'when Configuration#convert_to_expect_to_receive? is true' do
|
104
167
|
before { configuration.convert_to_expect_to_receive = true }
|
105
168
|
|
106
|
-
context 'and
|
107
|
-
before {
|
169
|
+
context 'and ShouldReceive#any_number_of_times? returns true' do
|
170
|
+
before { should_receive_object.stub(:any_number_of_times?).and_return(true) }
|
171
|
+
|
172
|
+
context 'when Configuration#replace_deprecated_method? is true' do
|
173
|
+
before { configuration.replace_deprecated_method = true }
|
174
|
+
|
175
|
+
context 'and Configuration#negative_form_of_to is "not_to"' do
|
176
|
+
before { configuration.negative_form_of_to = 'not_to' }
|
108
177
|
|
109
|
-
|
110
|
-
|
111
|
-
|
178
|
+
it 'invokes ShouldReceive#allowize_any_number_of_times! with "not_to"' do
|
179
|
+
should_receive_object.should_receive(:allowize_any_number_of_times!).with('not_to')
|
180
|
+
rewriter.process_should_receive(should_receive_object)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
context 'and Configuration#negative_form_of_to is "to_not"' do
|
185
|
+
before { configuration.negative_form_of_to = 'to_not' }
|
186
|
+
|
187
|
+
it 'invokes ShouldReceive#allowize_any_number_of_times! with "to_not"' do
|
188
|
+
should_receive_object.should_receive(:allowize_any_number_of_times!).with('to_not')
|
189
|
+
rewriter.process_should_receive(should_receive_object)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'when Configuration#replace_deprecated_method? is false' do
|
195
|
+
before { configuration.replace_deprecated_method = false }
|
196
|
+
|
197
|
+
context 'and Configuration#negative_form_of_to is "not_to"' do
|
198
|
+
before { configuration.negative_form_of_to = 'not_to' }
|
199
|
+
|
200
|
+
it 'invokes ShouldReceive#expectize! with "not_to"' do
|
201
|
+
should_receive_object.should_receive(:expectize!).with('not_to')
|
202
|
+
rewriter.process_should_receive(should_receive_object)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
context 'and Configuration#negative_form_of_to is "to_not"' do
|
207
|
+
before { configuration.negative_form_of_to = 'to_not' }
|
208
|
+
|
209
|
+
it 'invokes ShouldReceive#expectize! with "to_not"' do
|
210
|
+
should_receive_object.should_receive(:expectize!).with('to_not')
|
211
|
+
rewriter.process_should_receive(should_receive_object)
|
212
|
+
end
|
213
|
+
end
|
112
214
|
end
|
113
215
|
end
|
114
216
|
|
115
|
-
context 'and
|
116
|
-
before {
|
217
|
+
context 'and ShouldReceive#any_number_of_times? returns false' do
|
218
|
+
before { should_receive_object.stub(:any_number_of_times?).and_return(false) }
|
219
|
+
|
220
|
+
[true, false].each do |replace_deprecated_method|
|
221
|
+
context "when Configuration#replace_deprecated_method? is #{replace_deprecated_method}" do
|
222
|
+
before { configuration.replace_deprecated_method = replace_deprecated_method }
|
223
|
+
|
224
|
+
context 'and Configuration#negative_form_of_to is "not_to"' do
|
225
|
+
before { configuration.negative_form_of_to = 'not_to' }
|
226
|
+
|
227
|
+
it 'invokes ShouldReceive#expectize! with "not_to"' do
|
228
|
+
should_receive_object.should_receive(:expectize!).with('not_to')
|
229
|
+
rewriter.process_should_receive(should_receive_object)
|
230
|
+
end
|
231
|
+
end
|
117
232
|
|
118
|
-
|
119
|
-
|
120
|
-
|
233
|
+
context 'and Configuration#negative_form_of_to is "to_not"' do
|
234
|
+
before { configuration.negative_form_of_to = 'to_not' }
|
235
|
+
|
236
|
+
it 'invokes ShouldReceive#expectize! with "to_not"' do
|
237
|
+
should_receive_object.should_receive(:expectize!).with('to_not')
|
238
|
+
rewriter.process_should_receive(should_receive_object)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
121
242
|
end
|
122
243
|
end
|
123
244
|
end
|
124
245
|
|
246
|
+
shared_examples 'does nothing' do
|
247
|
+
it 'does nothing' do
|
248
|
+
should_receive_object.should_not_receive(:expectize!)
|
249
|
+
should_receive_object.should_not_receive(:allowize_any_number_of_times!)
|
250
|
+
should_receive_object.should_not_receive(:stubize_any_number_of_times!)
|
251
|
+
rewriter.process_should_receive(should_receive_object)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
125
255
|
context 'when Configuration#convert_to_expect_to_receive? is false' do
|
126
256
|
before { configuration.convert_to_expect_to_receive = false }
|
127
257
|
|
128
|
-
|
129
|
-
|
130
|
-
|
258
|
+
context 'and ShouldReceive#any_number_of_times? returns true' do
|
259
|
+
before { should_receive_object.stub(:any_number_of_times?).and_return(true) }
|
260
|
+
|
261
|
+
context 'when Configuration#replace_deprecated_method? is true' do
|
262
|
+
before { configuration.replace_deprecated_method = true }
|
263
|
+
|
264
|
+
it 'invokes ShouldReceive#stubize_any_number_of_times! with "not_to"' do
|
265
|
+
should_receive_object.should_receive(:stubize_any_number_of_times!)
|
266
|
+
rewriter.process_should_receive(should_receive_object)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
context 'when Configuration#replace_deprecated_method? is false' do
|
271
|
+
before { configuration.replace_deprecated_method = false }
|
272
|
+
|
273
|
+
include_examples 'does nothing'
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
context 'and ShouldReceive#any_number_of_times? returns false' do
|
278
|
+
before { should_receive_object.stub(:any_number_of_times?).and_return(false) }
|
279
|
+
|
280
|
+
[true, false].each do |replace_deprecated_method|
|
281
|
+
context "when Configuration#replace_deprecated_method? is #{replace_deprecated_method}" do
|
282
|
+
before { configuration.replace_deprecated_method = replace_deprecated_method }
|
283
|
+
|
284
|
+
include_examples 'does nothing'
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
describe '#process_method_stub' do
|
293
|
+
let(:method_stub_object) { double('method_stub_object').as_null_object }
|
294
|
+
|
295
|
+
shared_examples 'invokes MethodStub#allowize!' do
|
296
|
+
it 'invokes MethodStub#allowize!' do
|
297
|
+
method_stub_object.should_receive(:allowize!)
|
298
|
+
rewriter.process_method_stub(method_stub_object)
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
shared_examples 'does not invoke MethodStub#allowize!' do
|
303
|
+
it 'does not invoke MethodStub#allowize!' do
|
304
|
+
method_stub_object.should_not_receive(:allowize!)
|
305
|
+
rewriter.process_method_stub(method_stub_object)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
shared_examples 'invokes MethodStub#replace_deprecated_method!' do
|
310
|
+
it 'invokes MethodStub#replace_deprecated_method!' do
|
311
|
+
method_stub_object.should_receive(:replace_deprecated_method!)
|
312
|
+
rewriter.process_method_stub(method_stub_object)
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
shared_examples 'does not invoke MethodStub#replace_deprecated_method!' do
|
317
|
+
it 'does not invoke MethodStub#replace_deprecated_method!' do
|
318
|
+
method_stub_object.should_not_receive(:replace_deprecated_method!)
|
319
|
+
rewriter.process_method_stub(method_stub_object)
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
shared_examples 'invokes MethodStub#remove_any_number_of_times!' do
|
324
|
+
it 'invokes MethodStub#remove_any_number_of_times!' do
|
325
|
+
method_stub_object.should_receive(:remove_any_number_of_times!)
|
326
|
+
rewriter.process_method_stub(method_stub_object)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
shared_examples 'does not invoke MethodStub#remove_any_number_of_times!' do
|
331
|
+
it 'does not invoke MethodStub#remove_any_number_of_times!' do
|
332
|
+
method_stub_object.should_not_receive(:remove_any_number_of_times!)
|
333
|
+
rewriter.process_method_stub(method_stub_object)
|
131
334
|
end
|
132
335
|
end
|
133
336
|
|
134
337
|
context 'when Configuration#convert_to_allow_to_receive? is true' do
|
135
338
|
before { configuration.convert_to_allow_to_receive = true }
|
136
339
|
|
137
|
-
|
138
|
-
|
139
|
-
|
340
|
+
context 'and Configuration#replace_deprecated_method? is true' do
|
341
|
+
before { configuration.replace_deprecated_method = true }
|
342
|
+
|
343
|
+
include_examples 'invokes MethodStub#allowize!'
|
344
|
+
include_examples 'does not invoke MethodStub#replace_deprecated_method!'
|
345
|
+
include_examples 'invokes MethodStub#remove_any_number_of_times!'
|
346
|
+
end
|
347
|
+
|
348
|
+
context 'and Configuration#replace_deprecated_method? is false' do
|
349
|
+
before { configuration.replace_deprecated_method = false }
|
350
|
+
|
351
|
+
include_examples 'invokes MethodStub#allowize!'
|
352
|
+
include_examples 'does not invoke MethodStub#replace_deprecated_method!'
|
353
|
+
include_examples 'does not invoke MethodStub#remove_any_number_of_times!'
|
140
354
|
end
|
141
355
|
end
|
142
356
|
|
143
357
|
context 'when Configuration#convert_to_allow_to_receive? is false' do
|
144
358
|
before { configuration.convert_to_allow_to_receive = false }
|
145
359
|
|
146
|
-
|
147
|
-
|
148
|
-
|
360
|
+
context 'and Configuration#replace_deprecated_method? is true' do
|
361
|
+
before { configuration.replace_deprecated_method = true }
|
362
|
+
|
363
|
+
include_examples 'does not invoke MethodStub#allowize!'
|
364
|
+
include_examples 'invokes MethodStub#replace_deprecated_method!'
|
365
|
+
include_examples 'invokes MethodStub#remove_any_number_of_times!'
|
366
|
+
end
|
367
|
+
|
368
|
+
context 'and Configuration#replace_deprecated_method? is false' do
|
369
|
+
before { configuration.replace_deprecated_method = false }
|
370
|
+
|
371
|
+
include_examples 'does not invoke MethodStub#allowize!'
|
372
|
+
include_examples 'does not invoke MethodStub#replace_deprecated_method!'
|
373
|
+
include_examples 'does not invoke MethodStub#remove_any_number_of_times!'
|
149
374
|
end
|
150
375
|
end
|
376
|
+
end
|
377
|
+
|
378
|
+
describe '#process_double' do
|
379
|
+
let(:double_object) { double('double_object').as_null_object }
|
151
380
|
|
152
381
|
context 'when Configuration#replace_deprecated_method? is true' do
|
153
382
|
before { configuration.replace_deprecated_method = true }
|
154
383
|
|
155
384
|
it 'invokes Double#convert_to_double!' do
|
156
|
-
|
157
|
-
rewriter.
|
385
|
+
double_object.should_receive(:convert_to_double!)
|
386
|
+
rewriter.process_double(double_object)
|
158
387
|
end
|
388
|
+
end
|
159
389
|
|
160
|
-
|
161
|
-
|
162
|
-
|
390
|
+
context 'when Configuration#replace_deprecated_method? is false' do
|
391
|
+
before { configuration.replace_deprecated_method = false }
|
392
|
+
|
393
|
+
it 'does not invoke Double#convert_to_double!' do
|
394
|
+
double_object.should_not_receive(:convert_to_double!)
|
395
|
+
rewriter.process_double(double_object)
|
163
396
|
end
|
164
397
|
end
|
398
|
+
end
|
399
|
+
|
400
|
+
describe '#process_be_close' do
|
401
|
+
let(:be_close_object) { double('be_close_object').as_null_object }
|
165
402
|
|
166
403
|
context 'when Configuration#replace_deprecated_method? is true' do
|
167
|
-
before { configuration.replace_deprecated_method =
|
404
|
+
before { configuration.replace_deprecated_method = true }
|
168
405
|
|
169
|
-
it '
|
170
|
-
|
171
|
-
rewriter.
|
406
|
+
it 'invokes BeClose#convert_to_be_within!' do
|
407
|
+
be_close_object.should_receive(:convert_to_be_within!)
|
408
|
+
rewriter.process_be_close(be_close_object)
|
172
409
|
end
|
410
|
+
end
|
411
|
+
|
412
|
+
context 'when Configuration#replace_deprecated_method? is true' do
|
413
|
+
before { configuration.replace_deprecated_method = false }
|
173
414
|
|
174
415
|
it 'does not invoke BeClose#convert_to_be_within!' do
|
175
|
-
|
176
|
-
rewriter.
|
416
|
+
be_close_object.should_not_receive(:convert_to_be_within!)
|
417
|
+
rewriter.process_be_close(be_close_object)
|
177
418
|
end
|
178
419
|
end
|
420
|
+
end
|
421
|
+
|
422
|
+
describe '#process_rspec_configure' do
|
423
|
+
let(:rspec_configure) { double('rspec_configure').as_null_object }
|
179
424
|
|
180
425
|
context 'when #need_to_modify_expectation_syntax_configuration? returns true' do
|
181
426
|
before do
|
@@ -183,9 +428,8 @@ module Transpec
|
|
183
428
|
end
|
184
429
|
|
185
430
|
it 'invokes RSpecConfigure#modify_expectation_syntaxes! with :expect' do
|
186
|
-
|
187
|
-
|
188
|
-
rewriter.rewrite(source)
|
431
|
+
rspec_configure.should_receive(:modify_expectation_syntaxes!).with(:expect)
|
432
|
+
rewriter.process_rspec_configure(rspec_configure)
|
189
433
|
end
|
190
434
|
end
|
191
435
|
|
@@ -195,8 +439,8 @@ module Transpec
|
|
195
439
|
end
|
196
440
|
|
197
441
|
it 'does not invoke RSpecConfigure#modify_expectation_syntaxes!' do
|
198
|
-
|
199
|
-
rewriter.
|
442
|
+
rspec_configure.should_not_receive(:modify_expectation_syntaxes!)
|
443
|
+
rewriter.process_rspec_configure(rspec_configure)
|
200
444
|
end
|
201
445
|
end
|
202
446
|
|
@@ -206,9 +450,8 @@ module Transpec
|
|
206
450
|
end
|
207
451
|
|
208
452
|
it 'invokes RSpecConfigure#modify_mock_syntaxes! with :expect' do
|
209
|
-
|
210
|
-
|
211
|
-
rewriter.rewrite(source)
|
453
|
+
rspec_configure.should_receive(:modify_mock_syntaxes!).with(:expect)
|
454
|
+
rewriter.process_rspec_configure(rspec_configure)
|
212
455
|
end
|
213
456
|
end
|
214
457
|
|
@@ -218,70 +461,8 @@ module Transpec
|
|
218
461
|
end
|
219
462
|
|
220
463
|
it 'does not invoke RSpecConfigure#modify_mock_syntaxes!' do
|
221
|
-
|
222
|
-
rewriter.
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
context 'when the source have overlapped rewrite targets' do
|
227
|
-
let(:source) do
|
228
|
-
<<-END
|
229
|
-
describe 'example group' do
|
230
|
-
it 'is an example' do
|
231
|
-
object.stub(:message => mock('something'))
|
232
|
-
end
|
233
|
-
end
|
234
|
-
END
|
235
|
-
end
|
236
|
-
|
237
|
-
let(:expected_source) do
|
238
|
-
<<-END
|
239
|
-
describe 'example group' do
|
240
|
-
it 'is an example' do
|
241
|
-
allow(object).to receive(:message).and_return(double('something'))
|
242
|
-
end
|
243
|
-
end
|
244
|
-
END
|
245
|
-
end
|
246
|
-
|
247
|
-
it 'rewrites all targets properly' do
|
248
|
-
should == expected_source
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
context 'when the source have a monkey-patched expectation outside of example group context' do
|
253
|
-
before do
|
254
|
-
configuration.convert_to_expect_to_matcher = true
|
255
|
-
rewriter.stub(:warn)
|
256
|
-
end
|
257
|
-
|
258
|
-
let(:source) do
|
259
|
-
<<-END
|
260
|
-
describe 'example group' do
|
261
|
-
class SomeClass
|
262
|
-
def some_method
|
263
|
-
1.should == 1
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
it 'is an example' do
|
268
|
-
SomeClass.new.some_method
|
269
|
-
end
|
270
|
-
end
|
271
|
-
END
|
272
|
-
end
|
273
|
-
|
274
|
-
it 'does not rewrite the expectation to non-monkey-patch syntax' do
|
275
|
-
should == source
|
276
|
-
end
|
277
|
-
|
278
|
-
it 'warns to user' do
|
279
|
-
rewriter.should_receive(:warn) do |message|
|
280
|
-
message.should =~ /cannot/i
|
281
|
-
message.should =~ /context/i
|
282
|
-
end
|
283
|
-
|
284
|
-
rewriter.rewrite(source)
|
464
|
+
rspec_configure.should_not_receive(:modify_mock_syntaxes!)
|
465
|
+
rewriter.process_rspec_configure(rspec_configure)
|
285
466
|
end
|
286
467
|
end
|
287
468
|
end
|
@@ -24,25 +24,27 @@ module Transpec
|
|
24
24
|
let(:in_example_group_context?) { true }
|
25
25
|
|
26
26
|
describe '#convert_to_be_within!' do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
context 'when it is `be_close(expected, delta)` form' do
|
28
|
+
let(:source) do
|
29
|
+
<<-END
|
30
|
+
it 'is close to 0.333' do
|
31
|
+
(1.0 / 3.0).should be_close(0.333, 0.001)
|
32
|
+
end
|
33
|
+
END
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
let(:expected_source) do
|
37
|
+
<<-END
|
38
|
+
it 'is close to 0.333' do
|
39
|
+
(1.0 / 3.0).should be_within(0.001).of(0.333)
|
40
|
+
end
|
41
|
+
END
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
it 'converts into `be_within(delta).of(expected)` form' do
|
45
|
+
be_close_object.convert_to_be_within!
|
46
|
+
rewritten_source.should == expected_source
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
@@ -155,11 +155,11 @@ module Transpec
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
-
context 'when it is `== (
|
158
|
+
context 'when it is `== (5 - 3) / (4 - 2)` form' do
|
159
159
|
let(:source) do
|
160
160
|
<<-END
|
161
161
|
it 'is 1' do
|
162
|
-
subject.should == (
|
162
|
+
subject.should == (5 - 3) / (4 - 2)
|
163
163
|
end
|
164
164
|
END
|
165
165
|
end
|
@@ -167,12 +167,12 @@ module Transpec
|
|
167
167
|
let(:expected_source) do
|
168
168
|
<<-END
|
169
169
|
it 'is 1' do
|
170
|
-
subject.should eq((
|
170
|
+
subject.should eq((5 - 3) / (4 - 2))
|
171
171
|
end
|
172
172
|
END
|
173
173
|
end
|
174
174
|
|
175
|
-
it 'converts into `eq((
|
175
|
+
it 'converts into `eq((5 - 3) / (4 - 2))` form' do
|
176
176
|
rewritten_source.should == expected_source
|
177
177
|
end
|
178
178
|
end
|
@@ -180,7 +180,7 @@ module Transpec
|
|
180
180
|
context "when it is `== { 'key' => 'value' }` form" do
|
181
181
|
let(:source) do
|
182
182
|
<<-END
|
183
|
-
it 'is
|
183
|
+
it 'is the hash' do
|
184
184
|
subject.should == { 'key' => 'value' }
|
185
185
|
end
|
186
186
|
END
|
@@ -188,7 +188,7 @@ module Transpec
|
|
188
188
|
|
189
189
|
let(:expected_source) do
|
190
190
|
<<-END
|
191
|
-
it 'is
|
191
|
+
it 'is the hash' do
|
192
192
|
subject.should eq({ 'key' => 'value' })
|
193
193
|
end
|
194
194
|
END
|