transpec 3.0.0 → 3.0.1

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/CHANGELOG.md +4 -0
  4. data/lib/transpec/version.rb +1 -1
  5. data/transpec.gemspec +4 -3
  6. metadata +3 -97
  7. data/spec/.rubocop.yml +0 -23
  8. data/spec/integration/configuration_modification_spec.rb +0 -186
  9. data/spec/integration/conversion_spec.rb +0 -145
  10. data/spec/spec_helper.rb +0 -52
  11. data/spec/support/cache_helper.rb +0 -62
  12. data/spec/support/file_helper.rb +0 -25
  13. data/spec/support/shared_context.rb +0 -84
  14. data/spec/transpec/cli_spec.rb +0 -341
  15. data/spec/transpec/commit_message_spec.rb +0 -81
  16. data/spec/transpec/config_spec.rb +0 -99
  17. data/spec/transpec/converter_spec.rb +0 -1374
  18. data/spec/transpec/directory_cloner_spec.rb +0 -74
  19. data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +0 -143
  20. data/spec/transpec/dynamic_analyzer_spec.rb +0 -329
  21. data/spec/transpec/git_spec.rb +0 -151
  22. data/spec/transpec/option_parser_spec.rb +0 -275
  23. data/spec/transpec/processed_source_spec.rb +0 -93
  24. data/spec/transpec/project_spec.rb +0 -194
  25. data/spec/transpec/record_spec.rb +0 -128
  26. data/spec/transpec/report_spec.rb +0 -126
  27. data/spec/transpec/rspec_version_spec.rb +0 -129
  28. data/spec/transpec/spec_file_finder_spec.rb +0 -118
  29. data/spec/transpec/spec_suite_spec.rb +0 -108
  30. data/spec/transpec/static_context_inspector_spec.rb +0 -713
  31. data/spec/transpec/syntax/allow_spec.rb +0 -122
  32. data/spec/transpec/syntax/be_boolean_spec.rb +0 -176
  33. data/spec/transpec/syntax/be_close_spec.rb +0 -51
  34. data/spec/transpec/syntax/current_example_spec.rb +0 -319
  35. data/spec/transpec/syntax/double_spec.rb +0 -175
  36. data/spec/transpec/syntax/example_group_spec.rb +0 -716
  37. data/spec/transpec/syntax/example_spec.rb +0 -301
  38. data/spec/transpec/syntax/expect_spec.rb +0 -313
  39. data/spec/transpec/syntax/have_spec.rb +0 -1276
  40. data/spec/transpec/syntax/hook_spec.rb +0 -215
  41. data/spec/transpec/syntax/its_spec.rb +0 -448
  42. data/spec/transpec/syntax/matcher_definition_spec.rb +0 -59
  43. data/spec/transpec/syntax/method_stub_spec.rb +0 -1301
  44. data/spec/transpec/syntax/oneliner_should_spec.rb +0 -628
  45. data/spec/transpec/syntax/operator_spec.rb +0 -871
  46. data/spec/transpec/syntax/pending_spec.rb +0 -415
  47. data/spec/transpec/syntax/raise_error_spec.rb +0 -354
  48. data/spec/transpec/syntax/receive_spec.rb +0 -499
  49. data/spec/transpec/syntax/rspec_configure_spec.rb +0 -870
  50. data/spec/transpec/syntax/should_receive_spec.rb +0 -1108
  51. data/spec/transpec/syntax/should_spec.rb +0 -497
  52. data/spec/transpec/util_spec.rb +0 -115
  53. data/spec/transpec_spec.rb +0 -22
@@ -1,81 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'transpec/commit_message'
5
- require 'transpec/report'
6
- require 'transpec/record'
7
- require 'transpec/rspec_version'
8
-
9
- module Transpec
10
- describe CommitMessage do
11
- subject(:commit_message) { CommitMessage.new(report, rspec_version, cli_args) }
12
- let(:report) { Report.new }
13
- let(:rspec_version) { RSpecVersion.new('2.99.0.beta1') }
14
- let(:cli_args) { ['--force', '--rspec-command', 'bundle exec rspec'] }
15
-
16
- before do
17
- report.records << Record.new('obj.stub(:message)', 'allow(obj).to receive(:message)')
18
- report.records << Record.new('obj.should', 'expect(obj).to')
19
- report.records << Record.new('obj.should', 'expect(obj).to')
20
- end
21
-
22
- describe '#to_s' do
23
- it 'wraps lines within 72 characters except URLs' do
24
- commit_message.to_s.each_line do |line|
25
- next if line.match(%r{\bhttps?://})
26
- line.chomp.size.should <= 72
27
- end
28
- end
29
-
30
- let(:lines) { commit_message.to_s.lines.to_a }
31
-
32
- describe 'first line' do
33
- it 'has concise summary' do
34
- lines[0].chomp.should == 'Convert specs to RSpec 2.99.0.beta1 syntax with Transpec'
35
- end
36
- end
37
-
38
- describe 'second line' do
39
- it 'has blank line' do
40
- lines[1].chomp.should be_empty
41
- end
42
- end
43
-
44
- let(:body_lines) { lines[2..-1] }
45
-
46
- describe 'body' do
47
- it 'has Transpec description at the beginning' do
48
- body_lines[0].chomp
49
- .should match(/^This conversion is done by Transpec \d+\.\d+\.\d+ with the following command:$/)
50
- body_lines[1].chomp
51
- .should == ' transpec --force --rspec-command "bundle exec rspec"'
52
- end
53
-
54
- it 'has blank line after the preface' do
55
- body_lines[2].chomp.should be_empty
56
- end
57
-
58
- it 'has conversion summary' do
59
- body_lines[3..-3].join('').should == <<-END.gsub(/^\s+\|/, '')
60
- |* 2 conversions
61
- | from: obj.should
62
- | to: expect(obj).to
63
- |
64
- |* 1 conversion
65
- | from: obj.stub(:message)
66
- | to: allow(obj).to receive(:message)
67
- END
68
- end
69
-
70
- it 'has blank line after the summary' do
71
- body_lines[-2].chomp.should be_empty
72
- end
73
-
74
- it 'has the URL at the last line' do
75
- body_lines[-1].chomp.should ==
76
- 'For more details: https://github.com/yujinakayama/transpec#supported-conversions'
77
- end
78
- end
79
- end
80
- end
81
- end
@@ -1,99 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'transpec/config'
5
-
6
- module Transpec
7
- describe Config do
8
- subject(:config) { Config.new }
9
-
10
- context 'by default' do
11
- [
12
- [:forced?, false],
13
- [:convert_should?, true],
14
- [:convert_oneliner?, true],
15
- [:convert_should_receive?, true],
16
- [:convert_stub?, true],
17
- [:convert_have_items?, true],
18
- [:convert_its?, true],
19
- [:convert_pending?, true],
20
- [:convert_deprecated_method?, true],
21
- [:convert_example_group?, false],
22
- [:convert_hook_scope?, false],
23
- [:convert_stub_with_hash_to_allow_to_receive_and_return?, false],
24
- [:skip_dynamic_analysis?, false],
25
- [:negative_form_of_to, 'not_to'],
26
- [:boolean_matcher_type, :conditional],
27
- [:form_of_be_falsey, 'be_falsey'],
28
- [:add_explicit_type_metadata_to_example_group?, false],
29
- [:add_receiver_arg_to_any_instance_implementation_block?, true],
30
- [:parenthesize_matcher_arg?, true]
31
- ].each do |attribute, value|
32
- describe "##{attribute}" do
33
- subject { config.send(attribute) }
34
-
35
- it "is #{value.inspect}" do
36
- should == value
37
- end
38
- end
39
- end
40
- end
41
-
42
- describe '#negative_form_of_to=' do
43
- ['not_to', 'to_not'] .each do |form|
44
- context "when #{form.inspect} is passed" do
45
- it "sets #{form.inspect}" do
46
- config.negative_form_of_to = form
47
- config.negative_form_of_to.should == form
48
- end
49
- end
50
- end
51
-
52
- context 'when a form other than "not_to" or "to_not" is passed' do
53
- it 'raises error' do
54
- lambda do
55
- config.negative_form_of_to = 'foo'
56
- end.should raise_error(ArgumentError)
57
- end
58
- end
59
- end
60
-
61
- describe '#boolean_matcher_type=' do
62
- [:conditional, :exact] .each do |type|
63
- context "when #{type.inspect} is passed" do
64
- it "sets #{type.inspect}" do
65
- config.boolean_matcher_type = type
66
- config.boolean_matcher_type.should == type
67
- end
68
- end
69
- end
70
-
71
- context 'when a type other than :conditional or :exact is passed' do
72
- it 'raises error' do
73
- lambda do
74
- config.boolean_matcher_type = :foo
75
- end.should raise_error(ArgumentError)
76
- end
77
- end
78
- end
79
-
80
- describe '#form_of_be_falsey=' do
81
- ['be_falsey', 'be_falsy'] .each do |form|
82
- context "when #{form.inspect} is passed" do
83
- it "sets #{form.inspect}" do
84
- config.form_of_be_falsey = form
85
- config.form_of_be_falsey.should == form
86
- end
87
- end
88
- end
89
-
90
- context 'when a form other than "be_falsey" or "be_falsy" is passed' do
91
- it 'raises error' do
92
- lambda do
93
- config.form_of_be_falsey = 'foo'
94
- end.should raise_error(ArgumentError)
95
- end
96
- end
97
- end
98
- end
99
- end
@@ -1,1374 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'transpec/converter'
5
-
6
- module Transpec
7
- describe Converter do
8
- subject(:converter) { Converter.new(spec_suite, project, config) }
9
- let(:spec_suite) { double('spec_suite', runtime_data: nil).as_null_object }
10
- let(:project) { Project.new }
11
- let(:config) { Config.new }
12
- let(:rspec_version) { Transpec.required_rspec_version }
13
-
14
- before do
15
- converter.stub(:rspec_version).and_return(rspec_version)
16
- end
17
-
18
- describe '#convert_file!' do
19
- include_context 'isolated environment'
20
-
21
- let(:file_path) { 'sample_spec.rb' }
22
-
23
- before do
24
- File.write(file_path, 'This is a spec')
25
- File.utime(0, 0, file_path)
26
- converter.stub(:rewrite).and_return('This is the converted spec')
27
- end
28
-
29
- context 'when a file path is passed' do
30
- it 'overwrites the file' do
31
- converter.convert_file!(file_path)
32
- File.read(file_path).should == 'This is the converted spec'
33
- end
34
- end
35
-
36
- context 'when a processed source is passed' do
37
- let(:processed_source) { ProcessedSource.from_file(file_path) }
38
-
39
- it 'overwrites the file that the processed source was derived from' do
40
- converter.convert_file!(processed_source)
41
- File.read(file_path).should == 'This is the converted spec'
42
- end
43
- end
44
-
45
- context 'when the source is not needed to be converted' do
46
- before do
47
- converter.stub(:rewrite).and_return('This is a spec')
48
- end
49
-
50
- it 'does not touch the file' do
51
- converter.convert_file!(file_path)
52
- File.mtime(file_path).should == Time.at(0)
53
- end
54
- end
55
- end
56
-
57
- describe '#convert_source' do
58
- subject { converter.convert_source(source) }
59
-
60
- let(:source) do
61
- <<-END
62
- describe 'example group' do
63
- it 'is an example' do
64
- something.should == 'foo'
65
- something.should_receive(:message)
66
- end
67
- end
68
- END
69
- end
70
-
71
- it 'dispatches conversion target standalone syntax objects to each handler method' do
72
- converter.should_receive(:process_should).with(an_instance_of(Syntax::Should))
73
- converter.should_receive(:process_should_receive).with(an_instance_of(Syntax::ShouldReceive))
74
- converter.should_not_receive(:process_stub)
75
- converter.convert_source(source)
76
- end
77
-
78
- it 'dispatches conversion target non-standalone syntax objects to each handler method' do
79
- converter.should_receive(:process_operator).with(an_instance_of(Syntax::Operator))
80
- converter.should_not_receive(:process_have)
81
- converter.should_not_receive(:process_raise_error)
82
- converter.convert_source(source)
83
- end
84
-
85
- context 'when the source is invalid' do
86
- let(:source) { '<' }
87
-
88
- it 'raises Parser::SyntaxError' do
89
- -> { converter.convert_source(source) }.should raise_error(Parser::SyntaxError)
90
- end
91
- end
92
-
93
- context 'when the source has overlapped conversion targets' do
94
- let(:source) do
95
- <<-END
96
- describe 'example group' do
97
- it 'is an example' do
98
- object.stub(:message => mock('something'))
99
- end
100
- end
101
- END
102
- end
103
-
104
- let(:expected_source) do
105
- <<-END
106
- describe 'example group' do
107
- it 'is an example' do
108
- allow(object).to receive(:message).and_return(double('something'))
109
- end
110
- end
111
- END
112
- end
113
-
114
- before do
115
- config.convert_stub_with_hash_to_allow_to_receive_and_return = true
116
- end
117
-
118
- it 'converts all targets properly' do
119
- should == expected_source
120
- end
121
-
122
- it 'adds records for only completed conversions' do
123
- converter.convert_source(source)
124
- converter.report.records.count.should == 2
125
- end
126
- end
127
-
128
- context 'when the source has a monkey-patched expectation outside of example group context' do
129
- before do
130
- config.convert_should = true
131
- converter.stub(:warn)
132
- end
133
-
134
- let(:source) do
135
- <<-END
136
- describe 'example group' do
137
- class Klass
138
- def some_method
139
- 1.should == 1
140
- end
141
- end
142
-
143
- it 'is an example' do
144
- Klass.new.some_method
145
- end
146
- end
147
- END
148
- end
149
-
150
- it 'does not convert the expectation to non-monkey-patch syntax' do
151
- should == source
152
- end
153
-
154
- it 'adds the conversion error to the report' do
155
- converter.convert_source(source)
156
- converter.report.should have(1).conversion_error
157
- end
158
- end
159
- end
160
-
161
- describe '#process_should' do
162
- let(:should_object) { double('should_object', raise_error_matcher: raise_error_object).as_null_object }
163
- let(:raise_error_object) { double('raise_error_object').as_null_object }
164
-
165
- context 'when Config#convert_should? is true' do
166
- before { config.convert_should = true }
167
-
168
- context 'and Config#negative_form_of_to is "not_to"' do
169
- before { config.negative_form_of_to = 'not_to' }
170
-
171
- it 'invokes Should#expectize! with "not_to"' do
172
- should_object.should_receive(:expectize!).with('not_to')
173
- converter.process_should(should_object)
174
- end
175
- end
176
-
177
- context 'and Config#negative_form_of_to is "to_not"' do
178
- before { config.negative_form_of_to = 'to_not' }
179
-
180
- it 'invokes Should#expectize! with "to_not"' do
181
- should_object.should_receive(:expectize!).with('to_not')
182
- converter.process_should(should_object)
183
- end
184
- end
185
- end
186
-
187
- context 'when Config#convert_should? is false' do
188
- before { config.convert_should = false }
189
-
190
- it 'does not invoke Should#expectize!' do
191
- should_object.should_not_receive(:expectize!)
192
- converter.process_should(should_object)
193
- end
194
- end
195
- end
196
-
197
- describe '#process_oneliner_should' do
198
- let(:should_object) do
199
- double(
200
- 'oneliner_should_object',
201
- raise_error_matcher: raise_error_object,
202
- have_matcher: have_object
203
- ).as_null_object
204
- end
205
-
206
- let(:raise_error_object) { double('raise_error_object').as_null_object }
207
- let(:have_object) { double('have_object').as_null_object }
208
-
209
- shared_examples 'does nothing' do
210
- it 'does nothing' do
211
- should_object.should_not_receive(:expectize!)
212
- should_object.should_not_receive(:convert_have_items_to_standard_should!)
213
- should_object.should_not_receive(:convert_have_items_to_standard_expect!)
214
- converter.process_oneliner_should(should_object)
215
- end
216
- end
217
-
218
- shared_examples 'invokes OnelinerShould#expectize! if available' do
219
- context 'and RSpecVersion#oneliner_is_expected_available? returns true' do
220
- before { rspec_version.stub(:oneliner_is_expected_available?).and_return(true) }
221
-
222
- it 'invokes OnelinerShould#expectize!' do
223
- should_object.should_receive(:expectize!)
224
- converter.process_oneliner_should(should_object)
225
- end
226
- end
227
-
228
- context 'and RSpecVersion#oneliner_is_expected_available? returns false' do
229
- before { rspec_version.stub(:oneliner_is_expected_available?).and_return(false) }
230
- include_examples 'does nothing'
231
- end
232
- end
233
-
234
- shared_examples 'converts to standard expecatations' do
235
- context 'and Config#convert_should? is true' do
236
- before { config.convert_should = true }
237
-
238
- it 'invokes OnelinerShould#convert_have_items_to_standard_expect!' do
239
- should_object.should_receive(:convert_have_items_to_standard_expect!)
240
- converter.process_oneliner_should(should_object)
241
- end
242
- end
243
-
244
- context 'and Config#convert_should? is false' do
245
- before { config.convert_should = false }
246
-
247
- it 'invokes OnelinerShould#convert_have_items_to_standard_should!' do
248
- should_object.should_receive(:convert_have_items_to_standard_should!)
249
- converter.process_oneliner_should(should_object)
250
- end
251
- end
252
- end
253
-
254
- context 'when Config#convert_oneliner? is true' do
255
- before { config.convert_oneliner = true }
256
-
257
- context 'and the #have matcher is conversion target' do
258
- before do
259
- have_object.stub(:conversion_target?).and_return(true)
260
- end
261
-
262
- context 'and Config#convert_have_items? is true' do
263
- before { config.convert_have_items = true }
264
- include_examples 'converts to standard expecatations'
265
- end
266
-
267
- context 'and Config#convert_have_items? is false' do
268
- before { config.convert_have_items = false }
269
- include_examples 'invokes OnelinerShould#expectize! if available'
270
- end
271
- end
272
-
273
- context 'and the #have matcher is not conversion target' do
274
- before do
275
- have_object.stub(:conversion_target?).and_return(false)
276
- end
277
-
278
- context 'and Config#convert_have_items? is true' do
279
- before { config.convert_have_items = true }
280
- include_examples 'invokes OnelinerShould#expectize! if available'
281
- end
282
-
283
- context 'and Config#convert_have_items? is false' do
284
- before { config.convert_have_items = false }
285
- include_examples 'invokes OnelinerShould#expectize! if available'
286
- end
287
- end
288
- end
289
-
290
- context 'when Config#convert_oneliner? is false' do
291
- before { config.convert_oneliner = false }
292
-
293
- context 'and the #have matcher is conversion target' do
294
- before do
295
- have_object.stub(:conversion_target?).and_return(true)
296
- end
297
-
298
- context 'and Config#convert_have_items? is true' do
299
- before { config.convert_have_items = true }
300
- include_examples 'converts to standard expecatations'
301
- end
302
-
303
- context 'and Config#convert_have_items? is false' do
304
- before { config.convert_have_items = false }
305
- include_examples 'does nothing'
306
- end
307
- end
308
-
309
- context 'and the #have matcher is not conversion target' do
310
- before do
311
- have_object.stub(:conversion_target?).and_return(false)
312
- end
313
-
314
- context 'and Config#convert_have_items? is true' do
315
- before { config.convert_have_items = true }
316
- include_examples 'does nothing'
317
- end
318
-
319
- context 'and Config#convert_have_items? is false' do
320
- before { config.convert_have_items = false }
321
- include_examples 'does nothing'
322
- end
323
- end
324
- end
325
- end
326
-
327
- describe '#process_should_receive' do
328
- let(:should_receive_object) { double('should_receive_object').as_null_object }
329
-
330
- shared_examples 'does nothing' do
331
- it 'does nothing' do
332
- should_receive_object.should_not_receive(:expectize!)
333
- should_receive_object.should_not_receive(:allowize_any_number_of_times!)
334
- should_receive_object.should_not_receive(:stubize_any_number_of_times!)
335
- converter.process_should_receive(should_receive_object)
336
- end
337
- end
338
-
339
- context 'when ShouldReceive#useless_expectation? returns true' do
340
- before { should_receive_object.stub(:useless_expectation?).and_return(true) }
341
-
342
- context 'and Config#convert_deprecated_method? is true' do
343
- before { config.convert_deprecated_method = true }
344
-
345
- context 'and Config#convert_stub? is true' do
346
- before { config.convert_stub = true }
347
-
348
- [true, false].each do |convert_should_receive|
349
- context "and Config#convert_should_receive? is #{convert_should_receive}" do
350
- before { config.convert_should_receive = convert_should_receive }
351
-
352
- context 'and Config#negative_form_of_to is "not_to"' do
353
- before { config.negative_form_of_to = 'not_to' }
354
-
355
- it 'invokes ShouldReceive#allowize_useless_expectation! with "not_to"' do
356
- should_receive_object.should_receive(:allowize_useless_expectation!).with('not_to')
357
- converter.process_should_receive(should_receive_object)
358
- end
359
- end
360
-
361
- context 'and Config#negative_form_of_to is "to_not"' do
362
- before { config.negative_form_of_to = 'to_not' }
363
-
364
- it 'invokes ShouldReceive#allowize_useless_expectation! with "to_not"' do
365
- should_receive_object.should_receive(:allowize_useless_expectation!).with('to_not')
366
- converter.process_should_receive(should_receive_object)
367
- end
368
- end
369
- end
370
- end
371
- end
372
-
373
- context 'and Config#convert_stub? is false' do
374
- before { config.convert_stub = false }
375
-
376
- [true, false].each do |convert_should_receive|
377
- context "and Config#convert_should_receive? is #{convert_should_receive}" do
378
- before { config.convert_should_receive = convert_should_receive }
379
-
380
- it 'invokes ShouldReceive#stubize_useless_expectation!' do
381
- should_receive_object.should_receive(:stubize_useless_expectation!)
382
- converter.process_should_receive(should_receive_object)
383
- end
384
- end
385
- end
386
- end
387
- end
388
-
389
- context 'and Config#convert_deprecated_method? is false' do
390
- before { config.convert_deprecated_method = false }
391
-
392
- [true, false].each do |convert_stub|
393
- context "and Config#convert_stub? is #{convert_stub}" do
394
- before { config.convert_stub = convert_stub }
395
-
396
- context 'and Config#convert_should_receive? is true' do
397
- before { config.convert_should_receive = true }
398
-
399
- context 'and Config#negative_form_of_to is "not_to"' do
400
- before { config.negative_form_of_to = 'not_to' }
401
-
402
- it 'invokes ShouldReceive#expectize! with "not_to"' do
403
- should_receive_object.should_receive(:expectize!).with('not_to')
404
- converter.process_should_receive(should_receive_object)
405
- end
406
- end
407
-
408
- context 'and Config#negative_form_of_to is "to_not"' do
409
- before { config.negative_form_of_to = 'to_not' }
410
-
411
- it 'invokes ShouldReceive#expectize! with "to_not"' do
412
- should_receive_object.should_receive(:expectize!).with('to_not')
413
- converter.process_should_receive(should_receive_object)
414
- end
415
- end
416
- end
417
-
418
- context 'and Config#convert_should_receive? is false' do
419
- before { config.convert_should_receive = false }
420
-
421
- include_examples 'does nothing'
422
- end
423
- end
424
- end
425
- end
426
- end
427
-
428
- context 'when ShouldReceive#useless_expectation? returns false' do
429
- before { should_receive_object.stub(:useless_expectation?).and_return(false) }
430
-
431
- context 'and Config#convert_should_receive? is true' do
432
- before { config.convert_should_receive = true }
433
-
434
- [true, false].each do |convert_deprecated_method|
435
- context "and Config#convert_deprecated_method? is #{convert_deprecated_method}" do
436
- before { config.convert_deprecated_method = convert_deprecated_method }
437
-
438
- [true, false].each do |convert_stub|
439
- context "and Config#convert_stub? is #{convert_stub}" do
440
- before { config.convert_stub = convert_stub }
441
-
442
- context 'and Config#negative_form_of_to is "not_to"' do
443
- before { config.negative_form_of_to = 'not_to' }
444
-
445
- it 'invokes ShouldReceive#expectize! with "not_to"' do
446
- should_receive_object.should_receive(:expectize!).with('not_to')
447
- converter.process_should_receive(should_receive_object)
448
- end
449
- end
450
-
451
- context 'and Config#negative_form_of_to is "to_not"' do
452
- before { config.negative_form_of_to = 'to_not' }
453
-
454
- it 'invokes ShouldReceive#expectize! with "to_not"' do
455
- should_receive_object.should_receive(:expectize!).with('to_not')
456
- converter.process_should_receive(should_receive_object)
457
- end
458
- end
459
- end
460
- end
461
- end
462
- end
463
- end
464
-
465
- context 'and Config#convert_should_receive? is false' do
466
- before { config.convert_should_receive = false }
467
-
468
- [true, false].each do |convert_deprecated_method|
469
- context "and Config#convert_deprecated_method? is #{convert_deprecated_method}" do
470
- before { config.convert_deprecated_method = convert_deprecated_method }
471
-
472
- [true, false].each do |convert_stub|
473
- context "and Config#convert_stub? is #{convert_stub}" do
474
- before { config.convert_stub = convert_stub }
475
-
476
- include_examples 'does nothing'
477
- end
478
- end
479
- end
480
- end
481
- end
482
- end
483
- end
484
-
485
- describe '#process_method_stub' do
486
- let(:method_stub_object) { double('method_stub_object').as_null_object }
487
-
488
- shared_examples 'invokes MethodStub#allowize!' do
489
- it 'invokes MethodStub#allowize!' do
490
- method_stub_object.should_receive(:allowize!)
491
- converter.process_method_stub(method_stub_object)
492
- end
493
- end
494
-
495
- shared_examples 'does not invoke MethodStub#allowize!' do
496
- it 'does not invoke MethodStub#allowize!' do
497
- method_stub_object.should_not_receive(:allowize!)
498
- converter.process_method_stub(method_stub_object)
499
- end
500
- end
501
-
502
- shared_examples 'invokes MethodStub#convert_deprecated_method!' do
503
- it 'invokes MethodStub#convert_deprecated_method!' do
504
- method_stub_object.should_receive(:convert_deprecated_method!)
505
- converter.process_method_stub(method_stub_object)
506
- end
507
- end
508
-
509
- shared_examples 'does not invoke MethodStub#convert_deprecated_method!' do
510
- it 'does not invoke MethodStub#convert_deprecated_method!' do
511
- method_stub_object.should_not_receive(:convert_deprecated_method!)
512
- converter.process_method_stub(method_stub_object)
513
- end
514
- end
515
-
516
- shared_examples 'invokes MethodStub#remove_no_message_allowance!' do
517
- it 'invokes MethodStub#remove_no_message_allowance!' do
518
- method_stub_object.should_receive(:remove_no_message_allowance!)
519
- converter.process_method_stub(method_stub_object)
520
- end
521
- end
522
-
523
- shared_examples 'does not invoke MethodStub#remove_no_message_allowance!' do
524
- it 'does not invoke MethodStub#remove_no_message_allowance!' do
525
- method_stub_object.should_not_receive(:remove_no_message_allowance!)
526
- converter.process_method_stub(method_stub_object)
527
- end
528
- end
529
-
530
- context 'when Config#convert_stub? is true' do
531
- before { config.convert_stub = true }
532
-
533
- context 'and Config#convert_deprecated_method? is true' do
534
- before { config.convert_deprecated_method = true }
535
-
536
- context 'and MethodStub#hash_arg? is false' do
537
- before { method_stub_object.stub(:hash_arg?).and_return(false) }
538
- include_examples 'invokes MethodStub#allowize!'
539
- include_examples 'does not invoke MethodStub#convert_deprecated_method!'
540
- include_examples 'invokes MethodStub#remove_no_message_allowance!'
541
- end
542
-
543
- context 'and MethodStub#hash_arg? is true' do
544
- before { method_stub_object.stub(:hash_arg?).and_return(true) }
545
-
546
- context 'and Config#convert_stub_with_hash_to_allow_to_receive_and_return? is true' do
547
- before { config.convert_stub_with_hash_to_allow_to_receive_and_return = true }
548
-
549
- context 'and RSpecVersion#receive_messages_available? is true' do
550
- before { rspec_version.stub(:receive_messages_available?).and_return(true) }
551
- include_examples 'invokes MethodStub#allowize!'
552
- include_examples 'does not invoke MethodStub#convert_deprecated_method!'
553
- include_examples 'invokes MethodStub#remove_no_message_allowance!'
554
- end
555
-
556
- context 'and RSpecVersion#receive_messages_available? is false' do
557
- before { rspec_version.stub(:receive_messages_available?).and_return(false) }
558
- include_examples 'invokes MethodStub#allowize!'
559
- include_examples 'does not invoke MethodStub#convert_deprecated_method!'
560
- include_examples 'invokes MethodStub#remove_no_message_allowance!'
561
- end
562
- end
563
-
564
- context 'and Config#convert_stub_with_hash_to_allow_to_receive_and_return? is false' do
565
- before { config.convert_stub_with_hash_to_allow_to_receive_and_return = false }
566
-
567
- context 'and RSpecVersion#receive_messages_available? is true' do
568
- before { rspec_version.stub(:receive_messages_available?).and_return(true) }
569
- include_examples 'invokes MethodStub#allowize!'
570
- include_examples 'does not invoke MethodStub#convert_deprecated_method!'
571
- include_examples 'invokes MethodStub#remove_no_message_allowance!'
572
- end
573
-
574
- context 'and RSpecVersion#receive_messages_available? is false' do
575
- before { rspec_version.stub(:receive_messages_available?).and_return(false) }
576
- include_examples 'does not invoke MethodStub#allowize!'
577
- include_examples 'invokes MethodStub#convert_deprecated_method!'
578
- include_examples 'invokes MethodStub#remove_no_message_allowance!'
579
- end
580
- end
581
- end
582
- end
583
-
584
- context 'and Config#convert_deprecated_method? is false' do
585
- before do
586
- config.convert_deprecated_method = false
587
- method_stub_object.stub(:hash_arg?).and_return(false)
588
- end
589
-
590
- include_examples 'invokes MethodStub#allowize!'
591
- include_examples 'does not invoke MethodStub#convert_deprecated_method!'
592
- include_examples 'does not invoke MethodStub#remove_no_message_allowance!'
593
- end
594
- end
595
-
596
- context 'when Config#convert_stub? is false' do
597
- before { config.convert_stub = false }
598
-
599
- context 'and Config#convert_deprecated_method? is true' do
600
- before { config.convert_deprecated_method = true }
601
-
602
- include_examples 'does not invoke MethodStub#allowize!'
603
- include_examples 'invokes MethodStub#convert_deprecated_method!'
604
- include_examples 'invokes MethodStub#remove_no_message_allowance!'
605
- end
606
-
607
- context 'and Config#convert_deprecated_method? is false' do
608
- before { config.convert_deprecated_method = false }
609
-
610
- include_examples 'does not invoke MethodStub#allowize!'
611
- include_examples 'does not invoke MethodStub#convert_deprecated_method!'
612
- include_examples 'does not invoke MethodStub#remove_no_message_allowance!'
613
- end
614
- end
615
- end
616
-
617
- describe '#process_double' do
618
- let(:double_object) { double('double_object').as_null_object }
619
-
620
- context 'when Config#convert_deprecated_method? is true' do
621
- before { config.convert_deprecated_method = true }
622
-
623
- it 'invokes Double#convert_to_double!' do
624
- double_object.should_receive(:convert_to_double!)
625
- converter.process_double(double_object)
626
- end
627
- end
628
-
629
- context 'when Config#convert_deprecated_method? is false' do
630
- before { config.convert_deprecated_method = false }
631
-
632
- it 'does nothing' do
633
- double_object.should_not_receive(:convert_to_double!)
634
- converter.process_double(double_object)
635
- end
636
- end
637
- end
638
-
639
- describe '#process_operator' do
640
- let(:operator_object) { double('operator_object').as_null_object }
641
-
642
- context 'when Config#convert_should? is true' do
643
- before { config.convert_should = true }
644
-
645
- context 'and Config#parenthesize_matcher_arg is true' do
646
- before { config.parenthesize_matcher_arg = true }
647
-
648
- it 'invokes Operator#convert_operator! with true' do
649
- operator_object.should_receive(:convert_operator!).with(true)
650
- converter.process_operator(operator_object)
651
- end
652
- end
653
-
654
- context 'and Config#parenthesize_matcher_arg is false' do
655
- before { config.parenthesize_matcher_arg = false }
656
-
657
- it 'invokes Should#expectize! with false as second argument' do
658
- operator_object.should_receive(:convert_operator!).with(false)
659
- converter.process_operator(operator_object)
660
- end
661
- end
662
-
663
- context 'and the expectation is one-liner should' do
664
- before do
665
- operator_object.stub(:expectation).and_return(Syntax::OnelinerShould.new(nil))
666
- end
667
-
668
- context 'and RSpecVersion#oneliner_is_expected_available? returns true' do
669
- before { rspec_version.stub(:oneliner_is_expected_available?).and_return(true) }
670
-
671
- it 'invokes Operator#convert_operator!' do
672
- operator_object.should_receive(:convert_operator!)
673
- converter.process_operator(operator_object)
674
- end
675
- end
676
-
677
- context 'and RSpecVersion#oneliner_is_expected_available? returns false' do
678
- before { rspec_version.stub(:oneliner_is_expected_available?).and_return(false) }
679
-
680
- it 'does not invoke Operator#convert_operator!' do
681
- operator_object.should_not_receive(:convert_operator!)
682
- converter.process_operator(operator_object)
683
- end
684
- end
685
- end
686
- end
687
-
688
- context 'when Config#convert_should? is false' do
689
- before { config.convert_should = false }
690
-
691
- it 'does not invoke Operator#convert_operator!' do
692
- operator_object.should_not_receive(:convert_operator!)
693
- converter.process_operator(operator_object)
694
- end
695
- end
696
- end
697
-
698
- describe '#process_be_boolean' do
699
- let(:be_boolean_object) { double('be_boolean_object').as_null_object }
700
-
701
- context 'when RSpecVersion#be_truthy_available? returns true' do
702
- before { rspec_version.stub(:be_truthy_available?).and_return(true) }
703
-
704
- context 'and Config#convert_deprecated_method? is true' do
705
- before { config.convert_deprecated_method = true }
706
-
707
- context 'and Config#boolean_matcher_type is :conditional' do
708
- before { config.boolean_matcher_type = :conditional }
709
-
710
- context 'and Config#form_of_be_falsey is "be_falsey"' do
711
- before { config.form_of_be_falsey = 'be_falsey' }
712
-
713
- it 'invokes BeBoolean#convert_to_conditional_matcher! with "be_falsey"' do
714
- be_boolean_object.should_receive(:convert_to_conditional_matcher!).with('be_falsey')
715
- converter.process_be_boolean(be_boolean_object)
716
- end
717
- end
718
-
719
- context 'and Config#form_of_be_falsey is "be_falsy"' do
720
- before { config.form_of_be_falsey = 'be_falsy' }
721
-
722
- it 'invokes BeBoolean#convert_to_conditional_matcher! with "be_falsy"' do
723
- be_boolean_object.should_receive(:convert_to_conditional_matcher!).with('be_falsy')
724
- converter.process_be_boolean(be_boolean_object)
725
- end
726
- end
727
- end
728
-
729
- context 'and Config#boolean_matcher_type is :exact' do
730
- before { config.boolean_matcher_type = :exact }
731
-
732
- it 'invokes BeBoolean#convert_to_exact_matcher!' do
733
- be_boolean_object.should_receive(:convert_to_exact_matcher!)
734
- converter.process_be_boolean(be_boolean_object)
735
- end
736
- end
737
- end
738
-
739
- context 'and Config#convert_deprecated_method? is false' do
740
- before { config.convert_deprecated_method = false }
741
-
742
- it 'does nothing' do
743
- be_boolean_object.should_not_receive(:convert_to_conditional_matcher!)
744
- be_boolean_object.should_not_receive(:convert_to_exact_matcher!)
745
- converter.process_be_boolean(be_boolean_object)
746
- end
747
- end
748
- end
749
-
750
- context 'when RSpecVersion#be_truthy_available? returns true' do
751
- before { rspec_version.stub(:be_truthy_available?).and_return(false) }
752
-
753
- it 'does nothing' do
754
- be_boolean_object.should_not_receive(:convert_to_conditional_matcher!)
755
- be_boolean_object.should_not_receive(:convert_to_exact_matcher!)
756
- converter.process_be_boolean(be_boolean_object)
757
- end
758
- end
759
- end
760
-
761
- describe '#process_be_close' do
762
- let(:be_close_object) { double('be_close_object').as_null_object }
763
-
764
- context 'when Config#convert_deprecated_method? is true' do
765
- before { config.convert_deprecated_method = true }
766
-
767
- it 'invokes BeClose#convert_to_be_within!' do
768
- be_close_object.should_receive(:convert_to_be_within!)
769
- converter.process_be_close(be_close_object)
770
- end
771
- end
772
-
773
- context 'when Config#convert_deprecated_method? is false' do
774
- before { config.convert_deprecated_method = false }
775
-
776
- it 'does nothing' do
777
- be_close_object.should_not_receive(:convert_to_be_within!)
778
- converter.process_be_close(be_close_object)
779
- end
780
- end
781
- end
782
-
783
- describe '#process_have' do
784
- let(:have_object) { double('have_object').as_null_object }
785
-
786
- context 'when Config#convert_have_items? is true' do
787
- before { config.convert_have_items = true }
788
-
789
- context 'and Config#parenthesize_matcher_arg is true' do
790
- before { config.parenthesize_matcher_arg = true }
791
-
792
- it 'invokes Have#convert_to_standard_expectation! with true' do
793
- have_object.should_receive(:convert_to_standard_expectation!).with(true)
794
- converter.process_have(have_object)
795
- end
796
- end
797
-
798
- context 'and Config#parenthesize_matcher_arg is false' do
799
- before { config.parenthesize_matcher_arg = false }
800
-
801
- it 'invokes Have#convert_to_standard_expectation! with false' do
802
- have_object.should_receive(:convert_to_standard_expectation!).with(false)
803
- converter.process_have(have_object)
804
- end
805
- end
806
- end
807
-
808
- context 'when Config#convert_have_items? is false' do
809
- before { config.convert_have_items = false }
810
-
811
- it 'does not invoke Have#convert_to_standard_expectation!' do
812
- have_object.should_not_receive(:convert_to_standard_expectation!)
813
- converter.process_have(have_object)
814
- end
815
- end
816
- end
817
-
818
- describe '#process_hook' do
819
- let(:hook_object) { double('hook_object').as_null_object }
820
-
821
- context 'when Config#convert_hook_scope? is true' do
822
- before { config.convert_hook_scope = true }
823
-
824
- context 'when RSpecVersion#hook_scope_alias_available? returns true' do
825
- before { rspec_version.stub(:hook_scope_alias_available?).and_return(true) }
826
-
827
- it 'invokes Hook#convert_scope_name!' do
828
- hook_object.should_receive(:convert_scope_name!)
829
- converter.process_hook(hook_object)
830
- end
831
- end
832
-
833
- context 'when RSpecVersion#hook_scope_alias_available? returns false' do
834
- before { rspec_version.stub(:hook_scope_alias_available?).and_return(false) }
835
-
836
- it 'does nothing' do
837
- hook_object.should_not_receive(:convert_scope_name!)
838
- converter.process_hook(hook_object)
839
- end
840
- end
841
- end
842
-
843
- context 'when Config#convert_hook_scope? is false' do
844
- before { config.convert_hook_scope = false }
845
-
846
- context 'when RSpecVersion#hook_scope_alias_available? returns true' do
847
- before { rspec_version.stub(:hook_scope_alias_available?).and_return(true) }
848
-
849
- it 'does nothing' do
850
- hook_object.should_not_receive(:convert_scope_name!)
851
- converter.process_hook(hook_object)
852
- end
853
- end
854
- end
855
- end
856
-
857
- describe '#process_raise_error' do
858
- let(:raise_error_object) { double('raise_error_object').as_null_object }
859
-
860
- context 'when Config#convert_deprecated_method? is true' do
861
- before { config.convert_deprecated_method = true }
862
-
863
- it 'invokes RaiseError#remove_error_specification_with_negative_expectation!' do
864
- raise_error_object.should_receive(:remove_error_specification_with_negative_expectation!)
865
- converter.process_raise_error(raise_error_object)
866
- end
867
- end
868
-
869
- context 'when Config#convert_deprecated_method? is false' do
870
- before { config.convert_deprecated_method = false }
871
-
872
- it 'does nothing' do
873
- raise_error_object.should_not_receive(:remove_error_specification_with_negative_expectation!)
874
- converter.process_raise_error(raise_error_object)
875
- end
876
- end
877
- end
878
-
879
- describe '#process_its' do
880
- let(:its_object) { double('its_object').as_null_object }
881
-
882
- context 'when Config#convert_its? is true' do
883
- before { config.convert_its = true }
884
-
885
- it 'invokes Its#convert_to_describe_subject_it!' do
886
- its_object.should_receive(:convert_to_describe_subject_it!)
887
- converter.process_its(its_object)
888
- end
889
- end
890
-
891
- context 'when Config#convert_its? is false' do
892
- before { config.convert_its = false }
893
-
894
- it 'does nothing' do
895
- its_object.should_not_receive(:convert_to_describe_subject_it!)
896
- converter.process_its(its_object)
897
- end
898
- end
899
- end
900
-
901
- describe '#process_example' do
902
- let(:example_object) { double('example_object').as_null_object }
903
-
904
- shared_examples 'does nothing' do
905
- it 'does nothing' do
906
- example_object.should_not_receive(:convert_pending_to_skip!)
907
- converter.process_example(example_object)
908
- end
909
- end
910
-
911
- context 'when RSpecVersion#rspec_2_99? returns true' do
912
- before { rspec_version.stub(:rspec_2_99?).and_return(true) }
913
-
914
- context 'and Config#convert_pending? returns true' do
915
- before { config.convert_pending = true }
916
-
917
- it 'invokes Example#convert_pending_to_skip!' do
918
- example_object.should_receive(:convert_pending_to_skip!)
919
- converter.process_example(example_object)
920
- end
921
- end
922
-
923
- context 'and Config#convert_pending? returns false' do
924
- before { config.convert_pending = false }
925
- include_examples 'does nothing'
926
- end
927
- end
928
-
929
- context 'when RSpecVersion#rspec_2_99? returns false' do
930
- before { rspec_version.stub(:rspec_2_99?).and_return(false) }
931
-
932
- context 'and Config#convert_pending? returns true' do
933
- before { config.convert_pending = true }
934
- include_examples 'does nothing'
935
- end
936
-
937
- context 'and Config#convert_pending? returns false' do
938
- before { config.convert_pending = false }
939
- include_examples 'does nothing'
940
- end
941
- end
942
- end
943
-
944
- describe '#process_pending' do
945
- let(:pending_object) { double('pending_object').as_null_object }
946
-
947
- shared_examples 'does nothing' do
948
- it 'does nothing' do
949
- pending_object.should_not_receive(:convert_deprecated_syntax!)
950
- converter.process_pending(pending_object)
951
- end
952
- end
953
-
954
- context 'when RSpecVersion#rspec_2_99? returns true' do
955
- before { rspec_version.stub(:rspec_2_99?).and_return(true) }
956
-
957
- context 'and Config#convert_pending? returns true' do
958
- before { config.convert_pending = true }
959
-
960
- it 'invokes Example#convert_deprecated_syntax!' do
961
- pending_object.should_receive(:convert_deprecated_syntax!)
962
- converter.process_pending(pending_object)
963
- end
964
- end
965
-
966
- context 'and Config#convert_pending? returns false' do
967
- before { config.convert_pending = false }
968
- include_examples 'does nothing'
969
- end
970
- end
971
-
972
- context 'when RSpecVersion#rspec_2_99? returns false' do
973
- before { rspec_version.stub(:rspec_2_99?).and_return(false) }
974
-
975
- context 'and Config#convert_pending? returns true' do
976
- before { config.convert_pending = true }
977
- include_examples 'does nothing'
978
- end
979
-
980
- context 'and Config#convert_pending? returns false' do
981
- before { config.convert_pending = false }
982
- include_examples 'does nothing'
983
- end
984
- end
985
- end
986
-
987
- describe '#process_current_example' do
988
- let(:current_example_object) { double('current_example_object').as_null_object }
989
-
990
- context 'when RSpecVersion#yielded_example_available? returns true' do
991
- before { rspec_version.stub(:yielded_example_available?).and_return(true) }
992
-
993
- context 'and Config#convert_deprecated_method? is true' do
994
- before { config.convert_deprecated_method = true }
995
-
996
- it 'invokes CurrentExample#convert!' do
997
- current_example_object.should_receive(:convert!)
998
- converter.process_current_example(current_example_object)
999
- end
1000
- end
1001
-
1002
- context 'and Config#convert_deprecated_method? is false' do
1003
- before { config.convert_deprecated_method = false }
1004
-
1005
- it 'does nothing' do
1006
- current_example_object.should_not_receive(:convert!)
1007
- converter.process_current_example(current_example_object)
1008
- end
1009
- end
1010
- end
1011
-
1012
- context 'when RSpecVersion#yielded_example_available? returns false' do
1013
- before { rspec_version.stub(:yielded_example_available?).and_return(false) }
1014
-
1015
- context 'and Config#convert_deprecated_method? is true' do
1016
- before { config.convert_deprecated_method = true }
1017
-
1018
- it 'does nothing' do
1019
- current_example_object.should_not_receive(:convert!)
1020
- converter.process_current_example(current_example_object)
1021
- end
1022
- end
1023
- end
1024
- end
1025
-
1026
- describe '#process_matcher_definition' do
1027
- let(:matcher_definition) { double('matcher_definition').as_null_object }
1028
-
1029
- context 'when RSpecVersion#non_should_matcher_protocol_available? returns true' do
1030
- before { rspec_version.stub(:non_should_matcher_protocol_available?).and_return(true) }
1031
-
1032
- context 'and Config#convert_deprecated_method? is true' do
1033
- before { config.convert_deprecated_method = true }
1034
-
1035
- it 'invokes MatcherDefinition#convert_deprecated_method!' do
1036
- matcher_definition.should_receive(:convert_deprecated_method!)
1037
- converter.process_matcher_definition(matcher_definition)
1038
- end
1039
- end
1040
-
1041
- context 'and Config#convert_deprecated_method? is false' do
1042
- before { config.convert_deprecated_method = false }
1043
-
1044
- it 'does nothing' do
1045
- matcher_definition.should_not_receive(:convert_deprecated_method!)
1046
- converter.process_matcher_definition(matcher_definition)
1047
- end
1048
- end
1049
- end
1050
-
1051
- context 'when RSpecVersion#non_should_matcher_protocol_available? returns false' do
1052
- before { rspec_version.stub(:non_should_matcher_protocol_available?).and_return(false) }
1053
-
1054
- context 'and Config#convert_deprecated_method? is true' do
1055
- before { config.convert_deprecated_method = true }
1056
-
1057
- it 'does nothing' do
1058
- matcher_definition.should_not_receive(:convert_deprecated_method!)
1059
- converter.process_matcher_definition(matcher_definition)
1060
- end
1061
- end
1062
- end
1063
- end
1064
-
1065
- describe '#process_example_group' do
1066
- let(:example_group) { double('example_group').as_null_object }
1067
-
1068
- context 'when RSpecVersion#non_monkey_patch_example_group_available? returns true' do
1069
- before { rspec_version.stub(:non_monkey_patch_example_group_available?).and_return(true) }
1070
-
1071
- context 'and Config#convert_example_group? is true' do
1072
- before { config.convert_example_group = true }
1073
-
1074
- it 'invokes ExampleGroup#convert_to_non_monkey_patch!' do
1075
- example_group.should_receive(:convert_to_non_monkey_patch!)
1076
- converter.process_example_group(example_group)
1077
- end
1078
- end
1079
-
1080
- context 'and Config#convert_example_group? is false' do
1081
- before { config.convert_example_group = false }
1082
-
1083
- it 'does nothing' do
1084
- example_group.should_not_receive(:convert_to_non_monkey_patch!)
1085
- converter.process_example_group(example_group)
1086
- end
1087
- end
1088
- end
1089
-
1090
- context 'when RSpecVersion#non_monkey_patch_example_group_available? returns false' do
1091
- before { rspec_version.stub(:non_monkey_patch_example_group_available?).and_return(false) }
1092
-
1093
- context 'and Config#convert_example_group? is true' do
1094
- before { config.convert_example_group = true }
1095
-
1096
- it 'does nothing' do
1097
- example_group.should_not_receive(:convert_to_non_monkey_patch!)
1098
- converter.process_example_group(example_group)
1099
- end
1100
- end
1101
- end
1102
-
1103
- context 'when RSpecVersion#implicit_spec_type_disablement_available? returns true' do
1104
- before { rspec_version.stub(:implicit_spec_type_disablement_available?).and_return(true) }
1105
-
1106
- context 'and Config#add_explicit_type_metadata_to_example_group? is true' do
1107
- before { config.add_explicit_type_metadata_to_example_group = true }
1108
-
1109
- it 'invokes ExampleGroup#add_explicit_type_metadata!' do
1110
- example_group.should_receive(:add_explicit_type_metadata!)
1111
- converter.process_example_group(example_group)
1112
- end
1113
- end
1114
-
1115
- context 'and Config#add_explicit_type_metadata_to_example_group? is false' do
1116
- before { config.add_explicit_type_metadata_to_example_group = false }
1117
-
1118
- it 'does nothing' do
1119
- example_group.should_not_receive(:add_explicit_type_metadata!)
1120
- converter.process_example_group(example_group)
1121
- end
1122
- end
1123
- end
1124
-
1125
- context 'when RSpecVersion#implicit_spec_type_disablement_available? returns false' do
1126
- before { rspec_version.stub(:implicit_spec_type_disablement_available?).and_return(false) }
1127
-
1128
- context 'and Config#add_explicit_type_metadata_to_example_group? is true' do
1129
- before { config.add_explicit_type_metadata_to_example_group = true }
1130
-
1131
- it 'does nothing' do
1132
- example_group.should_not_receive(:add_explicit_type_metadata!)
1133
- converter.process_example_group(example_group)
1134
- end
1135
- end
1136
- end
1137
- end
1138
-
1139
- describe '#process_rspec_configure' do
1140
- let(:rspec_configure) do
1141
- double(
1142
- 'rspec_configure',
1143
- expectations: double('expectations').as_null_object,
1144
- mocks: double('mocks').as_null_object
1145
- ).as_null_object
1146
- end
1147
-
1148
- context 'when Config#convert_deprecated_method? returns true' do
1149
- before { config.convert_deprecated_method = true }
1150
-
1151
- it 'invokes RSpecConfigure#convert_deprecated_options!' do
1152
- rspec_configure.should_receive(:convert_deprecated_options!)
1153
- converter.process_rspec_configure(rspec_configure)
1154
- end
1155
- end
1156
-
1157
- context 'when Config#convert_deprecated_method? returns false' do
1158
- before { config.convert_deprecated_method = false }
1159
-
1160
- it 'does not invoke RSpecConfigure#convert_deprecated_options!' do
1161
- rspec_configure.should_not_receive(:convert_deprecated_options!)
1162
- converter.process_rspec_configure(rspec_configure)
1163
- end
1164
- end
1165
-
1166
- context 'when RSpecVersion#rspec_2_99? returns true' do
1167
- before do
1168
- rspec_version.stub(:rspec_2_99?).and_return(true)
1169
- end
1170
-
1171
- context 'and Config#convert_deprecated_method? returns true' do
1172
- before { config.convert_deprecated_method = true }
1173
-
1174
- context 'and SpecSuite#main_rspec_configure_node? returns true' do
1175
- before do
1176
- spec_suite.stub(:main_rspec_configure_node?).and_return(true)
1177
- end
1178
-
1179
- context 'and SpecSuite#need_to_modify_yield_receiver_..._config? return true' do
1180
- before do
1181
- spec_suite.stub(:need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config?)
1182
- .and_return(true)
1183
- end
1184
-
1185
- context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns true' do
1186
- before { config.add_receiver_arg_to_any_instance_implementation_block = true }
1187
-
1188
- it 'invokes RSpecConfigure.mocks.yield_receiver_to_any_instance_implementation_blocks= with true' do
1189
- rspec_configure.mocks
1190
- .should_receive(:yield_receiver_to_any_instance_implementation_blocks=).with(true)
1191
- converter.process_rspec_configure(rspec_configure)
1192
- end
1193
- end
1194
-
1195
- context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns false' do
1196
- before { config.add_receiver_arg_to_any_instance_implementation_block = false }
1197
-
1198
- it 'invokes RSpecConfigure.mocks.yield_receiver_to_any_instance_implementation_blocks= with false' do
1199
- rspec_configure.mocks
1200
- .should_receive(:yield_receiver_to_any_instance_implementation_blocks=).with(false)
1201
- converter.process_rspec_configure(rspec_configure)
1202
- end
1203
- end
1204
- end
1205
- end
1206
-
1207
- context 'and SpecSuite#need_to_modify_yield_receiver_..._config? return false' do
1208
- before do
1209
- spec_suite.stub(:need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config?)
1210
- .and_return(false)
1211
- end
1212
-
1213
- context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns true' do
1214
- before { config.add_receiver_arg_to_any_instance_implementation_block = true }
1215
-
1216
- it 'does not invoke RSpecConfigure.mocks.yield_receiver_to_any_instance_implementation_blocks=' do
1217
- rspec_configure.mocks.should_not_receive(:yield_receiver_to_any_instance_implementation_blocks=)
1218
- converter.process_rspec_configure(rspec_configure)
1219
- end
1220
- end
1221
- end
1222
-
1223
- context 'and SpecSuite#main_rspec_configure_node? returns false' do
1224
- before do
1225
- spec_suite.stub(:main_rspec_configure_node?).and_return(false)
1226
- end
1227
-
1228
- context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns true' do
1229
- before { config.add_receiver_arg_to_any_instance_implementation_block = true }
1230
-
1231
- it 'does not invoke RSpecConfigure.mocks.yield_receiver_to_any_instance_implementation_blocks=' do
1232
- rspec_configure.mocks.should_not_receive(:yield_receiver_to_any_instance_implementation_blocks=)
1233
- converter.process_rspec_configure(rspec_configure)
1234
- end
1235
- end
1236
- end
1237
- end
1238
-
1239
- context 'and Config#convert_deprecated_method? returns false' do
1240
- before { config.convert_deprecated_method = false }
1241
-
1242
- it 'does not invoke RSpecConfigure.mocks.yield_receiver_to_any_instance_implementation_blocks=' do
1243
- rspec_configure.mocks.should_not_receive(:yield_receiver_to_any_instance_implementation_blocks=)
1244
- converter.process_rspec_configure(rspec_configure)
1245
- end
1246
- end
1247
- end
1248
-
1249
- context 'when RSpecVersion#rspec_2_99? returns false' do
1250
- before do
1251
- rspec_version.stub(:rspec_2_99?).and_return(false)
1252
- end
1253
-
1254
- it 'does not invoke RSpecConfigure.mocks.yield_receiver_to_any_instance_implementation_blocks=' do
1255
- rspec_configure.mocks.should_not_receive(:yield_receiver_to_any_instance_implementation_blocks=)
1256
- converter.process_rspec_configure(rspec_configure)
1257
- end
1258
- end
1259
-
1260
- context 'when RSpecVersion#non_monkey_patch_example_group_available? returns true' do
1261
- before { rspec_version.stub(:non_monkey_patch_example_group_available?).and_return(true) }
1262
-
1263
- context 'and Config#convert_example_group? is true' do
1264
- before { config.convert_example_group = true }
1265
-
1266
- it 'invokes RSpecConfigure#expose_dsl_globally= with false' do
1267
- rspec_configure.should_receive(:expose_dsl_globally=).with(false)
1268
- converter.process_rspec_configure(rspec_configure)
1269
- end
1270
- end
1271
-
1272
- context 'and Config#convert_example_group? is false' do
1273
- before { config.convert_example_group = false }
1274
-
1275
- it 'does nothing' do
1276
- rspec_configure.should_not_receive(:expose_dsl_globally=)
1277
- converter.process_rspec_configure(rspec_configure)
1278
- end
1279
- end
1280
- end
1281
-
1282
- context 'when RSpecVersion#non_monkey_patch_example_group_available? returns false' do
1283
- before { rspec_version.stub(:non_monkey_patch_example_group_available?).and_return(false) }
1284
-
1285
- context 'and Config#convert_example_group? is true' do
1286
- before { config.convert_example_group = true }
1287
-
1288
- it 'does nothing' do
1289
- rspec_configure.should_not_receive(:expose_dsl_globally=)
1290
- converter.process_rspec_configure(rspec_configure)
1291
- end
1292
- end
1293
- end
1294
- end
1295
-
1296
- describe '#process_useless_and_return' do
1297
- let(:messaging_host) { double('messaging host').as_null_object }
1298
-
1299
- context 'when Config#convert_deprecated_method? returns true' do
1300
- before { config.convert_deprecated_method = true }
1301
-
1302
- it 'invokes #remove_useless_and_return!' do
1303
- messaging_host.should_receive(:remove_useless_and_return!)
1304
- converter.process_useless_and_return(messaging_host)
1305
- end
1306
- end
1307
-
1308
- context 'when Config#convert_deprecated_method? returns false' do
1309
- before { config.convert_deprecated_method = false }
1310
-
1311
- it 'does nothing' do
1312
- messaging_host.should_not_receive(:remove_useless_and_return!)
1313
- converter.process_useless_and_return(messaging_host)
1314
- end
1315
- end
1316
- end
1317
-
1318
- describe '#process_any_instance_block' do
1319
- let(:messaging_host) { double('messaging host').as_null_object }
1320
-
1321
- context 'when RSpecVersion#rspec_2_99? returns true' do
1322
- before do
1323
- rspec_version.stub(:rspec_2_99?).and_return(true)
1324
- end
1325
-
1326
- context 'and Config#convert_deprecated_method? returns true' do
1327
- before { config.convert_deprecated_method = true }
1328
-
1329
- context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns true' do
1330
- before { config.add_receiver_arg_to_any_instance_implementation_block = true }
1331
-
1332
- it 'invokes #add_receiver_arg_to_any_instance_implementation_block!' do
1333
- messaging_host.should_receive(:add_receiver_arg_to_any_instance_implementation_block!)
1334
- converter.process_any_instance_block(messaging_host)
1335
- end
1336
- end
1337
-
1338
- context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns false' do
1339
- before { config.add_receiver_arg_to_any_instance_implementation_block = false }
1340
-
1341
- it 'does nothing' do
1342
- messaging_host.should_not_receive(:add_instance_arg_to_any_instance_implementation_block!)
1343
- converter.process_any_instance_block(messaging_host)
1344
- end
1345
- end
1346
- end
1347
-
1348
- context 'and Config#convert_deprecated_method? returns false' do
1349
- before { config.convert_deprecated_method = false }
1350
-
1351
- context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns true' do
1352
- before { config.add_receiver_arg_to_any_instance_implementation_block = true }
1353
-
1354
- it 'does nothing' do
1355
- messaging_host.should_not_receive(:add_instance_arg_to_any_instance_implementation_block!)
1356
- converter.process_any_instance_block(messaging_host)
1357
- end
1358
- end
1359
- end
1360
- end
1361
-
1362
- context 'when RSpecVersion#rspec_2_99? returns false' do
1363
- before do
1364
- rspec_version.stub(:rspec_2_99?).and_return(false)
1365
- end
1366
-
1367
- it 'does nothing' do
1368
- messaging_host.should_not_receive(:add_instance_arg_to_any_instance_implementation_block!)
1369
- converter.process_any_instance_block(messaging_host)
1370
- end
1371
- end
1372
- end
1373
- end
1374
- end