rspec-mocks 3.0.0.beta1 → 3.0.0.beta2

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 (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
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Mocks
3
3
  module Version
4
- STRING = '3.0.0.beta1'
4
+ STRING = '3.0.0.beta2'
5
5
  end
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'delegate'
3
3
 
4
4
  describe "and_call_original" do
5
- context "on a partial mock object" do
5
+ context "on a partial double" do
6
6
  let(:klass) do
7
7
  Class.new do
8
8
  def meth_1
@@ -21,6 +21,28 @@ describe "and_call_original" do
21
21
 
22
22
  let(:instance) { klass.new }
23
23
 
24
+ context "when a method that exists has been stubbed previously" do
25
+ before { allow(instance).to receive(:meth_1).and_return(:override) }
26
+
27
+ it 'restores the original behavior' do
28
+ expect {
29
+ allow(instance).to receive(:meth_1).and_call_original
30
+ }.to change(instance, :meth_1).from(:override).to(:original)
31
+ end
32
+ end
33
+
34
+ context "when a non-existant method has been stubbed previously" do
35
+ it 'restores the original NameError behavior' do
36
+ expect { instance.abcd }.to raise_error(NameError).with_message(/abcd/)
37
+
38
+ allow(instance).to receive(:abcd).and_return(:override)
39
+ expect(instance.abcd).to eq(:override)
40
+
41
+ allow(instance).to receive(:abcd).and_call_original
42
+ expect { instance.abcd }.to raise_error(NameError).with_message(/abcd/)
43
+ end
44
+ end
45
+
24
46
  it 'passes the received message through to the original method' do
25
47
  expect(instance).to receive(:meth_1).and_call_original
26
48
  expect(instance.meth_1).to eq(:original)
@@ -47,7 +69,7 @@ describe "and_call_original" do
47
69
  end
48
70
 
49
71
  it 'warns when you override an existing implementation' do
50
- expect(RSpec).to receive(:warning).with(/overriding a previous implementation/)
72
+ expect(RSpec).to receive(:warning).with(/overriding a previous stub implementation of `meth_1`.*#{__FILE__}:#{__LINE__ + 1}/)
51
73
  expect(instance).to receive(:meth_1) { true }.and_call_original
52
74
  instance.meth_1
53
75
  end
@@ -200,7 +222,7 @@ describe "and_call_original" do
200
222
  end
201
223
  end
202
224
 
203
- context "on a partial mock object that overrides #method" do
225
+ context "on a partial double that overrides #method" do
204
226
  let(:request_klass) do
205
227
  Struct.new(:method, :url) do
206
228
  def perform
@@ -230,18 +252,17 @@ describe "and_call_original" do
230
252
  end
231
253
  end
232
254
 
233
- context "on a pure mock object" do
255
+ context "on a pure test double" do
234
256
  let(:instance) { double }
235
257
 
236
- it 'raises an error even if the mock object responds to the message' do
258
+ it 'raises an error even if the double object responds to the message' do
237
259
  expect(instance.to_s).to be_a(String)
238
260
  mock_expectation = instance.should_receive(:to_s)
239
261
  instance.to_s # to satisfy the expectation
240
262
 
241
263
  expect {
242
264
  mock_expectation.and_call_original
243
- }.to raise_error(/and_call_original.*partial mock/i)
265
+ }.to raise_error(/pure test double.*and_call_original.*partial double/i)
244
266
  end
245
267
  end
246
268
  end
247
-
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ module RSpec
4
+ module Mocks
5
+ describe 'and_return' do
6
+ let(:obj) { double('obj') }
7
+
8
+ context 'when a block is passed' do
9
+ it 'raises ArgumentError' do
10
+ expect {
11
+ obj.stub(:foo).and_return('bar') { 'baz' }
12
+ }.to raise_error(ArgumentError, /implementation block/i)
13
+ end
14
+ end
15
+
16
+ context 'when no argument is passed' do
17
+ it 'raises ArgumentError' do
18
+ expect { obj.stub(:foo).and_return }.to raise_error(ArgumentError)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RSpec::Mocks::Mock do
3
+ describe RSpec::Mocks::Double do
4
4
 
5
5
  let(:obj) { double }
6
6
 
@@ -124,4 +124,3 @@ describe RSpec::Mocks::Mock do
124
124
  end
125
125
  end
126
126
  end
127
-
@@ -97,6 +97,9 @@ module RSpec
97
97
  end
98
98
 
99
99
  context "behaves as 'every instance'" do
100
+ let(:super_class) { Class.new { def foo; 'bar'; end } }
101
+ let(:sub_class) { Class.new(super_class) }
102
+
100
103
  it "stubs every instance in the spec" do
101
104
  klass.any_instance.stub(:foo).and_return(result = Object.new)
102
105
  expect(klass.new.foo).to eq(result)
@@ -115,6 +118,19 @@ module RSpec
115
118
  foo = 'foo'.freeze
116
119
  expect(foo.dup.concat 'bar').to eq 'foobar'
117
120
  end
121
+
122
+ it 'handles stubbing on super and subclasses' do
123
+ super_class.any_instance.stub(:foo)
124
+ sub_class.any_instance.stub(:foo).and_return('baz')
125
+ expect(sub_class.new.foo).to eq('baz')
126
+ end
127
+
128
+ it 'handles method restoration on subclasses' do
129
+ super_class.any_instance.stub(:foo)
130
+ sub_class.any_instance.stub(:foo)
131
+ sub_class.any_instance.unstub(:foo)
132
+ expect(sub_class.new.foo).to eq("bar")
133
+ end
118
134
  end
119
135
 
120
136
  context "with argument matching" do
@@ -233,10 +249,10 @@ module RSpec
233
249
 
234
250
  # Simply resetting the proxy doesn't work
235
251
  # what we need to have happen is
236
- # ::RSpec::Mocks.any_instance_recorder_for(klass).stop_all_observation!
252
+ # ::RSpec::Mocks.space.any_instance_recorder_for(klass).stop_all_observation!
237
253
  # but that is never invoked in ::
238
254
  expect {
239
- RSpec::Mocks.space.verify_all
255
+ verify_all
240
256
  }.to(
241
257
  change { obj.existing_method }.from("stubbed value").to(:existing_method_return_value)
242
258
  )
@@ -376,7 +392,7 @@ module RSpec
376
392
  klass.any_instance.should_receive(:foo)
377
393
  klass.any_instance.should_not_receive(:bar)
378
394
  klass.new.foo
379
- RSpec::Mocks.space.verify_all
395
+ verify_all
380
396
  end
381
397
  end
382
398
 
@@ -401,14 +417,14 @@ module RSpec
401
417
  expect do
402
418
  klass.any_instance.should_receive(:foo)
403
419
  klass.new
404
- RSpec::Mocks.space.verify_all
420
+ verify_all
405
421
  end.to raise_error(RSpec::Mocks::MockExpectationError, foo_expectation_error_message)
406
422
  end
407
423
 
408
424
  it "fails if no instance is created" do
409
425
  expect do
410
426
  klass.any_instance.should_receive(:foo).and_return(1)
411
- RSpec::Mocks.space.verify_all
427
+ verify_all
412
428
  end.to raise_error(RSpec::Mocks::MockExpectationError, foo_expectation_error_message)
413
429
  end
414
430
 
@@ -416,7 +432,7 @@ module RSpec
416
432
  expect do
417
433
  klass.any_instance.should_receive(:foo)
418
434
  klass.any_instance.should_receive(:bar)
419
- RSpec::Mocks.space.verify_all
435
+ verify_all
420
436
  end.to raise_error(RSpec::Mocks::MockExpectationError, 'Exactly one instance should have received the following message(s) but didn\'t: bar, foo')
421
437
  end
422
438
 
@@ -454,7 +470,7 @@ module RSpec
454
470
  klass.any_instance.should_receive(:foo)
455
471
  klass.should_receive(:woot)
456
472
  klass.new.foo
457
- RSpec::Mocks.space.verify_all
473
+ verify_all
458
474
  end.to(raise_error(RSpec::Mocks::MockExpectationError) do |error|
459
475
  expect(error.message).not_to eq(existing_method_expectation_error_message)
460
476
  end)
@@ -480,14 +496,14 @@ module RSpec
480
496
  expect do
481
497
  klass.any_instance.should_receive(:existing_method)
482
498
  klass.new
483
- RSpec::Mocks.space.verify_all
499
+ verify_all
484
500
  end.to raise_error(RSpec::Mocks::MockExpectationError, existing_method_expectation_error_message)
485
501
  end
486
502
 
487
503
  it "fails if no instance is created" do
488
504
  expect do
489
505
  klass.any_instance.should_receive(:existing_method)
490
- RSpec::Mocks.space.verify_all
506
+ verify_all
491
507
  end.to raise_error(RSpec::Mocks::MockExpectationError, existing_method_expectation_error_message)
492
508
  end
493
509
 
@@ -495,7 +511,7 @@ module RSpec
495
511
  expect do
496
512
  klass.any_instance.should_receive(:existing_method)
497
513
  klass.any_instance.should_receive(:another_existing_method)
498
- RSpec::Mocks.space.verify_all
514
+ verify_all
499
515
  end.to raise_error(RSpec::Mocks::MockExpectationError, 'Exactly one instance should have received the following message(s) but didn\'t: another_existing_method, existing_method')
500
516
  end
501
517
 
@@ -589,7 +605,7 @@ module RSpec
589
605
  it "fails when no instances are declared" do
590
606
  expect do
591
607
  klass.any_instance.should_receive(:foo).once
592
- RSpec::Mocks.space.verify_all
608
+ verify_all
593
609
  end.to raise_error(RSpec::Mocks::MockExpectationError, foo_expectation_error_message)
594
610
  end
595
611
 
@@ -597,7 +613,7 @@ module RSpec
597
613
  expect do
598
614
  klass.any_instance.should_receive(:foo).once
599
615
  klass.new
600
- RSpec::Mocks.space.verify_all
616
+ verify_all
601
617
  end.to raise_error(RSpec::Mocks::MockExpectationError, foo_expectation_error_message)
602
618
  end
603
619
 
@@ -703,7 +719,7 @@ module RSpec
703
719
  context "the 'never' constraint" do
704
720
  it "passes for 0 invocations" do
705
721
  klass.any_instance.should_receive(:foo).never
706
- RSpec::Mocks.space.verify_all
722
+ verify_all
707
723
  end
708
724
 
709
725
  it "fails on the first invocation" do
@@ -724,7 +740,7 @@ module RSpec
724
740
  expect do
725
741
  klass.any_instance.should_receive(:foo).never
726
742
  klass.any_instance.should_receive(:existing_method).and_return(5)
727
- RSpec::Mocks.space.verify_all
743
+ verify_all
728
744
  end.to raise_error(RSpec::Mocks::MockExpectationError, existing_method_expectation_error_message)
729
745
  end
730
746
  end
@@ -858,7 +874,7 @@ module RSpec
858
874
  klass.any_instance.stub(:existing_method).and_return(false)
859
875
  klass.any_instance.stub(:existing_method).and_return(true)
860
876
 
861
- RSpec::Mocks.space.verify_all
877
+ verify_all
862
878
  expect(klass.new).to respond_to(:existing_method)
863
879
  expect(klass.new.existing_method).to eq(existing_method_return_value)
864
880
  end
@@ -952,7 +968,7 @@ module RSpec
952
968
 
953
969
  context 'when used in conjunction with a `dup`' do
954
970
  it "doesn't cause an infinite loop" do
955
- pending "This intermittently fails on JRuby" if RUBY_PLATFORM == 'java'
971
+ skip "This intermittently fails on JRuby" if RUBY_PLATFORM == 'java'
956
972
 
957
973
  Object.any_instance.stub(:some_method)
958
974
  o = Object.new
@@ -1019,7 +1035,7 @@ module RSpec
1019
1035
  instance = klass.new
1020
1036
  expect(instance.existing_method).to eq :stubbed_return_value
1021
1037
 
1022
- RSpec::Mocks.verify
1038
+ verify_all
1023
1039
 
1024
1040
  expect(instance.existing_method).to eq :existing_method_return_value
1025
1041
  end
@@ -10,29 +10,29 @@ module RSpec
10
10
 
11
11
  context "passing" do
12
12
  it "matches the same array" do
13
- expect(array_including(1, 2, 3)).to eq([1, 2, 3])
13
+ expect(array_including(1, 2, 3)).to be === [1, 2, 3]
14
14
  end
15
15
 
16
16
  it "matches the same array, specified without square brackets" do
17
- expect(array_including(1, 2, 3)).to eq([1, 2, 3])
17
+ expect(array_including(1, 2, 3)).to be === [1, 2, 3]
18
18
  end
19
19
 
20
20
  it "matches the same array, which includes nested arrays" do
21
- expect(array_including([1, 2], 3, 4)).to eq([[1, 2], 3, 4])
21
+ expect(array_including([1, 2], 3, 4)).to be === [[1, 2], 3, 4]
22
22
  end
23
23
 
24
24
  it "works with duplicates in expected" do
25
- expect(array_including(1, 1, 2, 3)).to eq([1, 2, 3])
25
+ expect(array_including(1, 1, 2, 3)).to be === [1, 2, 3]
26
26
  end
27
27
 
28
28
  it "works with duplicates in actual" do
29
- expect(array_including(1, 2, 3)).to eq([1, 1, 2, 3])
29
+ expect(array_including(1, 2, 3)).to be === [1, 1, 2, 3]
30
30
  end
31
31
  end
32
32
 
33
33
  context "failing" do
34
34
  it "fails when not all the entries in the expected are present" do
35
- expect(array_including(1,2,3,4,5)).not_to eq([1,2])
35
+ expect(array_including(1,2,3,4,5)).not_to be === [1,2]
36
36
  end
37
37
  end
38
38
  end
@@ -0,0 +1,132 @@
1
+ require "spec_helper"
2
+
3
+ describe "Using rspec-mocks features in before(:all) blocks" do
4
+ shared_examples_for "fails in a before(:all) block" do
5
+ the_error = nil
6
+ before(:all) do
7
+ begin
8
+ use_rspec_mocks
9
+ rescue
10
+ the_error = $!
11
+ end
12
+ end
13
+
14
+ it "raises an error with a useful message" do
15
+ expect(the_error).to be_a_kind_of(RSpec::Mocks::OutsideOfExampleError)
16
+
17
+ expect(the_error.message).to match(/The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported./)
18
+ end
19
+ end
20
+
21
+ describe "#stub_const" do
22
+ include_examples "fails in a before(:all) block" do
23
+ def use_rspec_mocks
24
+ stub_const("SomeNewConst", Class.new)
25
+ end
26
+
27
+ it 'does not stub the const' do
28
+ expect(defined?(SomeNewConst)).to be_falsey
29
+ end
30
+ end
31
+ end
32
+
33
+ describe "#hide_const(for an undefined const)" do
34
+ include_examples "fails in a before(:all) block" do
35
+ def use_rspec_mocks
36
+ hide_const("Foo")
37
+ end
38
+ end
39
+ end
40
+
41
+ describe "#hide_const(for a defined const)" do
42
+ include_examples "fails in a before(:all) block" do
43
+ def use_rspec_mocks
44
+ hide_const("Float")
45
+ end
46
+
47
+ it 'does not hide the const' do
48
+ expect(defined?(Float)).to be_truthy
49
+ end
50
+ end
51
+ end
52
+
53
+ describe "#stub" do
54
+ include_examples "fails in a before(:all) block" do
55
+ def use_rspec_mocks
56
+ Object.stub(:foo)
57
+ end
58
+ end
59
+ end
60
+
61
+ describe "#unstub" do
62
+ include_examples "fails in a before(:all) block" do
63
+ def use_rspec_mocks
64
+ Object.unstub(:foo)
65
+ end
66
+ end
67
+ end
68
+
69
+ describe "#should_receive" do
70
+ include_examples "fails in a before(:all) block" do
71
+ def use_rspec_mocks
72
+ Object.should_receive(:foo)
73
+ end
74
+ end
75
+ end
76
+
77
+ describe "#should_not_receive" do
78
+ include_examples "fails in a before(:all) block" do
79
+ def use_rspec_mocks
80
+ Object.should_not_receive(:foo)
81
+ end
82
+ end
83
+ end
84
+
85
+ describe "#any_instance" do
86
+ include_examples "fails in a before(:all) block" do
87
+ def use_rspec_mocks
88
+ Object.any_instance.should_receive(:foo)
89
+ end
90
+ end
91
+ end
92
+
93
+ describe "#stub_chain" do
94
+ include_examples "fails in a before(:all) block" do
95
+ def use_rspec_mocks
96
+ Object.stub_chain(:foo)
97
+ end
98
+ end
99
+ end
100
+
101
+ describe "#expect(...).to receive" do
102
+ include_examples "fails in a before(:all) block" do
103
+ def use_rspec_mocks
104
+ expect(Object).to receive(:foo)
105
+ end
106
+ end
107
+ end
108
+
109
+ describe "#allow(...).to receive" do
110
+ include_examples "fails in a before(:all) block" do
111
+ def use_rspec_mocks
112
+ allow(Object).to receive(:foo)
113
+ end
114
+ end
115
+ end
116
+
117
+ describe "#expect_any_instance_of(...).to receive" do
118
+ include_examples "fails in a before(:all) block" do
119
+ def use_rspec_mocks
120
+ expect_any_instance_of(Object).to receive(:foo)
121
+ end
122
+ end
123
+ end
124
+
125
+ describe "#allow_any_instance_of(...).to receive" do
126
+ include_examples "fails in a before(:all) block" do
127
+ def use_rspec_mocks
128
+ allow_any_instance_of(Object).to receive(:foo)
129
+ end
130
+ end
131
+ end
132
+ end