transpec 1.10.4 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -3
  3. data/CHANGELOG.md +9 -0
  4. data/README.md +96 -18
  5. data/README.md.erb +117 -51
  6. data/lib/transpec/base_rewriter.rb +25 -28
  7. data/lib/transpec/cli.rb +27 -14
  8. data/lib/transpec/configuration.rb +2 -1
  9. data/lib/transpec/converter.rb +54 -32
  10. data/lib/transpec/dynamic_analyzer/helper.rb.erb +44 -0
  11. data/lib/transpec/dynamic_analyzer/node_util.rb +17 -0
  12. data/lib/transpec/dynamic_analyzer/rewriter.rb +12 -4
  13. data/lib/transpec/dynamic_analyzer/runtime_data.rb +3 -4
  14. data/lib/transpec/dynamic_analyzer.rb +14 -52
  15. data/lib/transpec/option_parser.rb +89 -81
  16. data/lib/transpec/processed_source.rb +48 -0
  17. data/lib/transpec/record.rb +2 -2
  18. data/lib/transpec/report.rb +5 -1
  19. data/lib/transpec/rspec_dsl.rb +12 -2
  20. data/lib/transpec/rspec_version.rb +8 -7
  21. data/lib/transpec/spec_suite.rb +114 -0
  22. data/lib/transpec/syntax/example.rb +4 -20
  23. data/lib/transpec/syntax/example_group.rb +38 -0
  24. data/lib/transpec/syntax/have.rb +6 -9
  25. data/lib/transpec/syntax/its.rb +5 -7
  26. data/lib/transpec/syntax/method_stub.rb +12 -13
  27. data/lib/transpec/syntax/mixin/any_instance_block.rb +14 -6
  28. data/lib/transpec/syntax/mixin/context_sensitive.rb +41 -0
  29. data/lib/transpec/syntax/mixin/matcher_owner.rb +16 -26
  30. data/lib/transpec/syntax/mixin/monkey_patch_any_instance.rb +1 -1
  31. data/lib/transpec/syntax/mixin/no_message_allowance.rb +2 -2
  32. data/lib/transpec/syntax/mixin/useless_and_return.rb +2 -2
  33. data/lib/transpec/syntax/oneliner_should.rb +9 -13
  34. data/lib/transpec/syntax/operator.rb +3 -7
  35. data/lib/transpec/syntax/pending.rb +4 -20
  36. data/lib/transpec/syntax/rspec_configure/configuration_modification.rb +86 -0
  37. data/lib/transpec/syntax/rspec_configure/framework.rb +45 -86
  38. data/lib/transpec/syntax/rspec_configure.rb +18 -6
  39. data/lib/transpec/syntax/should.rb +3 -5
  40. data/lib/transpec/syntax/should_receive.rb +1 -1
  41. data/lib/transpec/syntax.rb +8 -0
  42. data/lib/transpec/util.rb +0 -8
  43. data/lib/transpec/version.rb +2 -2
  44. data/spec/acceptance/configuration_modification_spec.rb +132 -0
  45. data/spec/acceptance/conversion_spec.rb +114 -0
  46. data/spec/support/shared_context.rb +6 -12
  47. data/spec/transpec/cli_spec.rb +21 -23
  48. data/spec/transpec/configuration_spec.rb +2 -1
  49. data/spec/transpec/converter_spec.rb +292 -213
  50. data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +3 -3
  51. data/spec/transpec/dynamic_analyzer_spec.rb +8 -2
  52. data/spec/transpec/option_parser_spec.rb +42 -4
  53. data/spec/transpec/processed_source_spec.rb +67 -0
  54. data/spec/transpec/rspec_version_spec.rb +8 -2
  55. data/spec/transpec/spec_suite_spec.rb +107 -0
  56. data/spec/transpec/syntax/allow_spec.rb +9 -27
  57. data/spec/transpec/syntax/example_group_spec.rb +172 -0
  58. data/spec/transpec/syntax/expect_spec.rb +18 -54
  59. data/spec/transpec/syntax/have_spec.rb +35 -14
  60. data/spec/transpec/syntax/its_spec.rb +27 -7
  61. data/spec/transpec/syntax/method_stub_spec.rb +31 -8
  62. data/spec/transpec/syntax/oneliner_should_spec.rb +22 -131
  63. data/spec/transpec/syntax/rspec_configure_spec.rb +118 -15
  64. data/spec/transpec/syntax/should_spec.rb +51 -82
  65. data/tasks/fixtures/guard/COMMIT_EDITMSG +80 -0
  66. data/tasks/fixtures/mail/COMMIT_EDITMSG +84 -0
  67. data/tasks/fixtures/twitter/COMMIT_EDITMSG +36 -0
  68. data/tasks/lib/transpec_test.rb +23 -2
  69. data/tasks/readme.rake +35 -0
  70. metadata +22 -4
  71. data/lib/transpec/parser.rb +0 -9
@@ -10,8 +10,8 @@ module Transpec
10
10
 
11
11
  subject(:rewriter) { Rewriter.new }
12
12
 
13
- describe '#rewrite' do
14
- subject { rewriter.rewrite(source) }
13
+ describe '#rewrite_source' do
14
+ subject { rewriter.rewrite_source(source) }
15
15
 
16
16
  let(:source) do
17
17
  <<-END
@@ -43,7 +43,7 @@ module Transpec
43
43
  # rubocop:disable LineLength
44
44
  let(:expected_source) do
45
45
  <<-'END'
46
- transpec_analyze((transpec_analyze((subject), self, "(string)_14_21", { :should_source_location => [:object, "method(:should).source_location"], :should_example_method_defined_by_user? => [:object, "owner = method(:should).owner\nowner != RSpec::Core::ExampleGroup &&\n owner.ancestors.include?(RSpec::Core::ExampleGroup)"] }).should), self, "(string)_14_28", { :"=~_source_location" => [:object, "method(:=~).source_location"], :"=~_example_method_defined_by_user?" => [:object, "owner = method(:=~).owner\nowner != RSpec::Core::ExampleGroup &&\n owner.ancestors.include?(RSpec::Core::ExampleGroup)"], :expect_available? => [:context, "self.class.ancestors.any? { |a| a.name.start_with?('RSpec::') } && respond_to?(:expect)"] }) =~ transpec_analyze((<<-HEREDOC.gsub('foo', 'bar')), self, "(string)_32_61", { :enumerable_arg? => [:object, "is_a?(Enumerable)"] })
46
+ transpec_analyze((transpec_analyze((subject), self, "(string)_14_21", { :should_source_location => [:object, "method(:should).source_location"], :should_example_method_defined_by_user? => [:object, "owner = method(:should).owner\nowner != RSpec::Core::ExampleGroup &&\n owner.ancestors.include?(RSpec::Core::ExampleGroup)"] }).should), self, "(string)_14_28", { :expect_available? => [:context, "self.class.ancestors.any? { |a| a.name.start_with?('RSpec::') } && respond_to?(:expect)"], :"=~_source_location" => [:object, "method(:=~).source_location"], :"=~_example_method_defined_by_user?" => [:object, "owner = method(:=~).owner\nowner != RSpec::Core::ExampleGroup &&\n owner.ancestors.include?(RSpec::Core::ExampleGroup)"] }) =~ transpec_analyze((<<-HEREDOC.gsub('foo', 'bar')), self, "(string)_32_61", { :enumerable_arg? => [:object, "is_a?(Enumerable)"] })
47
47
  foo
48
48
  HEREDOC
49
49
  END
@@ -92,7 +92,10 @@ module Transpec
92
92
 
93
93
  context 'when no path is passed' do
94
94
  it 'rewrites all files in the "spec" directory' do
95
- DynamicAnalyzer::Rewriter.any_instance.should_receive(:rewrite_file!).with(file_path)
95
+ DynamicAnalyzer::Rewriter.any_instance.should_receive(:rewrite_file!) do |spec|
96
+ spec.path.should == file_path
97
+ end
98
+
96
99
  dynamic_analyzer.analyze
97
100
  end
98
101
  end
@@ -103,7 +106,10 @@ module Transpec
103
106
  end
104
107
 
105
108
  it 'rewrites only files in the passed paths' do
106
- DynamicAnalyzer::Rewriter.any_instance.should_receive(:rewrite_file!).with(file_path)
109
+ DynamicAnalyzer::Rewriter.any_instance.should_receive(:rewrite_file!) do |spec|
110
+ spec.path.should == file_path
111
+ end
112
+
107
113
  dynamic_analyzer.analyze([file_path])
108
114
  end
109
115
  end
@@ -101,6 +101,32 @@ module Transpec
101
101
  end
102
102
  end
103
103
 
104
+ describe '-v/--convert option' do
105
+ [
106
+ ['stub_with_hash', :convert_stub_with_hash_to_allow_to_receive_and_return?],
107
+ ['example_group', :convert_example_group?]
108
+ ].each do |cli_type, config_attr|
109
+ context "when #{cli_type.inspect} is specified" do
110
+ let(:args) { ['--convert', cli_type] }
111
+
112
+ it "sets Configuration##{config_attr} true" do
113
+ parser.parse(args)
114
+ configuration.send(config_attr).should be_true
115
+ end
116
+ end
117
+ end
118
+
119
+ context 'when unknown type is specified' do
120
+ let(:args) { ['--convert', 'unknown'] }
121
+
122
+ it 'raises error' do
123
+ -> { parser.parse(args) }.should raise_error(ArgumentError) { |error|
124
+ error.message.should == 'Unknown syntax type "unknown"'
125
+ }
126
+ end
127
+ end
128
+ end
129
+
104
130
  describe '-n/--negative-form option' do
105
131
  ['not_to', 'to_not'].each do |form|
106
132
  context "when #{form.inspect} is specified" do
@@ -159,9 +185,21 @@ module Transpec
159
185
  describe '-t/--convert-stub-with-hash option' do
160
186
  let(:args) { ['--convert-stub-with-hash'] }
161
187
 
162
- it 'sets Configuration#convert_stub_with_hash_to_stub_and_return? true' do
188
+ before do
189
+ parser.stub(:warn)
190
+ end
191
+
192
+ it 'sets Configuration#convert_stub_with_hash_to_allow_to_receive_and_return? true' do
193
+ parser.parse(args)
194
+ configuration.convert_stub_with_hash_to_allow_to_receive_and_return?.should be_true
195
+ end
196
+
197
+ it 'is deprecated' do
198
+ parser.should_receive(:warn) do |message|
199
+ message.should =~ /--convert-stub-with-hash.+deprecated/i
200
+ end
201
+
163
202
  parser.parse(args)
164
- configuration.convert_stub_with_hash_to_stub_and_return?.should be_true
165
203
  end
166
204
  end
167
205
 
@@ -212,9 +250,9 @@ module Transpec
212
250
  parser.help
213
251
  end
214
252
 
215
- it 'does not exceed 80 characters in each line' do
253
+ it 'does not exceed 100 characters in each line' do
216
254
  help_text.each_line do |line|
217
- line.chomp.length.should <= 80
255
+ line.chomp.length.should <= 100
218
256
  end
219
257
  end
220
258
 
@@ -0,0 +1,67 @@
1
+ # coding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'transpec/processed_source'
5
+
6
+ module Transpec
7
+ describe ProcessedSource do
8
+ describe '.parse_file' do
9
+ include FileHelper
10
+ include_context 'isolated environment'
11
+
12
+ let(:spec_path) { 'spec/example_spec.rb' }
13
+
14
+ before do
15
+ create_file(spec_path, "puts 'foo'")
16
+ end
17
+
18
+ it 'parses the file and returns processed source' do
19
+ processed_source = ProcessedSource.parse_file(spec_path)
20
+ processed_source.path.should == spec_path
21
+ processed_source.ast.should_not be_nil
22
+ end
23
+ end
24
+
25
+ describe '.parse' do
26
+ it 'parses the source and returns processed source' do
27
+ processed_source = ProcessedSource.parse("puts 'foo'")
28
+ processed_source.ast.should_not be_nil
29
+ end
30
+
31
+ context 'when a file path is passed' do
32
+ let(:spec_path) { 'spec/example_spec.rb' }
33
+
34
+ it 'sets the path to the instance' do
35
+ processed_source = ProcessedSource.parse("puts 'foo'", spec_path)
36
+ processed_source.path.should == spec_path
37
+ end
38
+ end
39
+
40
+ context 'when no file path is passed' do
41
+ it 'does not set the path to the instance' do
42
+ processed_source = ProcessedSource.parse("puts 'foo'")
43
+ processed_source.path.should be_nil
44
+ end
45
+ end
46
+
47
+ context 'when the file has invalid source' do
48
+ it 'sets syntax error to the instance' do
49
+ processed_source = ProcessedSource.parse('<')
50
+ processed_source.syntax_error.should be_a(Parser::SyntaxError)
51
+ end
52
+ end
53
+ end
54
+
55
+ describe '#to_s' do
56
+ it 'returns the original source' do
57
+ source = [
58
+ "puts 'foo'",
59
+ "puts 'bar'"
60
+ ].join("\n")
61
+
62
+ processed_source = ProcessedSource.parse(source)
63
+ processed_source.to_s.should == source
64
+ end
65
+ end
66
+ end
67
+ end
@@ -54,7 +54,9 @@ module Transpec
54
54
  ]
55
55
  end
56
56
 
57
- [:receive_messages_available?].each do |method|
57
+ [
58
+ :receive_messages_available?
59
+ ].each do |method|
58
60
  include_examples 'version comparisons', method, [
59
61
  ['2.14.0', false],
60
62
  ['2.99.0.beta1', false],
@@ -66,7 +68,11 @@ module Transpec
66
68
  ]
67
69
  end
68
70
 
69
- [:receive_message_chain_available?, :non_should_matcher_protocol_available?].each do |method|
71
+ [
72
+ :receive_message_chain_available?,
73
+ :non_should_matcher_protocol_available?,
74
+ :non_monkey_patch_example_group_available?
75
+ ].each do |method|
70
76
  include_examples 'version comparisons', method, [
71
77
  ['2.14.0', false],
72
78
  ['2.99.0.beta1', false],
@@ -0,0 +1,107 @@
1
+ # coding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'transpec/spec_suite'
5
+ require 'transpec/dynamic_analyzer'
6
+
7
+ module Transpec
8
+ describe SpecSuite do
9
+ include FileHelper
10
+ include_context 'isolated environment'
11
+
12
+ subject(:spec_suite) { SpecSuite.new(base_paths, runtime_data) }
13
+ let(:runtime_data) { nil }
14
+ let(:base_paths) { [] }
15
+
16
+ describe '#need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config?' do
17
+ subject do
18
+ spec_suite.need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config?
19
+ end
20
+
21
+ context "when there's an any_instance block to convert" do
22
+ before do
23
+ create_file('spec/example_spec.rb', <<-END)
24
+ describe 'example' do
25
+ it 'responds to #message' do
26
+ Object.any_instance.stub(:message) do |arg|
27
+ end
28
+ end
29
+ end
30
+ END
31
+ end
32
+
33
+ it { should be_true }
34
+ end
35
+
36
+ context "when there's no any_instance block to convert" do
37
+ before do
38
+ create_file('spec/example_spec.rb', <<-END)
39
+ describe 'example' do
40
+ it 'responds to #message' do
41
+ Object.any_instance.stub(:message) do
42
+ end
43
+ end
44
+ end
45
+ END
46
+ end
47
+
48
+ it { should be_false }
49
+ end
50
+ end
51
+
52
+ describe '#main_rspec_configure_node?' do
53
+ before do
54
+ create_file('spec/spec_helper.rb', <<-END)
55
+ RSpec.configure do |config|
56
+ end
57
+ END
58
+
59
+ create_file('spec/unit/spec_helper.rb', <<-END)
60
+ require 'spec_helper'
61
+
62
+ RSpec.configure do |config|
63
+ end
64
+ END
65
+
66
+ create_file('spec/unit/unit_spec.rb', <<-END)
67
+ require 'unit/spec_helper'
68
+ END
69
+ end
70
+
71
+ context 'without runtime information' do
72
+ it 'returns true for every node' do
73
+ spec_suite.specs.each do |spec|
74
+ spec.ast.each_node do |node|
75
+ spec_suite.main_rspec_configure_node?(node).should be_true
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ context 'with runtime information' do
82
+ let(:runtime_data) { Transpec::DynamicAnalyzer.new(silent: true).analyze(base_paths) }
83
+
84
+ let(:main_rspec_configure_node) do
85
+ spec_suite.specs.each do |spec|
86
+ next unless spec.path == 'spec/spec_helper.rb'
87
+ spec.ast.each_node do |node|
88
+ return node if node.send_type? && node.children[1] == :configure
89
+ end
90
+ end
91
+ fail 'Main RSpec.configure node not found!'
92
+ end
93
+
94
+ it 'returns true only for the main RSpec.configure node' do
95
+ spec_suite.main_rspec_configure_node?(main_rspec_configure_node).should be_true
96
+
97
+ spec_suite.specs.each do |spec|
98
+ spec.ast.each_node do |node|
99
+ next if node.equal?(main_rspec_configure_node)
100
+ spec_suite.main_rspec_configure_node?(node).should be_false
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -65,36 +65,18 @@ module Transpec
65
65
  describe '#receive_matcher' do
66
66
  subject { allow_object.receive_matcher }
67
67
 
68
- context 'when it is taking #receive matcher' do
69
- let(:source) do
70
- <<-END
71
- describe 'example' do
72
- it 'receives :foo' do
73
- allow(subject).to receive(:foo)
74
- end
68
+ let(:source) do
69
+ <<-END
70
+ describe 'example' do
71
+ it 'receives :foo' do
72
+ allow(subject).to receive(:foo)
75
73
  end
76
- END
77
- end
78
-
79
- it 'returns an instance of Receive' do
80
- should be_an(Receive)
81
- end
74
+ end
75
+ END
82
76
  end
83
77
 
84
- context 'when it is taking any other matcher' do
85
- let(:source) do
86
- <<-END
87
- describe 'example' do
88
- it 'is empty' do
89
- allow(subject).to be_empty
90
- end
91
- end
92
- END
93
- end
94
-
95
- it 'returns nil' do
96
- should be_nil
97
- end
78
+ it 'returns an instance of Receive' do
79
+ should be_an(Receive)
98
80
  end
99
81
  end
100
82
 
@@ -0,0 +1,172 @@
1
+ # coding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'transpec/syntax/example_group'
5
+
6
+ module Transpec
7
+ class Syntax
8
+ describe ExampleGroup do
9
+ include_context 'parsed objects'
10
+ include_context 'syntax object', ExampleGroup, :example_group
11
+
12
+ let(:record) { example_group.report.records.first }
13
+
14
+ describe '#convert_to_non_monkey_patch!' do
15
+ context 'when it is in top level scope' do
16
+ [
17
+ :describe,
18
+ :shared_examples,
19
+ :shared_context,
20
+ :share_examples_for,
21
+ :shared_examples_for
22
+ ].each do |method|
23
+ context "with expression `#{method} 'something' do ... end`" do
24
+ let(:source) do
25
+ <<-END
26
+ #{method} 'something' do
27
+ end
28
+ END
29
+ end
30
+
31
+ let(:expected_source) do
32
+ <<-END
33
+ RSpec.#{method} 'something' do
34
+ end
35
+ END
36
+ end
37
+
38
+ it "converts to `RSpec.#{method} 'something' do ... end`" do
39
+ example_group.convert_to_non_monkey_patch!
40
+ rewritten_source.should == expected_source
41
+ end
42
+
43
+ it "adds record `#{method} 'something' { }` -> `RSpec.#{method} 'something' { }`" do
44
+ example_group.convert_to_non_monkey_patch!
45
+ record.original_syntax.should == "#{method} 'something' { }"
46
+ record.converted_syntax.should == "RSpec.#{method} 'something' { }"
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ context 'when the #describe is in a module' do
53
+ let(:source) do
54
+ <<-END
55
+ module SomeModule
56
+ describe 'something' do
57
+ end
58
+ end
59
+ END
60
+ end
61
+
62
+ let(:expected_source) do
63
+ <<-END
64
+ module SomeModule
65
+ RSpec.describe 'something' do
66
+ end
67
+ end
68
+ END
69
+ end
70
+
71
+ it 'converts' do
72
+ example_group.convert_to_non_monkey_patch!
73
+ rewritten_source.should == expected_source
74
+ end
75
+ end
76
+
77
+ shared_context 'multiple #describes' do
78
+ before do
79
+ ast.each_node do |node|
80
+ example_group = described_class.new(node, source_rewriter, runtime_data)
81
+ next unless example_group.conversion_target?
82
+ example_group.convert_to_non_monkey_patch!
83
+ end
84
+ end
85
+ end
86
+
87
+ context 'when #describes are nested' do
88
+ include_context 'multiple #describes'
89
+
90
+ let(:source) do
91
+ <<-END
92
+ describe 'something' do
93
+ describe '#some_method' do
94
+ end
95
+ end
96
+ END
97
+ end
98
+
99
+ let(:expected_source) do
100
+ <<-END
101
+ RSpec.describe 'something' do
102
+ describe '#some_method' do
103
+ end
104
+ end
105
+ END
106
+ end
107
+
108
+ it 'converts only the outermost #describe' do
109
+ rewritten_source.should == expected_source
110
+ end
111
+ end
112
+
113
+ context 'when logical-inner #describe is placed outside of the outer #describe in source' do
114
+ include_context 'multiple #describes'
115
+
116
+ let(:source) do
117
+ <<-END
118
+ inner_proc = proc do
119
+ describe 'inner' do
120
+ end
121
+ end
122
+
123
+ describe 'outer' do
124
+ instance_eval(&inner_proc)
125
+ end
126
+ END
127
+ end
128
+
129
+ context 'without runtime information' do
130
+ let(:expected_source) do
131
+ <<-END
132
+ inner_proc = proc do
133
+ RSpec.describe 'inner' do
134
+ end
135
+ end
136
+
137
+ RSpec.describe 'outer' do
138
+ instance_eval(&inner_proc)
139
+ end
140
+ END
141
+ end
142
+
143
+ it 'unfortunately converts both #describe' do
144
+ rewritten_source.should == expected_source
145
+ end
146
+ end
147
+
148
+ context 'with runtime information' do
149
+ include_context 'dynamic analysis objects'
150
+
151
+ let(:expected_source) do
152
+ <<-END
153
+ inner_proc = proc do
154
+ describe 'inner' do
155
+ end
156
+ end
157
+
158
+ RSpec.describe 'outer' do
159
+ instance_eval(&inner_proc)
160
+ end
161
+ END
162
+ end
163
+
164
+ it 'properly converts only the outermost #describe' do
165
+ rewritten_source.should == expected_source
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
171
+ end
172
+ end
@@ -151,72 +151,36 @@ module Transpec
151
151
  describe '#have_matcher' do
152
152
  subject { expect_object.have_matcher }
153
153
 
154
- context 'when it is taking #have matcher' do
155
- let(:source) do
156
- <<-END
157
- describe 'example' do
158
- it 'has 2 items' do
159
- expect(subject).to have(2).items
160
- end
154
+ let(:source) do
155
+ <<-END
156
+ describe 'example' do
157
+ it 'has 2 items' do
158
+ expect(subject).to have(2).items
161
159
  end
162
- END
163
- end
164
-
165
- it 'returns an instance of Have' do
166
- should be_an(Have)
167
- end
160
+ end
161
+ END
168
162
  end
169
163
 
170
- context 'when it is taking any other matcher' do
171
- let(:source) do
172
- <<-END
173
- describe 'example' do
174
- it 'is empty' do
175
- expect(subject).to be_empty
176
- end
177
- end
178
- END
179
- end
180
-
181
- it 'returns nil' do
182
- should be_nil
183
- end
164
+ it 'returns an instance of Have' do
165
+ should be_an(Have)
184
166
  end
185
167
  end
186
168
 
187
169
  describe '#receive_matcher' do
188
170
  subject { expect_object.receive_matcher }
189
171
 
190
- context 'when it is taking #receive matcher' do
191
- let(:source) do
192
- <<-END
193
- describe 'example' do
194
- it 'receives :foo' do
195
- expect(subject).to receive(:foo)
196
- end
172
+ let(:source) do
173
+ <<-END
174
+ describe 'example' do
175
+ it 'receives :foo' do
176
+ expect(subject).to receive(:foo)
197
177
  end
198
- END
199
- end
200
-
201
- it 'returns an instance of Receive' do
202
- should be_an(Receive)
203
- end
178
+ end
179
+ END
204
180
  end
205
181
 
206
- context 'when it is taking any other matcher' do
207
- let(:source) do
208
- <<-END
209
- describe 'example' do
210
- it 'is empty' do
211
- expect(subject).to be_empty
212
- end
213
- end
214
- END
215
- end
216
-
217
- it 'returns nil' do
218
- should be_nil
219
- end
182
+ it 'returns an instance of Receive' do
183
+ should be_an(Receive)
220
184
  end
221
185
  end
222
186