transpec 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce0f0f3624392da60bc26a32d10f32a93ed866af
4
- data.tar.gz: c0492a785742c25c2f718c888253658b6fbe872d
3
+ metadata.gz: 184be0fbb9de5a2d47804fc8611719692da19749
4
+ data.tar.gz: abcbeecdc14d0061e07e50542a3fa784e4f890af
5
5
  SHA512:
6
- metadata.gz: 069b02b6bfd111b9ac243fd0559c6281417ca8be7e0e40d9bbe10cbf46f1a63fc6819d31f0d439acaad3c2f60c0a5dc00eb3d0b59374a9e23d76f4b495829a40
7
- data.tar.gz: 64212f1a93153c532e11dd6dc0d397a5f295c4064551663b8c43f2c70cac9f880bcf48b6893ef745a88fb3ec5378d7401384b23f91803708613f001b73519f2d
6
+ metadata.gz: b6edfa9df6df92ee56fa47a19b1fd389c92835f2e69bdd7a0cd64e9937b7f78af3890fb5cf8fdf408f2c9c167d1d056a5ae0b100f0c655e58edc46bcc7b514a2
7
+ data.tar.gz: a863cc647d30798d4c5815eef33e555dcb3a70c38c840277f05e57e398f9f40189346ad8f788d1068cb86f91745532ea2daf44edb97f7415cc8b24e0cc050468
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Master
4
4
 
5
+ ## v0.0.9
6
+
7
+ * Use `--disable allow_to_receive` to disable conversion from `obj.should_receive(:foo).any_number_of_times` to `allow(obj).to receive(:foo)` (Previously it was `--disable expect_to_receive`)
8
+
5
9
  ## v0.0.8
6
10
 
7
11
  * Support conversion from `not_to raise_error(SpecificErrorClass)` to `not_to raise_error`
data/README.md CHANGED
@@ -47,7 +47,7 @@ describe Account do
47
47
  end
48
48
 
49
49
  it 'does not raise error' do
50
- lambda { account.renew }.should_not raise_error
50
+ lambda { account.renew }.should_not raise_error(Account::RenewalError)
51
51
  end
52
52
  end
53
53
  end
@@ -150,7 +150,7 @@ $ transpec --disable expect_to_receive,allow_to_receive
150
150
 
151
151
  Conversion Type | Target Syntax | Converted Syntax
152
152
  --------------------|----------------------------------|----------------------------
153
- `expect_to_matcher` | `obj.should` | `expect(obj).to`
153
+ `expect_to_matcher` | `obj.should matcher` | `expect(obj).to matcher`
154
154
  `expect_to_receive` | `obj.should_receive` | `expect(obj).to receive`
155
155
  `allow_to_receive` | `obj.stub` | `allow(obj).to receive`
156
156
  `deprecated` | `obj.stub!`, `mock('foo')`, etc. | `obj.stub`, `double('foo')`
@@ -175,30 +175,30 @@ when parentheses are necessary to keep the meaning of the expression.
175
175
 
176
176
  ```ruby
177
177
  describe 'original spec' do
178
- it 'is example' do
178
+ it 'is an example' do
179
179
  1.should == 1
180
180
  2.should > 1
181
- 'string'.should =~ /str/
181
+ 'string'.should =~ /^str/
182
182
  [1, 2, 3].should =~ [2, 1, 3]
183
183
  { key: value }.should == { key: value }
184
184
  end
185
185
  end
186
186
 
187
187
  describe 'converted spec' do
188
- it 'is example' do
188
+ it 'is an example' do
189
189
  expect(1).to eq(1)
190
190
  expect(2).to be > 1
191
- expect('string').to match(/str/)
191
+ expect('string').to match(/^str/)
192
192
  expect([1, 2, 3]).to match_array([2, 1, 3])
193
193
  expect({ key: value }).to eq({ key: value })
194
194
  end
195
195
  end
196
196
 
197
197
  describe 'converted spec with -p/--no-parentheses-matcher-arg option' do
198
- it 'is example' do
198
+ it 'is an example' do
199
199
  expect(1).to eq 1
200
200
  expect(2).to be > 1
201
- expect('string').to match /str/
201
+ expect('string').to match /^str/
202
202
  expect([1, 2, 3]).to match_array [2, 1, 3]
203
203
  # With non-operator method, the parentheses are always required
204
204
  # to prevent the hash from being interpreted as a block.
@@ -207,6 +207,180 @@ describe 'converted spec with -p/--no-parentheses-matcher-arg option' do
207
207
  end
208
208
  ```
209
209
 
210
+ ## Supported Conversions
211
+
212
+ ### Standard expectations
213
+
214
+ ```ruby
215
+ # Target
216
+ obj.should matcher
217
+ obj.should_not matcher
218
+
219
+ # Converted
220
+ expect(obj).to matcher
221
+ expect(obj).not_to matcher
222
+ expect(obj).to_not matcher # with `--negative-form to_not`
223
+ ```
224
+
225
+ Disabled by: `--disable expect_to_matcher`
226
+
227
+ ### Operator matchers
228
+
229
+ ```ruby
230
+ # Target
231
+ 1.should == 1
232
+ 1.should < 2
233
+ Integer.should === 1
234
+ 'string'.should =~ /^str/
235
+ [1, 2, 3].should =~ [2, 1, 3]
236
+
237
+ # Converted
238
+ expect(1).to eq(1)
239
+ expect(1).to be < 2
240
+ expect(Integer).to be === 1
241
+ expect('string').to match(/^str/)
242
+ expect([1, 2, 3]).to match_array([2, 1, 3])
243
+ ```
244
+
245
+ ### `be_close` matcher
246
+
247
+ ```ruby
248
+ # Target
249
+ (1.0 / 3.0).should be_close(0.333, 0.001)
250
+
251
+ # Converted
252
+ (1.0 / 3.0).should be_within(0.001).of(0.333)
253
+ ```
254
+
255
+ Disabled by: `--disable deprecated`
256
+
257
+ ### Error expectations
258
+
259
+ ```ruby
260
+ # Target
261
+ lambda { do_something }.should raise_error
262
+ proc { do_something }.should raise_error
263
+ -> { do_something }.should raise_error
264
+
265
+ # Converted
266
+ expect { do_something }.to raise_error
267
+ ```
268
+
269
+ Disabled by: `--disable expect_to_matcher`
270
+
271
+ ### Negative error expectations with specific error
272
+
273
+ ```ruby
274
+ # Target
275
+ expect { do_something }.not_to raise_error(SomeErrorClass)
276
+ expect { do_something }.not_to raise_error('message')
277
+ expect { do_something }.not_to raise_error(SomeErrorClass, 'message')
278
+ lambda { do_something }.should_not raise_error(SomeErrorClass)
279
+
280
+ # Converted
281
+ expect { do_something }.not_to raise_error
282
+ lambda { do_something }.should_not raise_error # with `--disable expect_to_matcher`
283
+ ```
284
+
285
+ Disabled by: `--disable deprecated`
286
+
287
+ ### Message expectations
288
+
289
+ ```ruby
290
+ # Target
291
+ obj.should_receive(:foo)
292
+ SomeClass.any_instance.should_receive(:foo)
293
+
294
+ # Converted
295
+ expect(obj).to receive(:foo)
296
+ expect_any_instance_of(SomeClass).to receive(:foo)
297
+ ```
298
+
299
+ Disabled by: `--disable expect_to_receive`
300
+
301
+ ### Message expectations with `any_number_of_times`
302
+
303
+ ```ruby
304
+ # Target
305
+ obj.should_receive(:foo).any_number_of_times
306
+
307
+ SomeClass.any_instance.should_receive(:foo).any_number_of_times
308
+
309
+ # Converted
310
+ allow(obj).to receive(:foo)
311
+ obj.stub(:foo) # with `--disable allow_to_receive`
312
+
313
+ allow_any_instance_of(SomeClass).to receive(:foo)
314
+ SomeClass.any_instance.stub(:foo) # with `--disable allow_to_receive`
315
+ ```
316
+
317
+ Disabled by: `--disable deprecated`
318
+
319
+ ### Method stubs
320
+
321
+ ```ruby
322
+ # Target
323
+ obj.stub(:foo)
324
+
325
+ obj.stub!(:foo)
326
+
327
+ obj.stub(:foo => 1, :bar => 2)
328
+
329
+ SomeClass.any_instance.stub(:foo)
330
+
331
+ # Converted
332
+ allow(obj).to receive(:foo)
333
+
334
+ allow(obj).to receive(:foo)
335
+
336
+ allow(obj).to receive(:foo).and_return(1)
337
+ allow(obj).to receive(:bar).and_return(2)
338
+
339
+ allow_any_instance_of(SomeClass).to receive(:foo)
340
+ ```
341
+
342
+ Disabled by: `--disable allow_to_receive`
343
+
344
+ ### Deprecated method stub aliases
345
+
346
+ ```ruby
347
+ # Target
348
+ obj.stub!(:foo)
349
+ obj.unstub!(:foo)
350
+
351
+ # Converted
352
+ obj.stub(:foo) # with `--disable allow_to_receive`
353
+ obj.unstub(:foo)
354
+ ```
355
+
356
+ Disabled by: `--disable deprecated`
357
+
358
+ ### Method stubs with `any_number_of_times`
359
+
360
+ ```ruby
361
+ # Target
362
+ obj.stub(:foo).any_number_of_times
363
+
364
+ # Converted
365
+ allow(obj).to receive(:foo)
366
+ obj.stub(:foo) # with `--disable allow_to_receive`
367
+ ```
368
+
369
+ Disabled by: `--disable deprecated`
370
+
371
+ ### Deprecated test double aliases
372
+
373
+ ```ruby
374
+ # Target
375
+ stub('something')
376
+ mock('something')
377
+
378
+ # Converted
379
+ double('something')
380
+ ```
381
+
382
+ Disabled by: `--disable deprecated`
383
+
210
384
  ## Compatibility
211
385
 
212
386
  Tested on MRI 1.9, MRI 2.0 and JRuby in 1.9 mode.
@@ -49,7 +49,7 @@ describe Account do
49
49
  end
50
50
 
51
51
  it 'does not raise error' do
52
- lambda { account.renew }.should_not raise_error
52
+ lambda { account.renew }.should_not raise_error(Account::RenewalError)
53
53
  end
54
54
  end
55
55
  end
@@ -125,7 +125,7 @@ Conversion Type | Target Syntax | Converted Syntax
125
125
  --------------------|----------------------------------|----------------------------
126
126
  <%=
127
127
  conversion_type_table = <<END
128
- `expect_to_matcher` | `obj.should` | `expect(obj).to`
128
+ `expect_to_matcher` | `obj.should matcher` | `expect(obj).to matcher`
129
129
  `expect_to_receive` | `obj.should_receive` | `expect(obj).to receive`
130
130
  `allow_to_receive` | `obj.stub` | `allow(obj).to receive`
131
131
  `deprecated` | `obj.stub!`, `mock('foo')`, etc. | `obj.stub`, `double('foo')`
@@ -168,10 +168,10 @@ when parentheses are necessary to keep the meaning of the expression.
168
168
  <%=
169
169
  parenthesizing_example = <<END
170
170
  describe 'original spec' do
171
- it 'is example' do
171
+ it 'is an example' do
172
172
  1.should == 1
173
173
  2.should > 1
174
- 'string'.should =~ /str/
174
+ 'string'.should =~ /^str/
175
175
  [1, 2, 3].should =~ [2, 1, 3]
176
176
  { key: value }.should == { key: value }
177
177
  end
@@ -203,6 +203,180 @@ rewriter.rewrite(parenthesizing_example)
203
203
  -%>
204
204
  ```
205
205
 
206
+ ## Supported Conversions
207
+
208
+ ### Standard expectations
209
+
210
+ ```ruby
211
+ # Target
212
+ obj.should matcher
213
+ obj.should_not matcher
214
+
215
+ # Converted
216
+ expect(obj).to matcher
217
+ expect(obj).not_to matcher
218
+ expect(obj).to_not matcher # with `--negative-form to_not`
219
+ ```
220
+
221
+ Disabled by: `--disable expect_to_matcher`
222
+
223
+ ### Operator matchers
224
+
225
+ ```ruby
226
+ # Target
227
+ 1.should == 1
228
+ 1.should < 2
229
+ Integer.should === 1
230
+ 'string'.should =~ /^str/
231
+ [1, 2, 3].should =~ [2, 1, 3]
232
+
233
+ # Converted
234
+ expect(1).to eq(1)
235
+ expect(1).to be < 2
236
+ expect(Integer).to be === 1
237
+ expect('string').to match(/^str/)
238
+ expect([1, 2, 3]).to match_array([2, 1, 3])
239
+ ```
240
+
241
+ ### `be_close` matcher
242
+
243
+ ```ruby
244
+ # Target
245
+ (1.0 / 3.0).should be_close(0.333, 0.001)
246
+
247
+ # Converted
248
+ (1.0 / 3.0).should be_within(0.001).of(0.333)
249
+ ```
250
+
251
+ Disabled by: `--disable deprecated`
252
+
253
+ ### Error expectations
254
+
255
+ ```ruby
256
+ # Target
257
+ lambda { do_something }.should raise_error
258
+ proc { do_something }.should raise_error
259
+ -> { do_something }.should raise_error
260
+
261
+ # Converted
262
+ expect { do_something }.to raise_error
263
+ ```
264
+
265
+ Disabled by: `--disable expect_to_matcher`
266
+
267
+ ### Negative error expectations with specific error
268
+
269
+ ```ruby
270
+ # Target
271
+ expect { do_something }.not_to raise_error(SomeErrorClass)
272
+ expect { do_something }.not_to raise_error('message')
273
+ expect { do_something }.not_to raise_error(SomeErrorClass, 'message')
274
+ lambda { do_something }.should_not raise_error(SomeErrorClass)
275
+
276
+ # Converted
277
+ expect { do_something }.not_to raise_error
278
+ lambda { do_something }.should_not raise_error # with `--disable expect_to_matcher`
279
+ ```
280
+
281
+ Disabled by: `--disable deprecated`
282
+
283
+ ### Message expectations
284
+
285
+ ```ruby
286
+ # Target
287
+ obj.should_receive(:foo)
288
+ SomeClass.any_instance.should_receive(:foo)
289
+
290
+ # Converted
291
+ expect(obj).to receive(:foo)
292
+ expect_any_instance_of(SomeClass).to receive(:foo)
293
+ ```
294
+
295
+ Disabled by: `--disable expect_to_receive`
296
+
297
+ ### Message expectations with `any_number_of_times`
298
+
299
+ ```ruby
300
+ # Target
301
+ obj.should_receive(:foo).any_number_of_times
302
+
303
+ SomeClass.any_instance.should_receive(:foo).any_number_of_times
304
+
305
+ # Converted
306
+ allow(obj).to receive(:foo)
307
+ obj.stub(:foo) # with `--disable allow_to_receive`
308
+
309
+ allow_any_instance_of(SomeClass).to receive(:foo)
310
+ SomeClass.any_instance.stub(:foo) # with `--disable allow_to_receive`
311
+ ```
312
+
313
+ Disabled by: `--disable deprecated`
314
+
315
+ ### Method stubs
316
+
317
+ ```ruby
318
+ # Target
319
+ obj.stub(:foo)
320
+
321
+ obj.stub!(:foo)
322
+
323
+ obj.stub(:foo => 1, :bar => 2)
324
+
325
+ SomeClass.any_instance.stub(:foo)
326
+
327
+ # Converted
328
+ allow(obj).to receive(:foo)
329
+
330
+ allow(obj).to receive(:foo)
331
+
332
+ allow(obj).to receive(:foo).and_return(1)
333
+ allow(obj).to receive(:bar).and_return(2)
334
+
335
+ allow_any_instance_of(SomeClass).to receive(:foo)
336
+ ```
337
+
338
+ Disabled by: `--disable allow_to_receive`
339
+
340
+ ### Deprecated method stub aliases
341
+
342
+ ```ruby
343
+ # Target
344
+ obj.stub!(:foo)
345
+ obj.unstub!(:foo)
346
+
347
+ # Converted
348
+ obj.stub(:foo) # with `--disable allow_to_receive`
349
+ obj.unstub(:foo)
350
+ ```
351
+
352
+ Disabled by: `--disable deprecated`
353
+
354
+ ### Method stubs with `any_number_of_times`
355
+
356
+ ```ruby
357
+ # Target
358
+ obj.stub(:foo).any_number_of_times
359
+
360
+ # Converted
361
+ allow(obj).to receive(:foo)
362
+ obj.stub(:foo) # with `--disable allow_to_receive`
363
+ ```
364
+
365
+ Disabled by: `--disable deprecated`
366
+
367
+ ### Deprecated test double aliases
368
+
369
+ ```ruby
370
+ # Target
371
+ stub('something')
372
+ mock('something')
373
+
374
+ # Converted
375
+ double('something')
376
+ ```
377
+
378
+ Disabled by: `--disable deprecated`
379
+
206
380
  ## Compatibility
207
381
 
208
382
  Tested on MRI 1.9, MRI 2.0 and JRuby in 1.9 mode.
@@ -99,14 +99,18 @@ module Transpec
99
99
  end
100
100
 
101
101
  def process_should_receive(should_receive)
102
- if @configuration.convert_to_expect_to_receive?
103
- if should_receive.any_number_of_times? && @configuration.replace_deprecated_method?
104
- should_receive.allowize_any_number_of_times!(@configuration.negative_form_of_to)
105
- else
102
+ if should_receive.any_number_of_times?
103
+ if @configuration.replace_deprecated_method?
104
+ if @configuration.convert_to_allow_to_receive?
105
+ should_receive.allowize_any_number_of_times!(@configuration.negative_form_of_to)
106
+ else
107
+ should_receive.stubize_any_number_of_times!
108
+ end
109
+ elsif @configuration.convert_to_expect_to_receive?
106
110
  should_receive.expectize!(@configuration.negative_form_of_to)
107
111
  end
108
- elsif should_receive.any_number_of_times? && @configuration.replace_deprecated_method?
109
- should_receive.stubize_any_number_of_times!
112
+ elsif @configuration.convert_to_expect_to_receive?
113
+ should_receive.expectize!(@configuration.negative_form_of_to)
110
114
  end
111
115
  end
112
116
 
@@ -5,7 +5,7 @@ module Transpec
5
5
  module Version
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 8
8
+ PATCH = 9
9
9
 
10
10
  def self.to_s
11
11
  [MAJOR, MINOR, PATCH].join('.')
@@ -163,129 +163,158 @@ module Transpec
163
163
  describe '#process_should_receive' do
164
164
  let(:should_receive_object) { double('should_receive_object').as_null_object }
165
165
 
166
- context 'when Configuration#convert_to_expect_to_receive? is true' do
167
- before { configuration.convert_to_expect_to_receive = true }
166
+ shared_examples 'does nothing' do
167
+ it 'does nothing' do
168
+ should_receive_object.should_not_receive(:expectize!)
169
+ should_receive_object.should_not_receive(:allowize_any_number_of_times!)
170
+ should_receive_object.should_not_receive(:stubize_any_number_of_times!)
171
+ rewriter.process_should_receive(should_receive_object)
172
+ end
173
+ end
168
174
 
169
- context 'and ShouldReceive#any_number_of_times? returns true' do
170
- before { should_receive_object.stub(:any_number_of_times?).and_return(true) }
175
+ context 'when ShouldReceive#any_number_of_times? returns true' do
176
+ before { should_receive_object.stub(:any_number_of_times?).and_return(true) }
171
177
 
172
- context 'when Configuration#replace_deprecated_method? is true' do
173
- before { configuration.replace_deprecated_method = true }
178
+ context 'and Configuration#replace_deprecated_method? is true' do
179
+ before { configuration.replace_deprecated_method = true }
174
180
 
175
- context 'and Configuration#negative_form_of_to is "not_to"' do
176
- before { configuration.negative_form_of_to = 'not_to' }
181
+ context 'and Configuration#convert_to_allow_to_receive? is true' do
182
+ before { configuration.convert_to_allow_to_receive = true }
177
183
 
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
184
+ [true, false].each do |convert_to_expect_to_receive|
185
+ context "and Configuration#convert_to_expect_to_receive? is #{convert_to_expect_to_receive}" do
186
+ before { configuration.convert_to_expect_to_receive = convert_to_expect_to_receive }
183
187
 
184
- context 'and Configuration#negative_form_of_to is "to_not"' do
185
- before { configuration.negative_form_of_to = 'to_not' }
188
+ context 'and Configuration#negative_form_of_to is "not_to"' do
189
+ before { configuration.negative_form_of_to = 'not_to' }
186
190
 
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 }
191
+ it 'invokes ShouldReceive#allowize_any_number_of_times! with "not_to"' do
192
+ should_receive_object.should_receive(:allowize_any_number_of_times!).with('not_to')
193
+ rewriter.process_should_receive(should_receive_object)
194
+ end
195
+ end
196
196
 
197
- context 'and Configuration#negative_form_of_to is "not_to"' do
198
- before { configuration.negative_form_of_to = 'not_to' }
197
+ context 'and Configuration#negative_form_of_to is "to_not"' do
198
+ before { configuration.negative_form_of_to = 'to_not' }
199
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)
200
+ it 'invokes ShouldReceive#allowize_any_number_of_times! with "to_not"' do
201
+ should_receive_object.should_receive(:allowize_any_number_of_times!).with('to_not')
202
+ rewriter.process_should_receive(should_receive_object)
203
+ end
204
+ end
203
205
  end
204
206
  end
207
+ end
208
+
209
+ context 'and Configuration#convert_to_allow_to_receive? is false' do
210
+ before { configuration.convert_to_allow_to_receive = false }
205
211
 
206
- context 'and Configuration#negative_form_of_to is "to_not"' do
207
- before { configuration.negative_form_of_to = 'to_not' }
212
+ [true, false].each do |convert_to_expect_to_receive|
213
+ context "and Configuration#convert_to_expect_to_receive? is #{convert_to_expect_to_receive}" do
214
+ before { configuration.convert_to_expect_to_receive = convert_to_expect_to_receive }
208
215
 
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)
216
+ it 'invokes ShouldReceive#stubize_any_number_of_times!' do
217
+ should_receive_object.should_receive(:stubize_any_number_of_times!)
218
+ rewriter.process_should_receive(should_receive_object)
219
+ end
212
220
  end
213
221
  end
214
222
  end
215
223
  end
216
224
 
217
- context 'and ShouldReceive#any_number_of_times? returns false' do
218
- before { should_receive_object.stub(:any_number_of_times?).and_return(false) }
225
+ context 'and Configuration#replace_deprecated_method? is false' do
226
+ before { configuration.replace_deprecated_method = false }
219
227
 
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 }
228
+ [true, false].each do |convert_to_allow_to_receive|
229
+ context "and Configuration#convert_to_allow_to_receive? is #{convert_to_allow_to_receive}" do
230
+ before { configuration.convert_to_allow_to_receive = convert_to_allow_to_receive }
223
231
 
224
- context 'and Configuration#negative_form_of_to is "not_to"' do
225
- before { configuration.negative_form_of_to = 'not_to' }
232
+ context 'and Configuration#convert_to_expect_to_receive? is true' do
233
+ before { configuration.convert_to_expect_to_receive = true }
226
234
 
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)
235
+ context 'and Configuration#negative_form_of_to is "not_to"' do
236
+ before { configuration.negative_form_of_to = 'not_to' }
237
+
238
+ it 'invokes ShouldReceive#expectize! with "not_to"' do
239
+ should_receive_object.should_receive(:expectize!).with('not_to')
240
+ rewriter.process_should_receive(should_receive_object)
241
+ end
230
242
  end
231
- end
232
243
 
233
- context 'and Configuration#negative_form_of_to is "to_not"' do
234
- before { configuration.negative_form_of_to = 'to_not' }
244
+ context 'and Configuration#negative_form_of_to is "to_not"' do
245
+ before { configuration.negative_form_of_to = 'to_not' }
235
246
 
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)
247
+ it 'invokes ShouldReceive#expectize! with "to_not"' do
248
+ should_receive_object.should_receive(:expectize!).with('to_not')
249
+ rewriter.process_should_receive(should_receive_object)
250
+ end
239
251
  end
240
252
  end
253
+
254
+ context 'and Configuration#convert_to_expect_to_receive? is false' do
255
+ before { configuration.convert_to_expect_to_receive = false }
256
+
257
+ include_examples 'does nothing'
258
+ end
241
259
  end
242
260
  end
243
261
  end
244
262
  end
245
263
 
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
264
+ context 'when ShouldReceive#any_number_of_times? returns false' do
265
+ before { should_receive_object.stub(:any_number_of_times?).and_return(false) }
254
266
 
255
- context 'when Configuration#convert_to_expect_to_receive? is false' do
256
- before { configuration.convert_to_expect_to_receive = false }
267
+ context 'and Configuration#convert_to_expect_to_receive? is true' do
268
+ before { configuration.convert_to_expect_to_receive = true }
257
269
 
258
- context 'and ShouldReceive#any_number_of_times? returns true' do
259
- before { should_receive_object.stub(:any_number_of_times?).and_return(true) }
270
+ [true, false].each do |replace_deprecated_method|
271
+ context "and Configuration#replace_deprecated_method? is #{replace_deprecated_method}" do
272
+ before { configuration.replace_deprecated_method = replace_deprecated_method }
260
273
 
261
- context 'when Configuration#replace_deprecated_method? is true' do
262
- before { configuration.replace_deprecated_method = true }
274
+ [true, false].each do |convert_to_allow_to_receive|
275
+ context "and Configuration#convert_to_allow_to_receive? is #{convert_to_allow_to_receive}" do
276
+ before { configuration.convert_to_allow_to_receive = convert_to_allow_to_receive }
263
277
 
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
278
+ context 'and Configuration#negative_form_of_to is "not_to"' do
279
+ before { configuration.negative_form_of_to = 'not_to' }
280
+
281
+ it 'invokes ShouldReceive#expectize! with "not_to"' do
282
+ should_receive_object.should_receive(:expectize!).with('not_to')
283
+ rewriter.process_should_receive(should_receive_object)
284
+ end
285
+ end
269
286
 
270
- context 'when Configuration#replace_deprecated_method? is false' do
271
- before { configuration.replace_deprecated_method = false }
287
+ context 'and Configuration#negative_form_of_to is "to_not"' do
288
+ before { configuration.negative_form_of_to = 'to_not' }
272
289
 
273
- include_examples 'does nothing'
290
+ it 'invokes ShouldReceive#expectize! with "to_not"' do
291
+ should_receive_object.should_receive(:expectize!).with('to_not')
292
+ rewriter.process_should_receive(should_receive_object)
293
+ end
294
+ end
295
+ end
296
+ end
297
+ end
274
298
  end
275
299
  end
276
300
 
277
- context 'and ShouldReceive#any_number_of_times? returns false' do
278
- before { should_receive_object.stub(:any_number_of_times?).and_return(false) }
301
+ context 'and Configuration#convert_to_expect_to_receive? is false' do
302
+ before { configuration.convert_to_expect_to_receive = false }
279
303
 
280
304
  [true, false].each do |replace_deprecated_method|
281
- context "when Configuration#replace_deprecated_method? is #{replace_deprecated_method}" do
305
+ context "and Configuration#replace_deprecated_method? is #{replace_deprecated_method}" do
282
306
  before { configuration.replace_deprecated_method = replace_deprecated_method }
283
307
 
284
- include_examples 'does nothing'
308
+ [true, false].each do |convert_to_allow_to_receive|
309
+ context "and Configuration#convert_to_allow_to_receive? is #{convert_to_allow_to_receive}" do
310
+ before { configuration.convert_to_allow_to_receive = convert_to_allow_to_receive }
311
+
312
+ include_examples 'does nothing'
313
+ end
314
+ end
285
315
  end
286
316
  end
287
317
  end
288
-
289
318
  end
290
319
  end
291
320
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transpec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Nakayama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-22 00:00:00.000000000 Z
11
+ date: 2013-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser