transpec 0.2.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +10 -0
- data/README.md +111 -56
- data/README.md.erb +117 -62
- data/lib/transpec/ast/node.rb +41 -0
- data/lib/transpec/base_rewriter.rb +55 -0
- data/lib/transpec/cli.rb +43 -153
- data/lib/transpec/configuration.rb +13 -9
- data/lib/transpec/{rewriter.rb → converter.rb} +44 -71
- data/lib/transpec/dynamic_analyzer/rewriter.rb +94 -0
- data/lib/transpec/dynamic_analyzer/runtime_data.rb +27 -0
- data/lib/transpec/dynamic_analyzer.rb +166 -0
- data/lib/transpec/file_finder.rb +53 -0
- data/lib/transpec/option_parser.rb +166 -0
- data/lib/transpec/{context.rb → static_context_inspector.rb} +2 -2
- data/lib/transpec/syntax/be_close.rb +7 -9
- data/lib/transpec/syntax/double.rb +6 -10
- data/lib/transpec/syntax/expect.rb +35 -0
- data/lib/transpec/syntax/have.rb +195 -0
- data/lib/transpec/syntax/method_stub.rb +22 -27
- data/lib/transpec/syntax/mixin/allow_no_message.rb +73 -0
- data/lib/transpec/syntax/mixin/any_instance.rb +22 -0
- data/lib/transpec/syntax/mixin/expectizable.rb +26 -0
- data/lib/transpec/syntax/mixin/have_matcher.rb +23 -0
- data/lib/transpec/syntax/mixin/monkey_patch.rb +37 -0
- data/lib/transpec/syntax/mixin/send.rb +109 -0
- data/lib/transpec/syntax/{matcher.rb → operator_matcher.rb} +27 -14
- data/lib/transpec/syntax/raise_error.rb +6 -10
- data/lib/transpec/syntax/rspec_configure.rb +29 -28
- data/lib/transpec/syntax/should.rb +45 -15
- data/lib/transpec/syntax/should_receive.rb +44 -16
- data/lib/transpec/syntax.rb +29 -21
- data/lib/transpec/util.rb +12 -2
- data/lib/transpec/version.rb +3 -3
- data/spec/spec_helper.rb +8 -6
- data/spec/support/cache_helper.rb +50 -0
- data/spec/support/shared_context.rb +49 -1
- data/spec/transpec/ast/node_spec.rb +65 -0
- data/spec/transpec/cli_spec.rb +33 -242
- data/spec/transpec/commit_message_spec.rb +2 -2
- data/spec/transpec/configuration_spec.rb +12 -8
- data/spec/transpec/{rewriter_spec.rb → converter_spec.rb} +198 -148
- data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +183 -0
- data/spec/transpec/dynamic_analyzer_spec.rb +164 -0
- data/spec/transpec/file_finder_spec.rb +118 -0
- data/spec/transpec/option_parser_spec.rb +185 -0
- data/spec/transpec/{context_spec.rb → static_context_inspector_spec.rb} +27 -12
- data/spec/transpec/syntax/be_close_spec.rb +8 -4
- data/spec/transpec/syntax/double_spec.rb +105 -12
- data/spec/transpec/syntax/expect_spec.rb +83 -0
- data/spec/transpec/syntax/have_spec.rb +599 -0
- data/spec/transpec/syntax/method_stub_spec.rb +276 -115
- data/spec/transpec/syntax/{matcher_spec.rb → operator_matcher_spec.rb} +277 -98
- data/spec/transpec/syntax/raise_error_spec.rb +92 -46
- data/spec/transpec/syntax/should_receive_spec.rb +298 -92
- data/spec/transpec/syntax/should_spec.rb +230 -44
- data/spec/transpec/util_spec.rb +2 -9
- data/tasks/lib/transpec_demo.rb +1 -1
- data/tasks/lib/transpec_test.rb +5 -7
- data/tasks/test.rake +5 -1
- data/transpec.gemspec +1 -1
- metadata +46 -22
- data/lib/transpec/syntax/able_to_allow_no_message.rb +0 -73
- data/lib/transpec/syntax/able_to_target_any_instance.rb +0 -24
- data/lib/transpec/syntax/expectizable.rb +0 -27
- data/lib/transpec/syntax/send_node_syntax.rb +0 -57
@@ -1,14 +1,14 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
-
require 'transpec/
|
4
|
+
require 'transpec/converter'
|
5
5
|
|
6
6
|
module Transpec
|
7
|
-
describe
|
8
|
-
subject(:
|
7
|
+
describe Converter do
|
8
|
+
subject(:converter) { Converter.new(configuration) }
|
9
9
|
let(:configuration) { Configuration.new }
|
10
10
|
|
11
|
-
describe '#
|
11
|
+
describe '#convert_file!' do
|
12
12
|
include_context 'isolated environment'
|
13
13
|
|
14
14
|
let(:file_path) { 'sample_spec.rb' }
|
@@ -16,28 +16,28 @@ module Transpec
|
|
16
16
|
before do
|
17
17
|
File.write(file_path, 'This is a spec')
|
18
18
|
File.utime(0, 0, file_path)
|
19
|
-
|
19
|
+
converter.stub(:rewrite).and_return('This is the converted spec')
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'overwrites the passed file path' do
|
23
|
-
|
24
|
-
File.read(file_path).should == 'This is the
|
23
|
+
converter.convert_file!(file_path)
|
24
|
+
File.read(file_path).should == 'This is the converted spec'
|
25
25
|
end
|
26
26
|
|
27
|
-
context 'when the source does not need
|
27
|
+
context 'when the source does not need convert' do
|
28
28
|
before do
|
29
|
-
|
29
|
+
converter.stub(:rewrite).and_return('This is a spec')
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'does not touch the file' do
|
33
|
-
|
33
|
+
converter.convert_file!(file_path)
|
34
34
|
File.mtime(file_path).should == Time.at(0)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe '#
|
40
|
-
subject {
|
39
|
+
describe '#convert' do
|
40
|
+
subject { converter.convert(source) }
|
41
41
|
|
42
42
|
let(:source) do
|
43
43
|
<<-END
|
@@ -51,12 +51,12 @@ module Transpec
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'dispatches found syntax objects to each handler method' do
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
converter.should_receive(:process_should).with(an_instance_of(Syntax::Should))
|
55
|
+
converter.should_receive(:process_should_receive).with(an_instance_of(Syntax::ShouldReceive))
|
56
|
+
converter.convert(source)
|
57
57
|
end
|
58
58
|
|
59
|
-
context 'when the source has overlapped
|
59
|
+
context 'when the source has overlapped convert targets' do
|
60
60
|
let(:source) do
|
61
61
|
<<-END
|
62
62
|
describe 'example group' do
|
@@ -77,20 +77,20 @@ module Transpec
|
|
77
77
|
END
|
78
78
|
end
|
79
79
|
|
80
|
-
it '
|
80
|
+
it 'converts all targets properly' do
|
81
81
|
should == expected_source
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'adds records for only completed conversions' do
|
85
|
-
|
86
|
-
|
85
|
+
converter.convert(source)
|
86
|
+
converter.report.records.count.should == 2
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
context 'when the source has a monkey-patched expectation outside of example group context' do
|
91
91
|
before do
|
92
|
-
configuration.
|
93
|
-
|
92
|
+
configuration.convert_should = true
|
93
|
+
converter.stub(:warn)
|
94
94
|
end
|
95
95
|
|
96
96
|
let(:source) do
|
@@ -109,7 +109,7 @@ module Transpec
|
|
109
109
|
END
|
110
110
|
end
|
111
111
|
|
112
|
-
it 'does not
|
112
|
+
it 'does not convert the expectation to non-monkey-patch syntax' do
|
113
113
|
should == source
|
114
114
|
end
|
115
115
|
end
|
@@ -118,15 +118,15 @@ module Transpec
|
|
118
118
|
describe '#process_should' do
|
119
119
|
let(:should_object) { double('should_object').as_null_object }
|
120
120
|
|
121
|
-
context 'when Configuration#
|
122
|
-
before { configuration.
|
121
|
+
context 'when Configuration#convert_should? is true' do
|
122
|
+
before { configuration.convert_should = true }
|
123
123
|
|
124
124
|
context 'and Configuration#negative_form_of_to is "not_to"' do
|
125
125
|
before { configuration.negative_form_of_to = 'not_to' }
|
126
126
|
|
127
127
|
it 'invokes Should#expectize! with "not_to"' do
|
128
128
|
should_object.should_receive(:expectize!).with('not_to', anything)
|
129
|
-
|
129
|
+
converter.process_should(should_object)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
@@ -135,7 +135,7 @@ module Transpec
|
|
135
135
|
|
136
136
|
it 'invokes Should#expectize! with "to_not"' do
|
137
137
|
should_object.should_receive(:expectize!).with('to_not', anything)
|
138
|
-
|
138
|
+
converter.process_should(should_object)
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -144,7 +144,7 @@ module Transpec
|
|
144
144
|
|
145
145
|
it 'invokes Should#expectize! with true as second argument' do
|
146
146
|
should_object.should_receive(:expectize!).with(anything, true)
|
147
|
-
|
147
|
+
converter.process_should(should_object)
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
@@ -153,17 +153,67 @@ module Transpec
|
|
153
153
|
|
154
154
|
it 'invokes Should#expectize! with false as second argument' do
|
155
155
|
should_object.should_receive(:expectize!).with(anything, false)
|
156
|
-
|
156
|
+
converter.process_should(should_object)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
-
context 'when Configuration#
|
162
|
-
before { configuration.
|
161
|
+
context 'when Configuration#convert_should? is false' do
|
162
|
+
before { configuration.convert_should = false }
|
163
163
|
|
164
164
|
it 'does not invoke Should#expectize!' do
|
165
165
|
should_object.should_not_receive(:expectize!)
|
166
|
-
|
166
|
+
converter.process_should(should_object)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'when Configuration#convert_have_items? is true' do
|
171
|
+
before { configuration.convert_have_items = true }
|
172
|
+
|
173
|
+
it 'invokes Have#convert_to_standard_expectation!' do
|
174
|
+
should_object.have_matcher.should_receive(:convert_to_standard_expectation!)
|
175
|
+
converter.process_should(should_object)
|
176
|
+
end
|
177
|
+
|
178
|
+
context 'and Configuration#convert_should? is true' do
|
179
|
+
before { configuration.convert_should = true }
|
180
|
+
|
181
|
+
it 'invokes Should#expectize! then Have#convert_to_standard_expectation!' do
|
182
|
+
should_object.should_receive(:expectize!).ordered
|
183
|
+
should_object.have_matcher.should_receive(:convert_to_standard_expectation!).ordered
|
184
|
+
converter.process_should(should_object)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
context 'when Configuration#convert_have_items? is false' do
|
190
|
+
before { configuration.convert_have_items = false }
|
191
|
+
|
192
|
+
it 'does not invoke Have#convert_to_standard_expectation!' do
|
193
|
+
should_object.have_matcher.should_not_receive(:convert_to_standard_expectation!)
|
194
|
+
converter.process_should(should_object)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '#process_expect' do
|
200
|
+
let(:expect_object) { double('expect_object').as_null_object }
|
201
|
+
|
202
|
+
context 'when Configuration#convert_have_items? is true' do
|
203
|
+
before { configuration.convert_have_items = true }
|
204
|
+
|
205
|
+
it 'invokes Have#convert_to_standard_expectation!' do
|
206
|
+
expect_object.have_matcher.should_receive(:convert_to_standard_expectation!)
|
207
|
+
converter.process_expect(expect_object)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context 'when Configuration#convert_have_items? is false' do
|
212
|
+
before { configuration.convert_have_items = false }
|
213
|
+
|
214
|
+
it 'does not invoke Have#convert_to_standard_expectation!' do
|
215
|
+
expect_object.have_matcher.should_not_receive(:convert_to_standard_expectation!)
|
216
|
+
converter.process_expect(expect_object)
|
167
217
|
end
|
168
218
|
end
|
169
219
|
end
|
@@ -176,29 +226,29 @@ module Transpec
|
|
176
226
|
should_receive_object.should_not_receive(:expectize!)
|
177
227
|
should_receive_object.should_not_receive(:allowize_any_number_of_times!)
|
178
228
|
should_receive_object.should_not_receive(:stubize_any_number_of_times!)
|
179
|
-
|
229
|
+
converter.process_should_receive(should_receive_object)
|
180
230
|
end
|
181
231
|
end
|
182
232
|
|
183
233
|
context 'when ShouldReceive#useless_expectation? returns true' do
|
184
234
|
before { should_receive_object.stub(:useless_expectation?).and_return(true) }
|
185
235
|
|
186
|
-
context 'and Configuration#
|
187
|
-
before { configuration.
|
236
|
+
context 'and Configuration#convert_deprecated_method? is true' do
|
237
|
+
before { configuration.convert_deprecated_method = true }
|
188
238
|
|
189
|
-
context 'and Configuration#
|
190
|
-
before { configuration.
|
239
|
+
context 'and Configuration#convert_stub? is true' do
|
240
|
+
before { configuration.convert_stub = true }
|
191
241
|
|
192
|
-
[true, false].each do |
|
193
|
-
context "and Configuration#
|
194
|
-
before { configuration.
|
242
|
+
[true, false].each do |convert_should_receive|
|
243
|
+
context "and Configuration#convert_should_receive? is #{convert_should_receive}" do
|
244
|
+
before { configuration.convert_should_receive = convert_should_receive }
|
195
245
|
|
196
246
|
context 'and Configuration#negative_form_of_to is "not_to"' do
|
197
247
|
before { configuration.negative_form_of_to = 'not_to' }
|
198
248
|
|
199
249
|
it 'invokes ShouldReceive#allowize_useless_expectation! with "not_to"' do
|
200
250
|
should_receive_object.should_receive(:allowize_useless_expectation!).with('not_to')
|
201
|
-
|
251
|
+
converter.process_should_receive(should_receive_object)
|
202
252
|
end
|
203
253
|
end
|
204
254
|
|
@@ -207,45 +257,45 @@ module Transpec
|
|
207
257
|
|
208
258
|
it 'invokes ShouldReceive#allowize_useless_expectation! with "to_not"' do
|
209
259
|
should_receive_object.should_receive(:allowize_useless_expectation!).with('to_not')
|
210
|
-
|
260
|
+
converter.process_should_receive(should_receive_object)
|
211
261
|
end
|
212
262
|
end
|
213
263
|
end
|
214
264
|
end
|
215
265
|
end
|
216
266
|
|
217
|
-
context 'and Configuration#
|
218
|
-
before { configuration.
|
267
|
+
context 'and Configuration#convert_stub? is false' do
|
268
|
+
before { configuration.convert_stub = false }
|
219
269
|
|
220
|
-
[true, false].each do |
|
221
|
-
context "and Configuration#
|
222
|
-
before { configuration.
|
270
|
+
[true, false].each do |convert_should_receive|
|
271
|
+
context "and Configuration#convert_should_receive? is #{convert_should_receive}" do
|
272
|
+
before { configuration.convert_should_receive = convert_should_receive }
|
223
273
|
|
224
274
|
it 'invokes ShouldReceive#stubize_useless_expectation!' do
|
225
275
|
should_receive_object.should_receive(:stubize_useless_expectation!)
|
226
|
-
|
276
|
+
converter.process_should_receive(should_receive_object)
|
227
277
|
end
|
228
278
|
end
|
229
279
|
end
|
230
280
|
end
|
231
281
|
end
|
232
282
|
|
233
|
-
context 'and Configuration#
|
234
|
-
before { configuration.
|
283
|
+
context 'and Configuration#convert_deprecated_method? is false' do
|
284
|
+
before { configuration.convert_deprecated_method = false }
|
235
285
|
|
236
|
-
[true, false].each do |
|
237
|
-
context "and Configuration#
|
238
|
-
before { configuration.
|
286
|
+
[true, false].each do |convert_stub|
|
287
|
+
context "and Configuration#convert_stub? is #{convert_stub}" do
|
288
|
+
before { configuration.convert_stub = convert_stub }
|
239
289
|
|
240
|
-
context 'and Configuration#
|
241
|
-
before { configuration.
|
290
|
+
context 'and Configuration#convert_should_receive? is true' do
|
291
|
+
before { configuration.convert_should_receive = true }
|
242
292
|
|
243
293
|
context 'and Configuration#negative_form_of_to is "not_to"' do
|
244
294
|
before { configuration.negative_form_of_to = 'not_to' }
|
245
295
|
|
246
296
|
it 'invokes ShouldReceive#expectize! with "not_to"' do
|
247
297
|
should_receive_object.should_receive(:expectize!).with('not_to')
|
248
|
-
|
298
|
+
converter.process_should_receive(should_receive_object)
|
249
299
|
end
|
250
300
|
end
|
251
301
|
|
@@ -254,13 +304,13 @@ module Transpec
|
|
254
304
|
|
255
305
|
it 'invokes ShouldReceive#expectize! with "to_not"' do
|
256
306
|
should_receive_object.should_receive(:expectize!).with('to_not')
|
257
|
-
|
307
|
+
converter.process_should_receive(should_receive_object)
|
258
308
|
end
|
259
309
|
end
|
260
310
|
end
|
261
311
|
|
262
|
-
context 'and Configuration#
|
263
|
-
before { configuration.
|
312
|
+
context 'and Configuration#convert_should_receive? is false' do
|
313
|
+
before { configuration.convert_should_receive = false }
|
264
314
|
|
265
315
|
include_examples 'does nothing'
|
266
316
|
end
|
@@ -272,23 +322,23 @@ module Transpec
|
|
272
322
|
context 'when ShouldReceive#useless_expectation? returns false' do
|
273
323
|
before { should_receive_object.stub(:useless_expectation?).and_return(false) }
|
274
324
|
|
275
|
-
context 'and Configuration#
|
276
|
-
before { configuration.
|
325
|
+
context 'and Configuration#convert_should_receive? is true' do
|
326
|
+
before { configuration.convert_should_receive = true }
|
277
327
|
|
278
|
-
[true, false].each do |
|
279
|
-
context "and Configuration#
|
280
|
-
before { configuration.
|
328
|
+
[true, false].each do |convert_deprecated_method|
|
329
|
+
context "and Configuration#convert_deprecated_method? is #{convert_deprecated_method}" do
|
330
|
+
before { configuration.convert_deprecated_method = convert_deprecated_method }
|
281
331
|
|
282
|
-
[true, false].each do |
|
283
|
-
context "and Configuration#
|
284
|
-
before { configuration.
|
332
|
+
[true, false].each do |convert_stub|
|
333
|
+
context "and Configuration#convert_stub? is #{convert_stub}" do
|
334
|
+
before { configuration.convert_stub = convert_stub }
|
285
335
|
|
286
336
|
context 'and Configuration#negative_form_of_to is "not_to"' do
|
287
337
|
before { configuration.negative_form_of_to = 'not_to' }
|
288
338
|
|
289
339
|
it 'invokes ShouldReceive#expectize! with "not_to"' do
|
290
340
|
should_receive_object.should_receive(:expectize!).with('not_to')
|
291
|
-
|
341
|
+
converter.process_should_receive(should_receive_object)
|
292
342
|
end
|
293
343
|
end
|
294
344
|
|
@@ -297,7 +347,7 @@ module Transpec
|
|
297
347
|
|
298
348
|
it 'invokes ShouldReceive#expectize! with "to_not"' do
|
299
349
|
should_receive_object.should_receive(:expectize!).with('to_not')
|
300
|
-
|
350
|
+
converter.process_should_receive(should_receive_object)
|
301
351
|
end
|
302
352
|
end
|
303
353
|
end
|
@@ -306,16 +356,16 @@ module Transpec
|
|
306
356
|
end
|
307
357
|
end
|
308
358
|
|
309
|
-
context 'and Configuration#
|
310
|
-
before { configuration.
|
359
|
+
context 'and Configuration#convert_should_receive? is false' do
|
360
|
+
before { configuration.convert_should_receive = false }
|
311
361
|
|
312
|
-
[true, false].each do |
|
313
|
-
context "and Configuration#
|
314
|
-
before { configuration.
|
362
|
+
[true, false].each do |convert_deprecated_method|
|
363
|
+
context "and Configuration#convert_deprecated_method? is #{convert_deprecated_method}" do
|
364
|
+
before { configuration.convert_deprecated_method = convert_deprecated_method }
|
315
365
|
|
316
|
-
[true, false].each do |
|
317
|
-
context "and Configuration#
|
318
|
-
before { configuration.
|
366
|
+
[true, false].each do |convert_stub|
|
367
|
+
context "and Configuration#convert_stub? is #{convert_stub}" do
|
368
|
+
before { configuration.convert_stub = convert_stub }
|
319
369
|
|
320
370
|
include_examples 'does nothing'
|
321
371
|
end
|
@@ -332,81 +382,81 @@ module Transpec
|
|
332
382
|
shared_examples 'invokes MethodStub#allowize!' do
|
333
383
|
it 'invokes MethodStub#allowize!' do
|
334
384
|
method_stub_object.should_receive(:allowize!)
|
335
|
-
|
385
|
+
converter.process_method_stub(method_stub_object)
|
336
386
|
end
|
337
387
|
end
|
338
388
|
|
339
389
|
shared_examples 'does not invoke MethodStub#allowize!' do
|
340
390
|
it 'does not invoke MethodStub#allowize!' do
|
341
391
|
method_stub_object.should_not_receive(:allowize!)
|
342
|
-
|
392
|
+
converter.process_method_stub(method_stub_object)
|
343
393
|
end
|
344
394
|
end
|
345
395
|
|
346
|
-
shared_examples 'invokes MethodStub#
|
347
|
-
it 'invokes MethodStub#
|
348
|
-
method_stub_object.should_receive(:
|
349
|
-
|
396
|
+
shared_examples 'invokes MethodStub#convert_deprecated_method!' do
|
397
|
+
it 'invokes MethodStub#convert_deprecated_method!' do
|
398
|
+
method_stub_object.should_receive(:convert_deprecated_method!)
|
399
|
+
converter.process_method_stub(method_stub_object)
|
350
400
|
end
|
351
401
|
end
|
352
402
|
|
353
|
-
shared_examples 'does not invoke MethodStub#
|
354
|
-
it 'does not invoke MethodStub#
|
355
|
-
method_stub_object.should_not_receive(:
|
356
|
-
|
403
|
+
shared_examples 'does not invoke MethodStub#convert_deprecated_method!' do
|
404
|
+
it 'does not invoke MethodStub#convert_deprecated_method!' do
|
405
|
+
method_stub_object.should_not_receive(:convert_deprecated_method!)
|
406
|
+
converter.process_method_stub(method_stub_object)
|
357
407
|
end
|
358
408
|
end
|
359
409
|
|
360
410
|
shared_examples 'invokes MethodStub#remove_allowance_for_no_message!' do
|
361
411
|
it 'invokes MethodStub#remove_allowance_for_no_message!' do
|
362
412
|
method_stub_object.should_receive(:remove_allowance_for_no_message!)
|
363
|
-
|
413
|
+
converter.process_method_stub(method_stub_object)
|
364
414
|
end
|
365
415
|
end
|
366
416
|
|
367
417
|
shared_examples 'does not invoke MethodStub#remove_allowance_for_no_message!' do
|
368
418
|
it 'does not invoke MethodStub#remove_allowance_for_no_message!' do
|
369
419
|
method_stub_object.should_not_receive(:remove_allowance_for_no_message!)
|
370
|
-
|
420
|
+
converter.process_method_stub(method_stub_object)
|
371
421
|
end
|
372
422
|
end
|
373
423
|
|
374
|
-
context 'when Configuration#
|
375
|
-
before { configuration.
|
424
|
+
context 'when Configuration#convert_stub? is true' do
|
425
|
+
before { configuration.convert_stub = true }
|
376
426
|
|
377
|
-
context 'and Configuration#
|
378
|
-
before { configuration.
|
427
|
+
context 'and Configuration#convert_deprecated_method? is true' do
|
428
|
+
before { configuration.convert_deprecated_method = true }
|
379
429
|
|
380
430
|
include_examples 'invokes MethodStub#allowize!'
|
381
|
-
include_examples 'does not invoke MethodStub#
|
431
|
+
include_examples 'does not invoke MethodStub#convert_deprecated_method!'
|
382
432
|
include_examples 'invokes MethodStub#remove_allowance_for_no_message!'
|
383
433
|
end
|
384
434
|
|
385
|
-
context 'and Configuration#
|
386
|
-
before { configuration.
|
435
|
+
context 'and Configuration#convert_deprecated_method? is false' do
|
436
|
+
before { configuration.convert_deprecated_method = false }
|
387
437
|
|
388
438
|
include_examples 'invokes MethodStub#allowize!'
|
389
|
-
include_examples 'does not invoke MethodStub#
|
439
|
+
include_examples 'does not invoke MethodStub#convert_deprecated_method!'
|
390
440
|
include_examples 'does not invoke MethodStub#remove_allowance_for_no_message!'
|
391
441
|
end
|
392
442
|
end
|
393
443
|
|
394
|
-
context 'when Configuration#
|
395
|
-
before { configuration.
|
444
|
+
context 'when Configuration#convert_stub? is false' do
|
445
|
+
before { configuration.convert_stub = false }
|
396
446
|
|
397
|
-
context 'and Configuration#
|
398
|
-
before { configuration.
|
447
|
+
context 'and Configuration#convert_deprecated_method? is true' do
|
448
|
+
before { configuration.convert_deprecated_method = true }
|
399
449
|
|
400
450
|
include_examples 'does not invoke MethodStub#allowize!'
|
401
|
-
include_examples 'invokes MethodStub#
|
451
|
+
include_examples 'invokes MethodStub#convert_deprecated_method!'
|
402
452
|
include_examples 'invokes MethodStub#remove_allowance_for_no_message!'
|
403
453
|
end
|
404
454
|
|
405
|
-
context 'and Configuration#
|
406
|
-
before { configuration.
|
455
|
+
context 'and Configuration#convert_deprecated_method? is false' do
|
456
|
+
before { configuration.convert_deprecated_method = false }
|
407
457
|
|
408
458
|
include_examples 'does not invoke MethodStub#allowize!'
|
409
|
-
include_examples 'does not invoke MethodStub#
|
459
|
+
include_examples 'does not invoke MethodStub#convert_deprecated_method!'
|
410
460
|
include_examples 'does not invoke MethodStub#remove_allowance_for_no_message!'
|
411
461
|
end
|
412
462
|
end
|
@@ -415,21 +465,21 @@ module Transpec
|
|
415
465
|
describe '#process_double' do
|
416
466
|
let(:double_object) { double('double_object').as_null_object }
|
417
467
|
|
418
|
-
context 'when Configuration#
|
419
|
-
before { configuration.
|
468
|
+
context 'when Configuration#convert_deprecated_method? is true' do
|
469
|
+
before { configuration.convert_deprecated_method = true }
|
420
470
|
|
421
471
|
it 'invokes Double#convert_to_double!' do
|
422
472
|
double_object.should_receive(:convert_to_double!)
|
423
|
-
|
473
|
+
converter.process_double(double_object)
|
424
474
|
end
|
425
475
|
end
|
426
476
|
|
427
|
-
context 'when Configuration#
|
428
|
-
before { configuration.
|
477
|
+
context 'when Configuration#convert_deprecated_method? is false' do
|
478
|
+
before { configuration.convert_deprecated_method = false }
|
429
479
|
|
430
480
|
it 'does not invoke Double#convert_to_double!' do
|
431
481
|
double_object.should_not_receive(:convert_to_double!)
|
432
|
-
|
482
|
+
converter.process_double(double_object)
|
433
483
|
end
|
434
484
|
end
|
435
485
|
end
|
@@ -437,21 +487,21 @@ module Transpec
|
|
437
487
|
describe '#process_be_close' do
|
438
488
|
let(:be_close_object) { double('be_close_object').as_null_object }
|
439
489
|
|
440
|
-
context 'when Configuration#
|
441
|
-
before { configuration.
|
490
|
+
context 'when Configuration#convert_deprecated_method? is true' do
|
491
|
+
before { configuration.convert_deprecated_method = true }
|
442
492
|
|
443
493
|
it 'invokes BeClose#convert_to_be_within!' do
|
444
494
|
be_close_object.should_receive(:convert_to_be_within!)
|
445
|
-
|
495
|
+
converter.process_be_close(be_close_object)
|
446
496
|
end
|
447
497
|
end
|
448
498
|
|
449
|
-
context 'when Configuration#
|
450
|
-
before { configuration.
|
499
|
+
context 'when Configuration#convert_deprecated_method? is true' do
|
500
|
+
before { configuration.convert_deprecated_method = false }
|
451
501
|
|
452
502
|
it 'does not invoke BeClose#convert_to_be_within!' do
|
453
503
|
be_close_object.should_not_receive(:convert_to_be_within!)
|
454
|
-
|
504
|
+
converter.process_be_close(be_close_object)
|
455
505
|
end
|
456
506
|
end
|
457
507
|
end
|
@@ -459,21 +509,21 @@ module Transpec
|
|
459
509
|
describe '#process_raise_error' do
|
460
510
|
let(:raise_error_object) { double('raise_error_object').as_null_object }
|
461
511
|
|
462
|
-
context 'when Configuration#
|
463
|
-
before { configuration.
|
512
|
+
context 'when Configuration#convert_deprecated_method? is true' do
|
513
|
+
before { configuration.convert_deprecated_method = true }
|
464
514
|
|
465
515
|
it 'invokes RaiseError#remove_error_specification_with_negative_expectation!' do
|
466
516
|
raise_error_object.should_receive(:remove_error_specification_with_negative_expectation!)
|
467
|
-
|
517
|
+
converter.process_raise_error(raise_error_object)
|
468
518
|
end
|
469
519
|
end
|
470
520
|
|
471
|
-
context 'when Configuration#
|
472
|
-
before { configuration.
|
521
|
+
context 'when Configuration#convert_deprecated_method? is true' do
|
522
|
+
before { configuration.convert_deprecated_method = false }
|
473
523
|
|
474
524
|
it 'does not invoke BeClose#convert_to_be_within!' do
|
475
525
|
raise_error_object.should_not_receive(:remove_error_specification_with_negative_expectation!)
|
476
|
-
|
526
|
+
converter.process_raise_error(raise_error_object)
|
477
527
|
end
|
478
528
|
end
|
479
529
|
end
|
@@ -483,45 +533,45 @@ module Transpec
|
|
483
533
|
|
484
534
|
context 'when #need_to_modify_expectation_syntax_configuration? returns true' do
|
485
535
|
before do
|
486
|
-
|
536
|
+
converter.stub(:need_to_modify_expectation_syntax_configuration?).and_return(true)
|
487
537
|
end
|
488
538
|
|
489
539
|
it 'invokes RSpecConfigure#modify_expectation_syntaxes! with :expect' do
|
490
540
|
rspec_configure.should_receive(:modify_expectation_syntaxes!).with(:expect)
|
491
|
-
|
541
|
+
converter.process_rspec_configure(rspec_configure)
|
492
542
|
end
|
493
543
|
end
|
494
544
|
|
495
545
|
context 'when #need_to_modify_expectation_syntax_configuration? returns false' do
|
496
546
|
before do
|
497
|
-
|
547
|
+
converter.stub(:need_to_modify_expectation_syntax_configuration?).and_return(false)
|
498
548
|
end
|
499
549
|
|
500
550
|
it 'does not invoke RSpecConfigure#modify_expectation_syntaxes!' do
|
501
551
|
rspec_configure.should_not_receive(:modify_expectation_syntaxes!)
|
502
|
-
|
552
|
+
converter.process_rspec_configure(rspec_configure)
|
503
553
|
end
|
504
554
|
end
|
505
555
|
|
506
556
|
context 'when #need_to_modify_mock_syntax_configuration? returns true' do
|
507
557
|
before do
|
508
|
-
|
558
|
+
converter.stub(:need_to_modify_mock_syntax_configuration?).and_return(true)
|
509
559
|
end
|
510
560
|
|
511
561
|
it 'invokes RSpecConfigure#modify_mock_syntaxes! with :expect' do
|
512
562
|
rspec_configure.should_receive(:modify_mock_syntaxes!).with(:expect)
|
513
|
-
|
563
|
+
converter.process_rspec_configure(rspec_configure)
|
514
564
|
end
|
515
565
|
end
|
516
566
|
|
517
567
|
context 'when #need_to_modify_mock_syntax_configuration? returns false' do
|
518
568
|
before do
|
519
|
-
|
569
|
+
converter.stub(:need_to_modify_mock_syntax_configuration?).and_return(false)
|
520
570
|
end
|
521
571
|
|
522
572
|
it 'does not invoke RSpecConfigure#modify_mock_syntaxes!' do
|
523
573
|
rspec_configure.should_not_receive(:modify_mock_syntaxes!)
|
524
|
-
|
574
|
+
converter.process_rspec_configure(rspec_configure)
|
525
575
|
end
|
526
576
|
end
|
527
577
|
end
|
@@ -551,11 +601,11 @@ module Transpec
|
|
551
601
|
end
|
552
602
|
|
553
603
|
describe '#need_to_modify_expectation_syntax_configuration?' do
|
554
|
-
subject {
|
604
|
+
subject { converter.need_to_modify_expectation_syntax_configuration?(rspec_configure) }
|
555
605
|
let(:rspec_configure) { double('rspec_configure') }
|
556
606
|
|
557
|
-
context 'when Configuration#
|
558
|
-
before { configuration.
|
607
|
+
context 'when Configuration#convert_should? is true' do
|
608
|
+
before { configuration.convert_should = true }
|
559
609
|
|
560
610
|
include_examples 'syntaxes', :expectation_syntaxes, {
|
561
611
|
[] => false,
|
@@ -565,8 +615,8 @@ module Transpec
|
|
565
615
|
}
|
566
616
|
end
|
567
617
|
|
568
|
-
context 'when Configuration#
|
569
|
-
before { configuration.
|
618
|
+
context 'when Configuration#convert_should? is false' do
|
619
|
+
before { configuration.convert_should = false }
|
570
620
|
|
571
621
|
include_examples 'syntaxes', :expectation_syntaxes, {
|
572
622
|
[] => false,
|
@@ -578,14 +628,14 @@ module Transpec
|
|
578
628
|
end
|
579
629
|
|
580
630
|
describe '#need_to_modify_mock_syntax_configuration?' do
|
581
|
-
subject {
|
631
|
+
subject { converter.need_to_modify_mock_syntax_configuration?(rspec_configure) }
|
582
632
|
let(:rspec_configure) { double('rspec_configure') }
|
583
633
|
|
584
|
-
context 'when Configuration#
|
585
|
-
before { configuration.
|
634
|
+
context 'when Configuration#convert_should_receive? is true' do
|
635
|
+
before { configuration.convert_should_receive = true }
|
586
636
|
|
587
|
-
context 'and Configuration#
|
588
|
-
before { configuration.
|
637
|
+
context 'and Configuration#convert_stub? is true' do
|
638
|
+
before { configuration.convert_stub = true }
|
589
639
|
|
590
640
|
include_examples 'syntaxes', :mock_syntaxes, {
|
591
641
|
[] => false,
|
@@ -595,8 +645,8 @@ module Transpec
|
|
595
645
|
}
|
596
646
|
end
|
597
647
|
|
598
|
-
context 'and Configuration#
|
599
|
-
before { configuration.
|
648
|
+
context 'and Configuration#convert_stub? is false' do
|
649
|
+
before { configuration.convert_stub = false }
|
600
650
|
|
601
651
|
include_examples 'syntaxes', :mock_syntaxes, {
|
602
652
|
[] => false,
|
@@ -607,11 +657,11 @@ module Transpec
|
|
607
657
|
end
|
608
658
|
end
|
609
659
|
|
610
|
-
context 'when Configuration#
|
611
|
-
before { configuration.
|
660
|
+
context 'when Configuration#convert_should_receive? is false' do
|
661
|
+
before { configuration.convert_should_receive = false }
|
612
662
|
|
613
|
-
context 'and Configuration#
|
614
|
-
before { configuration.
|
663
|
+
context 'and Configuration#convert_stub? is true' do
|
664
|
+
before { configuration.convert_stub = true }
|
615
665
|
|
616
666
|
include_examples 'syntaxes', :mock_syntaxes, {
|
617
667
|
[] => false,
|
@@ -621,8 +671,8 @@ module Transpec
|
|
621
671
|
}
|
622
672
|
end
|
623
673
|
|
624
|
-
context 'and Configuration#
|
625
|
-
before { configuration.
|
674
|
+
context 'and Configuration#convert_stub? is false' do
|
675
|
+
before { configuration.convert_stub = false }
|
626
676
|
|
627
677
|
include_examples 'syntaxes', :mock_syntaxes, {
|
628
678
|
[] => false,
|