rspec-mocks 2.99.4 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +14 -6
  2. checksums.yaml.gz.sig +2 -0
  3. data.tar.gz.sig +1 -0
  4. data/Changelog.md +89 -105
  5. data/License.txt +1 -0
  6. data/README.md +77 -57
  7. data/features/argument_matchers/explicit.feature +5 -5
  8. data/features/argument_matchers/general_matchers.feature +10 -10
  9. data/features/argument_matchers/type_matchers.feature +3 -3
  10. data/features/message_expectations/allow_any_instance_of.feature +1 -1
  11. data/features/message_expectations/any_instance.feature +27 -5
  12. data/features/message_expectations/call_original.feature +2 -2
  13. data/features/message_expectations/expect_message_using_expect.feature +2 -2
  14. data/features/message_expectations/expect_message_using_should_receive.feature +2 -2
  15. data/features/message_expectations/receive_counts.feature +7 -7
  16. data/features/message_expectations/warn_when_expectation_is_set_on_nil.feature +3 -3
  17. data/features/method_stubs/README.md +3 -0
  18. data/features/method_stubs/any_instance.feature +11 -11
  19. data/features/method_stubs/as_null_object.feature +4 -4
  20. data/features/method_stubs/simple_return_value_with_stub.feature +7 -7
  21. data/features/method_stubs/stub_chain.feature +3 -3
  22. data/features/method_stubs/stub_implementation.feature +2 -2
  23. data/features/method_stubs/to_ary.feature +2 -2
  24. data/features/mutating_constants/hiding_defined_constant.feature +2 -2
  25. data/features/mutating_constants/stub_defined_constant.feature +5 -5
  26. data/features/mutating_constants/stub_undefined_constant.feature +6 -6
  27. data/features/outside_rspec/configuration.feature +0 -2
  28. data/features/outside_rspec/standalone.feature +1 -1
  29. data/features/spies/spy_partial_mock_method.feature +2 -2
  30. data/features/spies/spy_pure_mock_method.feature +5 -5
  31. data/features/spies/spy_unstubbed_method.feature +1 -1
  32. data/features/support/env.rb +10 -1
  33. data/features/test_frameworks/test_unit.feature +1 -1
  34. data/features/verifying_doubles/class_doubles.feature +88 -0
  35. data/features/verifying_doubles/dynamic_classes.feature +72 -0
  36. data/features/verifying_doubles/introduction.feature +85 -0
  37. data/features/verifying_doubles/object_doubles.feature +65 -0
  38. data/features/verifying_doubles/partial_doubles.feature +34 -0
  39. data/lib/rspec/mocks.rb +8 -34
  40. data/lib/rspec/mocks/any_instance/chain.rb +4 -34
  41. data/lib/rspec/mocks/any_instance/expectation_chain.rb +14 -4
  42. data/lib/rspec/mocks/any_instance/message_chains.rb +27 -12
  43. data/lib/rspec/mocks/any_instance/recorder.rb +23 -31
  44. data/lib/rspec/mocks/any_instance/stub_chain.rb +9 -4
  45. data/lib/rspec/mocks/argument_list_matcher.rb +8 -1
  46. data/lib/rspec/mocks/argument_matchers.rb +26 -12
  47. data/lib/rspec/mocks/arity_calculator.rb +66 -0
  48. data/lib/rspec/mocks/configuration.rb +42 -14
  49. data/lib/rspec/mocks/error_generator.rb +34 -10
  50. data/lib/rspec/mocks/example_methods.rb +64 -19
  51. data/lib/rspec/mocks/extensions/marshal.rb +0 -15
  52. data/lib/rspec/mocks/framework.rb +4 -4
  53. data/lib/rspec/mocks/instance_method_stasher.rb +80 -62
  54. data/lib/rspec/mocks/matchers/have_received.rb +18 -14
  55. data/lib/rspec/mocks/matchers/receive.rb +29 -7
  56. data/lib/rspec/mocks/matchers/receive_messages.rb +72 -0
  57. data/lib/rspec/mocks/message_expectation.rb +95 -148
  58. data/lib/rspec/mocks/method_double.rb +77 -139
  59. data/lib/rspec/mocks/method_reference.rb +95 -0
  60. data/lib/rspec/mocks/mock.rb +1 -1
  61. data/lib/rspec/mocks/mutate_const.rb +12 -9
  62. data/lib/rspec/mocks/object_reference.rb +90 -0
  63. data/lib/rspec/mocks/order_group.rb +49 -7
  64. data/lib/rspec/mocks/proxy.rb +72 -33
  65. data/lib/rspec/mocks/proxy_for_nil.rb +2 -2
  66. data/lib/rspec/mocks/space.rb +13 -18
  67. data/lib/rspec/mocks/stub_chain.rb +2 -2
  68. data/lib/rspec/mocks/syntax.rb +61 -36
  69. data/lib/rspec/mocks/targets.rb +40 -19
  70. data/lib/rspec/mocks/test_double.rb +12 -56
  71. data/lib/rspec/mocks/verifying_double.rb +77 -0
  72. data/lib/rspec/mocks/verifying_message_expecation.rb +60 -0
  73. data/lib/rspec/mocks/verifying_proxy.rb +151 -0
  74. data/lib/rspec/mocks/version.rb +1 -1
  75. data/spec/rspec/mocks/and_call_original_spec.rb +34 -30
  76. data/spec/rspec/mocks/and_yield_spec.rb +2 -2
  77. data/spec/rspec/mocks/any_instance/message_chains_spec.rb +1 -1
  78. data/spec/rspec/mocks/any_instance_spec.rb +53 -260
  79. data/spec/rspec/mocks/argument_expectation_spec.rb +4 -4
  80. data/spec/rspec/mocks/arity_calculator_spec.rb +95 -0
  81. data/spec/rspec/mocks/array_including_matcher_spec.rb +41 -0
  82. data/spec/rspec/mocks/at_least_spec.rb +4 -32
  83. data/spec/rspec/mocks/block_return_value_spec.rb +4 -135
  84. data/spec/rspec/mocks/combining_implementation_instructions_spec.rb +10 -11
  85. data/spec/rspec/mocks/configuration_spec.rb +79 -0
  86. data/spec/rspec/mocks/double_spec.rb +10 -78
  87. data/spec/rspec/mocks/extensions/marshal_spec.rb +0 -8
  88. data/spec/rspec/mocks/failing_argument_matchers_spec.rb +49 -4
  89. data/spec/rspec/mocks/instance_method_stasher_spec.rb +20 -3
  90. data/spec/rspec/mocks/matchers/have_received_spec.rb +74 -0
  91. data/spec/rspec/mocks/matchers/receive_messages_spec.rb +140 -0
  92. data/spec/rspec/mocks/matchers/receive_spec.rb +82 -42
  93. data/spec/rspec/mocks/methods_spec.rb +1 -1
  94. data/spec/rspec/mocks/{bug_report_830_spec.rb → mock_expectation_error_spec.rb} +4 -3
  95. data/spec/rspec/mocks/mock_ordering_spec.rb +11 -0
  96. data/spec/rspec/mocks/mock_space_spec.rb +10 -1
  97. data/spec/rspec/mocks/mock_spec.rb +26 -82
  98. data/spec/rspec/mocks/multiple_return_value_spec.rb +1 -1
  99. data/spec/rspec/mocks/mutate_const_spec.rb +18 -5
  100. data/spec/rspec/mocks/null_object_mock_spec.rb +6 -4
  101. data/spec/rspec/mocks/options_hash_spec.rb +3 -3
  102. data/spec/rspec/mocks/order_group_spec.rb +27 -0
  103. data/spec/rspec/mocks/partial_mock_spec.rb +101 -1
  104. data/spec/rspec/mocks/passing_argument_matchers_spec.rb +3 -20
  105. data/spec/rspec/mocks/record_messages_spec.rb +4 -4
  106. data/spec/rspec/mocks/serialization_spec.rb +4 -6
  107. data/spec/rspec/mocks/space_spec.rb +3 -3
  108. data/spec/rspec/mocks/stub_chain_spec.rb +0 -12
  109. data/spec/rspec/mocks/stub_spec.rb +23 -44
  110. data/spec/rspec/mocks/test_double_spec.rb +3 -22
  111. data/spec/rspec/mocks/verifying_double_spec.rb +327 -0
  112. data/spec/rspec/mocks/verifying_message_expecation_spec.rb +68 -0
  113. data/spec/rspec/mocks_spec.rb +16 -39
  114. data/spec/spec_helper.rb +29 -18
  115. metadata +131 -86
  116. metadata.gz.sig +1 -0
  117. data/features/message_expectations/expect_any_instance_of.feature +0 -27
  118. data/lib/rspec/mocks/caller_filter.rb +0 -60
  119. data/lib/rspec/mocks/deprecation.rb +0 -26
  120. data/lib/rspec/mocks/extensions/instance_exec.rb +0 -34
  121. data/lib/rspec/mocks/extensions/proc.rb +0 -63
  122. data/lib/spec/mocks.rb +0 -4
  123. data/spec/rspec/mocks/and_return_spec.rb +0 -17
  124. data/spec/rspec/mocks/any_number_of_times_spec.rb +0 -36
  125. data/spec/rspec/mocks/before_all_spec.rb +0 -74
  126. data/spec/rspec/mocks/bug_report_10260_spec.rb +0 -8
  127. data/spec/rspec/mocks/bug_report_10263_spec.rb +0 -27
  128. data/spec/rspec/mocks/bug_report_11545_spec.rb +0 -32
  129. data/spec/rspec/mocks/bug_report_496_spec.rb +0 -17
  130. data/spec/rspec/mocks/bug_report_600_spec.rb +0 -22
  131. data/spec/rspec/mocks/bug_report_7611_spec.rb +0 -16
  132. data/spec/rspec/mocks/bug_report_8165_spec.rb +0 -31
  133. data/spec/rspec/mocks/bug_report_957_spec.rb +0 -22
@@ -9,23 +9,23 @@ module RSpec
9
9
  it "considers an object that responds to #matches? and #failure_message_for_should to be a matcher" do
10
10
  obj.stub(:matches?)
11
11
  obj.stub(:failure_message_for_should)
12
- expect(argument_expectation.send(:is_matcher?, obj)).to be true
12
+ expect(argument_expectation.send(:is_matcher?, obj)).to be_truthy
13
13
  end
14
14
 
15
15
  it "considers an object that responds to #matches? and #failure_message to be a matcher for backward compatibility" do
16
16
  obj.stub(:matches?)
17
17
  obj.stub(:failure_message)
18
- expect(argument_expectation.send(:is_matcher?, obj)).to be true
18
+ expect(argument_expectation.send(:is_matcher?, obj)).to be_truthy
19
19
  end
20
20
 
21
21
  it "does NOT consider an object that only responds to #matches? to be a matcher" do
22
22
  obj.stub(:matches?)
23
- expect(argument_expectation.send(:is_matcher?, obj)).to be false
23
+ expect(argument_expectation.send(:is_matcher?, obj)).to be_falsey
24
24
  end
25
25
 
26
26
  it "does not consider a null object to be a matcher" do
27
27
  obj.as_null_object
28
- expect(argument_expectation.send(:is_matcher?, obj)).to be false
28
+ expect(argument_expectation.send(:is_matcher?, obj)).to be_falsey
29
29
  end
30
30
  end
31
31
  end
@@ -0,0 +1,95 @@
1
+ require 'spec_helper'
2
+
3
+ module RSpec
4
+ module Mocks
5
+ describe ArityCalculator do
6
+ describe '#verify!' do
7
+ subject { described_class.new(test_method) }
8
+
9
+ def within_range?(arity)
10
+ subject.within_range?(arity)
11
+ end
12
+
13
+ def description
14
+ subject.range_description
15
+ end
16
+
17
+ describe 'with a method with arguments' do
18
+ def arity_two(x, y); end
19
+
20
+ let(:test_method) { method(:arity_two) }
21
+
22
+ it 'covers only the exact arity' do
23
+ expect(within_range?(1)).to eq(false)
24
+ expect(within_range?(2)).to eq(true)
25
+ expect(within_range?(3)).to eq(false)
26
+ end
27
+
28
+ it 'is described precisely' do
29
+ expect(description).to eq("2")
30
+ end
31
+ end
32
+
33
+ describe 'a method with splat arguments' do
34
+ def arity_splat(_, *); end
35
+
36
+ let(:test_method) { method(:arity_splat) }
37
+
38
+ it 'covers a range from the lower bound upwards' do
39
+ expect(within_range?(0)).to eq(false)
40
+ expect(within_range?(1)).to eq(true)
41
+ expect(within_range?(2)).to eq(true)
42
+ expect(within_range?(3)).to eq(true)
43
+ end
44
+
45
+ it 'is described with no upper bound' do
46
+ expect(description).to eq("1 or more")
47
+ end
48
+ end
49
+
50
+ describe 'a method with optional arguments' do
51
+ def arity_optional(x, y, z = 1); end
52
+
53
+ let(:test_method) { method(:arity_optional) }
54
+
55
+ it 'covers a range from min to max possible arguments' do
56
+ expect(within_range?(1)).to eq(false)
57
+ expect(within_range?(2)).to eq(true)
58
+ expect(within_range?(3)).to eq(true)
59
+
60
+ if ArityCalculator.supports_optional_and_splat_args?
61
+ expect(within_range?(4)).to eq(false)
62
+ else
63
+ expect(within_range?(4)).to eq(true)
64
+ end
65
+ end
66
+
67
+ if ArityCalculator.supports_optional_and_splat_args?
68
+ it 'is described as a range' do
69
+ expect(description).to eq("2 to 3")
70
+ end
71
+ else
72
+ it 'is described with no upper bound' do
73
+ expect(description).to eq("2 or more")
74
+ end
75
+ end
76
+ end
77
+
78
+ describe 'a method with a block' do
79
+ def arity_block(_, &block); end
80
+
81
+ let(:test_method) { method(:arity_block) }
82
+
83
+ it 'does not count the block as a parameter' do
84
+ expect(within_range?(1)).to eq(true)
85
+ expect(within_range?(2)).to eq(false)
86
+ end
87
+
88
+ it 'is described precisely' do
89
+ expect(description).to eq("1")
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ module RSpec
4
+ module Mocks
5
+ module ArgumentMatchers
6
+ describe ArrayIncludingMatcher do
7
+ it "describes itself properly" do
8
+ expect(ArrayIncludingMatcher.new([1, 2, 3]).description).to eq "array_including(1,2,3)"
9
+ end
10
+
11
+ context "passing" do
12
+ it "matches the same array" do
13
+ expect(array_including(1, 2, 3)).to eq([1, 2, 3])
14
+ end
15
+
16
+ it "matches the same array, specified without square brackets" do
17
+ expect(array_including(1, 2, 3)).to eq([1, 2, 3])
18
+ end
19
+
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])
22
+ end
23
+
24
+ it "works with duplicates in expected" do
25
+ expect(array_including(1, 1, 2, 3)).to eq([1, 2, 3])
26
+ end
27
+
28
+ it "works with duplicates in actual" do
29
+ expect(array_including(1, 2, 3)).to eq([1, 1, 2, 3])
30
+ end
31
+ end
32
+
33
+ context "failing" do
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])
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -98,38 +98,10 @@ module RSpec
98
98
  end
99
99
 
100
100
  context "when sent with 0" do
101
- before { RSpec.stub(:deprecate) }
102
-
103
- it "outputs a deprecation warning" do
104
- expect(RSpec).to receive(:deprecate).with("at_least\(0\) with should_receive", :replacement => "stub")
105
- expect(@double).to receive(:do_something).at_least(0).times
106
- end
107
-
108
- it "passes with no return if called once" do
109
- @double.should_receive(:do_something).at_least(0).times
110
- @double.do_something
111
- end
112
-
113
- it "passes with return block if called once" do
114
- @double.should_receive(:do_something).at_least(0).times { true }
115
- @double.do_something
116
- end
117
-
118
- it "passes with and_return if called once" do
119
- @double.should_receive(:do_something).at_least(0).times.and_return true
120
- @double.do_something
121
- end
122
-
123
- it "passes with no return if never called" do
124
- @double.should_receive(:do_something).at_least(0).times
125
- end
126
-
127
- it "passes with return block if never called" do
128
- @double.should_receive(:do_something).at_least(0).times { true }
129
- end
130
-
131
- it "passes with and_return if never called" do
132
- @double.should_receive(:do_something).at_least(0).times.and_return true
101
+ it "outputs a removal message" do
102
+ expect {
103
+ expect(@double).to receive(:do_something).at_least(0).times
104
+ }.to raise_error(/has been removed/)
133
105
  end
134
106
  end
135
107
 
@@ -1,17 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "a double declaration with a block handed to:" do
4
- # The "receives a block" part is important: 1.8.7 has a bug that reports the
5
- # wrong arity when a block receives a block.
6
- it 'forwards all given args to the block, even when it receives a block', :unless => RUBY_VERSION.to_s == '1.8.6' do
7
- obj = Object.new
8
- yielded_args = []
9
- eval("obj.stub(:foo) { |*args, &bl| yielded_args << args }")
10
- obj.foo(1, 2, 3)
11
-
12
- expect(yielded_args).to eq([[1, 2, 3]])
13
- end
14
-
15
4
  describe "should_receive" do
16
5
  it "returns the value of executing the block" do
17
6
  obj = Object.new
@@ -34,23 +23,6 @@ describe "a double declaration with a block handed to:" do
34
23
  obj.stub(:foo) { 'bar' }
35
24
  expect(obj.foo).to eq('bar')
36
25
  end
37
-
38
- it "does not complain if a lambda block and mismatched arguments are passed" do
39
- RSpec.stub :deprecate
40
- obj = Object.new
41
- obj.stub(:foo, &lambda { 'bar' })
42
- expect(obj.foo(1, 2)).to eq('bar')
43
- end
44
-
45
- it 'warns of deprection if argument counts dont match' do
46
- expect(RSpec).to receive(:deprecate) do |message, opts|
47
- expect(message).to eq "stubbing implementations with mismatched arity"
48
- expect(opts[:call_site]).to match %r%/spec/rspec/mocks/block_return_value_spec.rb%
49
- end
50
- obj = Object.new
51
- obj.stub(:foo, &lambda { 'bar' })
52
- expect(obj.foo(1, 2)).to eq('bar')
53
- end
54
26
  end
55
27
 
56
28
  describe "with" do
@@ -60,123 +32,20 @@ describe "a double declaration with a block handed to:" do
60
32
  expect(obj.foo('baz')).to eq('bar')
61
33
  end
62
34
 
63
- it "does not complain if a lambda block and mismatched arguments are passed" do
64
- RSpec.stub :deprecate
65
- obj = Object.new
66
- obj.stub(:foo).with(1, 2, &lambda { 'bar' })
67
- expect(obj.foo(1, 2)).to eq('bar')
68
- end
69
-
70
- it 'warns of deprection if argument counts dont match' do
71
- expect(RSpec).to receive(:deprecate) do |message, opts|
72
- expect(message).to eq "stubbing implementations with mismatched arity"
73
- expect(opts[:call_site]).to match %r%/spec/rspec/mocks/block_return_value_spec.rb%
74
- end
75
- obj = Object.new
76
- obj.stub(:foo).with(1, 2, &lambda { 'bar' })
77
- expect(obj.foo(1, 2)).to eq('bar')
78
- end
79
-
80
- it 'warns of deprecation when provided block but no arguments' do
81
- expect(RSpec).to receive(:deprecate) do |message, opts|
82
- expect(message).to match(/Using the return value of a `with` block/)
83
- end
84
- obj = Object.new
85
- obj.stub(:foo).with {|x| 'baz' }.and_return('bar')
86
- expect(obj.foo(1)).to eq('bar')
87
- end
88
-
89
- it 'includes callsite in deprecation of provided block but no arguments' do
35
+ it "returns the value of executing the block with given argument" do
90
36
  obj = Object.new
91
- expect_deprecation_with_call_site __FILE__, __LINE__ + 1
92
- obj.stub(:foo).with {|x| 'baz' }.and_return('bar')
93
- expect(obj.foo(1)).to eq('bar')
37
+ obj.stub(:foo).with('baz') {|x| 'bar' + x }
38
+ expect(obj.foo('baz')).to eq('barbaz')
94
39
  end
95
40
  end
96
41
 
97
- %w[once twice ordered].each do |method|
42
+ %w[once twice ordered and_return].each do |method|
98
43
  describe method do
99
44
  it "returns the value of executing the block" do
100
45
  obj = Object.new
101
46
  obj.stub(:foo).send(method) { 'bar' }
102
47
  expect(obj.foo).to eq('bar')
103
48
  end
104
-
105
- it "does not complain if a lambda block and mismatched arguments are passed" do
106
- RSpec.stub :deprecate
107
- obj = Object.new
108
- obj.stub(:foo).send(method, &lambda { 'bar' })
109
- expect(obj.foo(1, 2)).to eq('bar')
110
- end
111
-
112
- it 'warns of deprection if argument counts dont match' do
113
- expect(RSpec).to receive(:deprecate) do |message, opts|
114
- expect(message).to eq "stubbing implementations with mismatched arity"
115
- expect(opts[:call_site]).to match %r%/spec/rspec/mocks/block_return_value_spec.rb%
116
- end
117
- obj = Object.new
118
- obj.stub(:foo).send(method, &lambda { 'bar' })
119
- expect(obj.foo(1, 2)).to eq('bar')
120
- end
121
- end
122
- end
123
-
124
- describe 'and_return' do
125
- before do
126
- allow_deprecation
127
- end
128
-
129
- it "returns the value of executing the block" do
130
- obj = Object.new
131
- obj.stub(:foo).and_return { 'bar' }
132
- expect(obj.foo).to eq('bar')
133
- end
134
-
135
- it "does not complain if a lambda block and mismatched arguments are passed" do
136
- obj = Object.new
137
- obj.stub(:foo).and_return(&lambda { 'bar' })
138
- expect(obj.foo(1, 2)).to eq('bar')
139
- end
140
-
141
- it 'warns of deprecation of `and_return { value }`' do
142
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 3, '`and_return { value }`')
143
-
144
- obj = Object.new
145
- obj.stub(:foo).and_return { 'bar' }
146
- expect(obj.foo(1, 2)).to eq('bar')
147
- end
148
-
149
- it 'warns of deprection if argument counts dont match' do
150
- warned = false
151
-
152
- expect(RSpec).to receive(:deprecate).at_least(1) do |message, opts|
153
- next unless message == "stubbing implementations with mismatched arity"
154
- expect(opts[:call_site]).to match %r%/spec/rspec/mocks/block_return_value_spec.rb%
155
- warned = true
156
- end
157
-
158
- obj = Object.new
159
- obj.stub(:foo).and_return(&lambda { 'bar' })
160
- expect(obj.foo(1, 2)).to eq('bar')
161
-
162
- expect(warned).to be true
163
- end
164
- end
165
-
166
- describe 'any_number_of_times' do
167
- before do
168
- RSpec.stub(:deprecate)
169
- end
170
-
171
- it "warns about deprecation" do
172
- expect(RSpec).to receive(:deprecate).with("any_number_of_times", :replacement => "stub")
173
- Object.new.stub(:foo).any_number_of_times { 'bar' }
174
- end
175
-
176
- it "returns the value of executing the block" do
177
- obj = Object.new
178
- obj.stub(:foo).any_number_of_times { 'bar' }
179
- expect(obj.foo).to eq('bar')
180
49
  end
181
50
  end
182
51
 
@@ -21,7 +21,7 @@ module RSpec
21
21
  expect(dbl.foo(:arg, &b)).to eq(3)
22
22
  }.to yield_with_args(5)
23
23
 
24
- expect(@block_called).to be true
24
+ expect(@block_called).to be_truthy
25
25
  end
26
26
 
27
27
  it 'works when passing a block to `stub`' do
@@ -60,12 +60,6 @@ module RSpec
60
60
  end
61
61
  end
62
62
 
63
- it 'works when passing a block to `any_number_of_times`', :silence_warnings do
64
- verify_combined_implementation do |dbl|
65
- dbl.should_receive(:foo).any_number_of_times { @block_called = true }
66
- end
67
- end
68
-
69
63
  it 'works when passing a block to `once`' do
70
64
  verify_combined_implementation do |dbl|
71
65
  dbl.should_receive(:foo).once { @block_called = true }
@@ -91,8 +85,6 @@ module RSpec
91
85
  end
92
86
 
93
87
  it 'can combine and_yield and and_return with a block' do
94
- allow_deprecation
95
-
96
88
  dbl = double
97
89
  dbl.stub(:foo).and_yield(5).and_return { :return }
98
90
 
@@ -119,7 +111,7 @@ module RSpec
119
111
  expect { dbl.foo(&b) }.to raise_error("boom")
120
112
  }.to yield_with_args(5)
121
113
 
122
- expect(block_called).to be true
114
+ expect(block_called).to be_truthy
123
115
  end
124
116
 
125
117
  it 'can combine and_yield and and_throw' do
@@ -140,7 +132,7 @@ module RSpec
140
132
  expect { dbl.foo(&b) }.to throw_symbol(:bar)
141
133
  }.to yield_with_args(5)
142
134
 
143
- expect(block_called).to be true
135
+ expect(block_called).to be_truthy
144
136
  end
145
137
 
146
138
  it 'returns `nil` from all terminal actions to discourage further configuration' do
@@ -167,6 +159,7 @@ module RSpec
167
159
  end
168
160
 
169
161
  it 'allows the inner implementation block to be overriden' do
162
+ allow(RSpec).to receive(:warning)
170
163
  dbl = double
171
164
  stubbed_double = dbl.stub(:foo)
172
165
 
@@ -177,6 +170,11 @@ module RSpec
177
170
  expect(dbl.foo(:arg)).to eq(:at_least_block)
178
171
  end
179
172
 
173
+ it 'warns when the inner implementation block is overriden' do
174
+ expect(RSpec).to receive(:warning).with(/overriding a previous implementation/)
175
+ double.stub(:foo).with(:arg) { :with_block }.at_least(:once) { :at_least_block }
176
+ end
177
+
180
178
  it 'can combine and_call_original, with, and_return' do
181
179
  obj = Struct.new(:value).new('original')
182
180
  obj.stub(:value).and_call_original
@@ -186,6 +184,7 @@ module RSpec
186
184
  end
187
185
 
188
186
  it 'raises an error if `and_call_original` is followed by any other instructions' do
187
+ allow(RSpec).to receive(:warning)
189
188
  dbl = [1, 2, 3]
190
189
  stubbed = dbl.stub(:size)
191
190
  stubbed.and_call_original