rspec-mocks 3.0.0.beta1 → 3.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data.tar.gz.sig +1 -1
  2. data/Changelog.md +95 -3
  3. data/README.md +27 -13
  4. data/features/README.md +15 -7
  5. data/features/argument_matchers/README.md +5 -5
  6. data/features/argument_matchers/explicit.feature +6 -6
  7. data/features/argument_matchers/general_matchers.feature +4 -4
  8. data/features/argument_matchers/type_matchers.feature +2 -2
  9. data/features/message_expectations/README.md +29 -27
  10. data/features/message_expectations/call_original.feature +0 -1
  11. data/features/message_expectations/message_chains_using_expect.feature +49 -0
  12. data/features/method_stubs/README.md +2 -1
  13. data/features/method_stubs/{any_instance.feature → allow_any_instance_of.feature} +12 -12
  14. data/features/method_stubs/{stub_chain.feature → receive_message_chain.feature} +3 -3
  15. data/features/method_stubs/to_ary.feature +1 -1
  16. data/features/mutating_constants/stub_defined_constant.feature +0 -1
  17. data/features/outside_rspec/standalone.feature +1 -1
  18. data/features/spies/spy_pure_mock_method.feature +1 -1
  19. data/features/test_frameworks/test_unit.feature +21 -10
  20. data/features/verifying_doubles/README.md +17 -0
  21. data/features/verifying_doubles/class_doubles.feature +1 -16
  22. data/features/verifying_doubles/dynamic_classes.feature +0 -1
  23. data/features/verifying_doubles/{introduction.feature → instance_doubles.feature} +41 -23
  24. data/features/verifying_doubles/partial_doubles.feature +2 -2
  25. data/lib/rspec/mocks.rb +69 -82
  26. data/lib/rspec/mocks/any_instance/expect_chain_chain.rb +35 -0
  27. data/lib/rspec/mocks/any_instance/expectation_chain.rb +1 -2
  28. data/lib/rspec/mocks/any_instance/recorder.rb +52 -18
  29. data/lib/rspec/mocks/any_instance/stub_chain.rb +1 -1
  30. data/lib/rspec/mocks/any_instance/stub_chain_chain.rb +4 -0
  31. data/lib/rspec/mocks/argument_list_matcher.rb +10 -44
  32. data/lib/rspec/mocks/argument_matchers.rb +132 -163
  33. data/lib/rspec/mocks/configuration.rb +28 -4
  34. data/lib/rspec/mocks/error_generator.rb +46 -13
  35. data/lib/rspec/mocks/example_methods.rb +13 -12
  36. data/lib/rspec/mocks/extensions/marshal.rb +1 -1
  37. data/lib/rspec/mocks/framework.rb +3 -4
  38. data/lib/rspec/mocks/instance_method_stasher.rb +2 -3
  39. data/lib/rspec/mocks/matchers/have_received.rb +8 -6
  40. data/lib/rspec/mocks/matchers/receive.rb +28 -20
  41. data/lib/rspec/mocks/matchers/receive_message_chain.rb +65 -0
  42. data/lib/rspec/mocks/matchers/receive_messages.rb +3 -2
  43. data/lib/rspec/mocks/message_chain.rb +91 -0
  44. data/lib/rspec/mocks/message_expectation.rb +86 -80
  45. data/lib/rspec/mocks/method_double.rb +2 -11
  46. data/lib/rspec/mocks/method_reference.rb +82 -23
  47. data/lib/rspec/mocks/method_signature_verifier.rb +207 -0
  48. data/lib/rspec/mocks/mutate_const.rb +34 -50
  49. data/lib/rspec/mocks/object_reference.rb +0 -1
  50. data/lib/rspec/mocks/proxy.rb +70 -13
  51. data/lib/rspec/mocks/ruby_features.rb +24 -0
  52. data/lib/rspec/mocks/space.rb +105 -31
  53. data/lib/rspec/mocks/standalone.rb +2 -2
  54. data/lib/rspec/mocks/syntax.rb +43 -8
  55. data/lib/rspec/mocks/targets.rb +16 -7
  56. data/lib/rspec/mocks/test_double.rb +41 -15
  57. data/lib/rspec/mocks/verifying_double.rb +51 -4
  58. data/lib/rspec/mocks/verifying_message_expecation.rb +12 -12
  59. data/lib/rspec/mocks/verifying_proxy.rb +32 -19
  60. data/lib/rspec/mocks/version.rb +1 -1
  61. data/spec/rspec/mocks/and_call_original_spec.rb +28 -7
  62. data/spec/rspec/mocks/and_return_spec.rb +23 -0
  63. data/spec/rspec/mocks/and_yield_spec.rb +1 -2
  64. data/spec/rspec/mocks/any_instance_spec.rb +33 -17
  65. data/spec/rspec/mocks/array_including_matcher_spec.rb +6 -6
  66. data/spec/rspec/mocks/before_all_spec.rb +132 -0
  67. data/spec/rspec/mocks/block_return_value_spec.rb +12 -1
  68. data/spec/rspec/mocks/combining_implementation_instructions_spec.rb +9 -11
  69. data/spec/rspec/mocks/configuration_spec.rb +14 -1
  70. data/spec/rspec/mocks/double_spec.rb +867 -24
  71. data/spec/rspec/mocks/example_methods_spec.rb +13 -0
  72. data/spec/rspec/mocks/extensions/marshal_spec.rb +17 -17
  73. data/spec/rspec/mocks/failing_argument_matchers_spec.rb +29 -1
  74. data/spec/rspec/mocks/hash_excluding_matcher_spec.rb +12 -12
  75. data/spec/rspec/mocks/hash_including_matcher_spec.rb +21 -17
  76. data/spec/rspec/mocks/instance_method_stasher_spec.rb +2 -3
  77. data/spec/rspec/mocks/matchers/have_received_spec.rb +7 -0
  78. data/spec/rspec/mocks/matchers/receive_message_chain_spec.rb +198 -0
  79. data/spec/rspec/mocks/matchers/receive_messages_spec.rb +2 -2
  80. data/spec/rspec/mocks/matchers/receive_spec.rb +19 -6
  81. data/spec/rspec/mocks/method_signature_verifier_spec.rb +272 -0
  82. data/spec/rspec/mocks/methods_spec.rb +0 -1
  83. data/spec/rspec/mocks/multiple_return_value_spec.rb +2 -2
  84. data/spec/rspec/mocks/mutate_const_spec.rb +24 -1
  85. data/spec/rspec/mocks/nil_expectation_warning_spec.rb +6 -22
  86. data/spec/rspec/mocks/null_object_mock_spec.rb +13 -7
  87. data/spec/rspec/mocks/options_hash_spec.rb +3 -3
  88. data/spec/rspec/mocks/{partial_mock_spec.rb → partial_double_spec.rb} +5 -2
  89. data/spec/rspec/mocks/{partial_mock_using_mocks_directly_spec.rb → partial_double_using_mocks_directly_spec.rb} +1 -1
  90. data/spec/rspec/mocks/passing_argument_matchers_spec.rb +18 -0
  91. data/spec/rspec/mocks/serialization_spec.rb +1 -0
  92. data/spec/rspec/mocks/space_spec.rb +218 -7
  93. data/spec/rspec/mocks/stub_chain_spec.rb +6 -0
  94. data/spec/rspec/mocks/stub_spec.rb +0 -6
  95. data/spec/rspec/mocks/syntax_spec.rb +19 -0
  96. data/spec/rspec/mocks/test_double_spec.rb +0 -1
  97. data/spec/rspec/mocks/verifying_double_spec.rb +281 -18
  98. data/spec/rspec/mocks/verifying_message_expecation_spec.rb +7 -6
  99. data/spec/rspec/mocks_spec.rb +168 -42
  100. data/spec/spec_helper.rb +34 -22
  101. metadata +94 -63
  102. metadata.gz.sig +0 -0
  103. checksums.yaml +0 -15
  104. checksums.yaml.gz.sig +0 -2
  105. data/features/outside_rspec/configuration.feature +0 -60
  106. data/lib/rspec/mocks/arity_calculator.rb +0 -66
  107. data/lib/rspec/mocks/errors.rb +0 -12
  108. data/lib/rspec/mocks/mock.rb +0 -7
  109. data/lib/rspec/mocks/proxy_for_nil.rb +0 -37
  110. data/lib/rspec/mocks/stub_chain.rb +0 -51
  111. data/spec/rspec/mocks/argument_expectation_spec.rb +0 -32
  112. data/spec/rspec/mocks/arity_calculator_spec.rb +0 -95
  113. data/spec/rspec/mocks/mock_space_spec.rb +0 -113
  114. data/spec/rspec/mocks/mock_spec.rb +0 -788
@@ -64,7 +64,7 @@ module RSpec
64
64
  let(:expectation_error) do
65
65
  failure = nil
66
66
  begin
67
- RSpec::Mocks.space.verify_all
67
+ verify_all
68
68
  rescue RSpec::Mocks::MockExpectationError => error
69
69
  failure = error
70
70
  end
@@ -74,7 +74,7 @@ module RSpec
74
74
  it "sets up multiple expectations" do
75
75
  expect(obj).to receive_messages(:a => 1, :b => 2)
76
76
  obj.a
77
- expect { RSpec::Mocks.space.verify_all }.to raise_error RSpec::Mocks::MockExpectationError
77
+ expect { verify_all }.to raise_error RSpec::Mocks::MockExpectationError
78
78
  end
79
79
 
80
80
  it 'fails with a sensible message' do
@@ -5,10 +5,6 @@ module RSpec
5
5
  describe Matchers::Receive do
6
6
  include_context "with syntax", :expect
7
7
 
8
- def verify_all
9
- ::RSpec::Mocks.space.verify_all
10
- end
11
-
12
8
  describe "expectations/allowances on any instance recorders" do
13
9
  include_context "with syntax", [:expect, :should]
14
10
 
@@ -93,6 +89,24 @@ module RSpec
93
89
  expect(receiver.foo(1)).to eq(:a)
94
90
  expect(receiver.foo(2)).to eq(:b)
95
91
  end
92
+
93
+ it 'allows do...end blocks to be passed to the fluent interface methods without getting a warning' do
94
+ expect(RSpec).not_to receive(:warning)
95
+
96
+ wrapped.to receive(:foo).with(1) do
97
+ :a
98
+ end
99
+
100
+ expect(receiver.foo(1)).to eq(:a)
101
+ end
102
+
103
+ it 'makes { } blocks trump do...end blocks when passed to a fluent interface method' do
104
+ wrapped.to receive(:foo).with(1) { :curly } do
105
+ :do_end
106
+ end
107
+
108
+ expect(receiver.foo(1)).to eq(:curly)
109
+ end
96
110
  end
97
111
 
98
112
  shared_examples_for "an expect syntax allowance" do |*options|
@@ -207,7 +221,7 @@ module RSpec
207
221
  it "removes the method double" do
208
222
  target.to receive(:foo).and_return(:baz)
209
223
  expect {
210
- ::RSpec::Mocks.space.verify_all
224
+ verify_all
211
225
  }.to change { object.foo }.from(:baz).to(:bar)
212
226
  end
213
227
  end
@@ -402,4 +416,3 @@ module RSpec
402
416
  end
403
417
  end
404
418
  end
405
-
@@ -0,0 +1,272 @@
1
+ require 'spec_helper'
2
+
3
+ module RSpec
4
+ module Mocks
5
+ describe MethodSignatureVerifier do
6
+ describe '#verify!' do
7
+ let(:signature) { MethodSignature.new(test_method) }
8
+
9
+ def valid_non_kw_args?(arity)
10
+ described_class.new(signature, [nil] * arity).valid?
11
+ end
12
+
13
+ def valid?(*args)
14
+ described_class.new(signature, args).valid?
15
+ end
16
+
17
+ def error_description
18
+ described_class.new(signature, []).error_message[/Expected (.*),/, 1]
19
+ end
20
+
21
+ def error_for(*args)
22
+ described_class.new(signature, args).error_message
23
+ end
24
+
25
+ def signature_description
26
+ signature.description
27
+ end
28
+
29
+ describe 'with a method with arguments' do
30
+ def arity_two(x, y); end
31
+
32
+ let(:test_method) { method(:arity_two) }
33
+
34
+ it 'covers only the exact arity' do
35
+ expect(valid_non_kw_args?(1)).to eq(false)
36
+ expect(valid_non_kw_args?(2)).to eq(true)
37
+ expect(valid_non_kw_args?(3)).to eq(false)
38
+ end
39
+
40
+ it 'does not treat a last-arg hash as kw args' do
41
+ expect(valid?(1, {})).to eq(true)
42
+ end
43
+
44
+ it 'describes the arity precisely' do
45
+ expect(error_description).to eq("2")
46
+ end
47
+
48
+ it 'mentions only the arity in the description' do
49
+ expect(signature_description).to eq("arity of 2")
50
+ end
51
+ end
52
+
53
+ describe 'a method with splat arguments' do
54
+ def arity_splat(_, *); end
55
+
56
+ let(:test_method) { method(:arity_splat) }
57
+
58
+ it 'covers a range from the lower bound upwards' do
59
+ expect(valid_non_kw_args?(0)).to eq(false)
60
+ expect(valid_non_kw_args?(1)).to eq(true)
61
+ expect(valid_non_kw_args?(2)).to eq(true)
62
+ expect(valid_non_kw_args?(3)).to eq(true)
63
+ end
64
+
65
+ it 'describes the arity with no upper bound' do
66
+ expect(error_description).to eq("1 or more")
67
+ end
68
+
69
+ it 'mentions only the arity in the description' do
70
+ expect(signature_description).to eq("arity of 1 or more")
71
+ end
72
+ end
73
+
74
+ describe 'a method with optional arguments' do
75
+ def arity_optional(x, y, z = 1); end
76
+
77
+ let(:test_method) { method(:arity_optional) }
78
+
79
+ it 'covers a range from min to max possible arguments' do
80
+ expect(valid_non_kw_args?(1)).to eq(false)
81
+ expect(valid_non_kw_args?(2)).to eq(true)
82
+ expect(valid_non_kw_args?(3)).to eq(true)
83
+
84
+ if optional_and_splat_args_supported?
85
+ expect(valid_non_kw_args?(4)).to eq(false)
86
+ else
87
+ expect(valid_non_kw_args?(4)).to eq(true)
88
+ end
89
+ end
90
+
91
+ if optional_and_splat_args_supported?
92
+ it 'describes the arity as a range' do
93
+ expect(error_description).to eq("2 to 3")
94
+ end
95
+ else
96
+ it 'describes the arity with no upper bound' do
97
+ expect(error_description).to eq("2 or more")
98
+ end
99
+ end
100
+ end
101
+
102
+ if kw_args_supported?
103
+ describe 'a method with optional keyword arguments' do
104
+ eval <<-RUBY
105
+ def arity_kw(x, y:1, z:2); end
106
+ RUBY
107
+
108
+ let(:test_method) { method(:arity_kw) }
109
+
110
+ it 'does not require any of the arguments' do
111
+ expect(valid?(nil)).to eq(true)
112
+ expect(valid?(nil, nil)).to eq(false)
113
+ end
114
+
115
+ it 'does not allow an invalid keyword arguments' do
116
+ expect(valid?(nil, :a => 1)).to eq(false)
117
+ end
118
+
119
+ it 'mentions the invalid keyword args in the error' do
120
+ expect(error_for(nil, :a => 0, :b => 1)).to \
121
+ eq("Invalid keyword arguments provided: a, b")
122
+ end
123
+
124
+ it 'describes invalid arity precisely' do
125
+ expect(error_for()).to \
126
+ eq("Wrong number of arguments. Expected 1, got 0.")
127
+ end
128
+
129
+ it 'does not blow up when given a BasicObject as the last arg' do
130
+ expect(valid?(BasicObject.new)).to eq(true)
131
+ end
132
+
133
+ it 'does not mutate the provided args array' do
134
+ args = [nil, { :y => 1 }]
135
+ described_class.new(signature, args).valid?
136
+ expect(args).to eq([nil, { :y => 1 }])
137
+ end
138
+
139
+ it 'mentions the arity and optional kw args in the description' do
140
+ expect(signature_description).to eq("arity of 1 and optional keyword args (:y, :z)")
141
+ end
142
+ end
143
+ end
144
+
145
+ if required_kw_args_supported?
146
+ describe 'a method with required keyword arguments' do
147
+ eval <<-RUBY
148
+ def arity_required_kw(x, y:, z:, a: 'default'); end
149
+ RUBY
150
+
151
+ let(:test_method) { method(:arity_required_kw) }
152
+
153
+ it 'returns false unless all required keywords args are present' do
154
+ expect(valid?(nil, :a => 0, :y => 1, :z => 2)).to eq(true)
155
+ expect(valid?(nil, :a => 0, :y => 1)).to eq(false)
156
+ expect(valid?(nil, nil, :a => 0, :y => 1, :z => 2)).to eq(false)
157
+ expect(valid?(nil, nil)).to eq(false)
158
+ end
159
+
160
+ it 'mentions the missing required keyword args in the error' do
161
+ expect(error_for(nil, :a => 0)).to \
162
+ eq("Missing required keyword arguments: y, z")
163
+ end
164
+
165
+ it 'is described precisely when arity is wrong' do
166
+ expect(error_for(nil, nil, :z => 0, :y => 1)).to \
167
+ eq("Wrong number of arguments. Expected 1, got 2.")
168
+ end
169
+
170
+ it 'mentions the arity, optional kw args and required kw args in the description' do
171
+ expect(signature_description).to \
172
+ eq("arity of 1 and optional keyword args (:a) and required keyword args (:y, :z)")
173
+ end
174
+ end
175
+
176
+ describe 'a method with required keyword arguments and a splat' do
177
+ eval <<-RUBY
178
+ def arity_required_kw_splat(w, *x, y:, z:, a: 'default'); end
179
+ RUBY
180
+
181
+ let(:test_method) { method(:arity_required_kw_splat) }
182
+
183
+ it 'returns false unless all required keywords args are present' do
184
+ expect(valid?(nil, :a => 0, :y => 1, :z => 2)).to eq(true)
185
+ expect(valid?(nil, :a => 0, :y => 1)).to eq(false)
186
+ expect(valid?(nil, nil, :a => 0, :y => 1, :z => 2)).to eq(true)
187
+ expect(valid?(nil, nil, nil)).to eq(false)
188
+ expect(valid?).to eq(false)
189
+ end
190
+
191
+ it 'mentions missing required keyword args in the error' do
192
+ expect(error_for(nil, :y => 1)).to \
193
+ eq("Missing required keyword arguments: z")
194
+ end
195
+
196
+ it 'mentions the arity, optional kw args and required kw args in the description' do
197
+ expect(signature_description).to \
198
+ eq("arity of 1 or more and optional keyword args (:a) and required keyword args (:y, :z)")
199
+ end
200
+ end
201
+
202
+ describe 'a method with required keyword arguments and a keyword arg splat' do
203
+ eval <<-RUBY
204
+ def arity_kw_arg_splat(x:, **rest); end
205
+ RUBY
206
+
207
+ let(:test_method) { method(:arity_kw_arg_splat) }
208
+
209
+ it 'allows extra undeclared keyword args' do
210
+ expect(valid?(:x => 1)).to eq(true)
211
+ expect(valid?(:x => 1, :y => 2)).to eq(true)
212
+ end
213
+
214
+ it 'mentions missing required keyword args in the error' do
215
+ expect(error_for(:y => 1)).to \
216
+ eq("Missing required keyword arguments: x")
217
+ end
218
+
219
+ it 'mentions the required kw args and keyword splat in the description' do
220
+ expect(signature_description).to \
221
+ eq("required keyword args (:x) and any additional keyword args")
222
+ end
223
+ end
224
+
225
+ describe 'a method with a required arg and a keyword arg splat' do
226
+ eval <<-RUBY
227
+ def arity_kw_arg_splat(x, **rest); end
228
+ RUBY
229
+
230
+ let(:test_method) { method(:arity_kw_arg_splat) }
231
+
232
+ it 'allows a single arg and any number of keyword args' do
233
+ expect(valid?(nil)).to eq(true)
234
+ expect(valid?(nil, :x => 1)).to eq(true)
235
+ expect(valid?(nil, :x => 1, :y => 2)).to eq(true)
236
+ expect(valid?(:x => 1)).to eq(true)
237
+
238
+ expect(valid?).to eq(false)
239
+ expect(valid?(nil, nil)).to eq(false)
240
+ expect(valid?(nil, nil, :x => 1)).to eq(false)
241
+ end
242
+
243
+ it 'describes the arity precisely' do
244
+ expect(error_for()).to \
245
+ eq("Wrong number of arguments. Expected 1, got 0.")
246
+ end
247
+
248
+ it 'mentions the required kw args and keyword splat in the description' do
249
+ expect(signature_description).to \
250
+ eq("arity of 1 and any additional keyword args")
251
+ end
252
+ end
253
+ end
254
+
255
+ describe 'a method with a block' do
256
+ def arity_block(_, &block); end
257
+
258
+ let(:test_method) { method(:arity_block) }
259
+
260
+ it 'does not count the block as a parameter' do
261
+ expect(valid_non_kw_args?(1)).to eq(true)
262
+ expect(valid_non_kw_args?(2)).to eq(false)
263
+ end
264
+
265
+ it 'describes the arity precisely' do
266
+ expect(error_description).to eq("1")
267
+ end
268
+ end
269
+ end
270
+ end
271
+ end
272
+ end
@@ -24,4 +24,3 @@ module RSpec
24
24
  end
25
25
  end
26
26
  end
27
-
@@ -56,7 +56,7 @@ module RSpec
56
56
  before(:each) do
57
57
  @double = double
58
58
  @return_values = [1,2,3]
59
- @double.should_receive(:do_something).exactly(3).times.and_return(@return_values[0],@return_values[1],@return_values[2])
59
+ @double.should_receive(:do_something).exactly(3).times.and_return(@return_values[0], @return_values[1], @return_values[2])
60
60
  end
61
61
 
62
62
  it "returns values in order to consecutive calls" do
@@ -104,7 +104,7 @@ module RSpec
104
104
 
105
105
  describe "a message expectation with multiple return values with a specified count larger than the number of values" do
106
106
  before(:each) do
107
- @double = RSpec::Mocks::Mock.new("double")
107
+ @double = RSpec::Mocks::Double.new("double")
108
108
  @double.should_receive(:do_something).exactly(3).times.and_return(11, 22)
109
109
  end
110
110
 
@@ -451,6 +451,18 @@ module RSpec
451
451
  it("returns nil for the original value") { expect(const.original_value).to be_nil }
452
452
  end
453
453
 
454
+ context 'for a previously undefined parent of a stubbed constant' do
455
+ before { stub_const("TestClass::UndefinedModule::Undefined", :other) }
456
+ let(:const) { Constant.original("TestClass::UndefinedModule") }
457
+
458
+ it("exposes its name") { expect(const.name).to eq("TestClass::UndefinedModule") }
459
+ it("indicates it was not previously defined") { expect(const).not_to be_previously_defined }
460
+ it("indicates it has been mutated") { expect(const).to be_mutated }
461
+ it("indicates it has been stubbed") { expect(const).to be_stubbed }
462
+ it("indicates it has not been hidden") { expect(const).not_to be_hidden }
463
+ it("returns nil for the original value") { expect(const.original_value).to be_nil }
464
+ end
465
+
454
466
  context 'for a previously undefined unstubbed constant' do
455
467
  let(:const) { Constant.original("TestClass::Undefined") }
456
468
 
@@ -488,6 +500,18 @@ module RSpec
488
500
  it("returns nil for the original value") { expect(const.original_value).to be_nil }
489
501
  end
490
502
 
503
+ context 'for a previously undefined hidden constant' do
504
+ before { hide_const("SomeUndefinedConst") }
505
+ let(:const) { Constant.original("SomeUndefinedConst") }
506
+
507
+ it("exposes its name") { expect(const.name).to eq("SomeUndefinedConst") }
508
+ it("indicates it was previously undefined") { expect(const).not_to be_previously_defined }
509
+ it("indicates it has not been mutated") { expect(const).not_to be_mutated }
510
+ it("indicates it has not not been stubbed") { expect(const).not_to be_stubbed }
511
+ it("indicates it has not been hidden") { expect(const).not_to be_hidden }
512
+ it("returns nil for the original value") { expect(const.original_value).to be_nil }
513
+ end
514
+
491
515
  context 'for a previously defined hidden constant' do
492
516
  before { hide_const("TestClass::M") }
493
517
  let(:const) { Constant.original("TestClass::M") }
@@ -516,4 +540,3 @@ module RSpec
516
540
  end
517
541
  end
518
542
  end
519
-
@@ -1,14 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
- def remove_last_describe_from_world
4
- RSpec::world.example_groups.pop
5
- end
6
-
7
- def empty_example_group
8
- RSpec::Core::ExampleGroup.describe(Object, 'Empty Behaviour Group') { }
9
- remove_last_describe_from_world
10
- end
11
-
12
3
  module RSpec
13
4
  module Mocks
14
5
  describe "an expectation set on nil" do
@@ -44,18 +35,12 @@ module RSpec
44
35
 
45
36
  describe "#allow_message_expectations_on_nil" do
46
37
  it "does not affect subsequent examples" do
47
- example_group = ::RSpec::Core::ExampleGroup.describe
48
- reporter = ::RSpec.configuration.reporter
49
- example_group.it("when called in one example that doesn't end up setting an expectation on nil") do
50
- allow_message_expectations_on_nil
51
- end
52
- example_group.it("should not effect the next example ran") do
53
- Kernel.should_receive(:warn)
54
- nil.should_receive(:foo)
55
- nil.foo
56
- end
57
-
58
- expect(example_group.run reporter).to eq true
38
+ allow_message_expectations_on_nil
39
+ RSpec::Mocks.teardown
40
+ RSpec::Mocks.setup
41
+ Kernel.should_receive(:warn)
42
+ nil.should_receive(:foo)
43
+ nil.foo
59
44
  end
60
45
 
61
46
  it 'doesnt error when marshalled' do
@@ -65,4 +50,3 @@ module RSpec
65
50
  end
66
51
  end
67
52
  end
68
-