Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 92b896c

Browse files
jhottensteinpirj
authored andcommitted
Fix jruby test by removing the receiver from the block args
1 parent a03b484 commit 92b896c

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

spec/rspec/mocks/matchers/receive_spec.rb

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,24 @@ module Mocks
2424
receiver.foo(1.1)
2525
end
2626

27-
it 'allows a `do...end` block implementation to be provided' do
28-
wrapped.to receive(:foo) do
29-
4
30-
end
27+
context 'without yielding receiver' do
28+
# when `yield_receiver_to_any_instance_implementation_blocks` is `true`
29+
# the block arguments are different for `expect` and `expect_any_instance_of`
30+
around do |example|
31+
previous_value = RSpec::Mocks.configuration.yield_receiver_to_any_instance_implementation_blocks?
32+
RSpec::Mocks.configuration.yield_receiver_to_any_instance_implementation_blocks = false
33+
example.run
34+
RSpec::Mocks.configuration.yield_receiver_to_any_instance_implementation_blocks = previous_value
35+
end
36+
37+
it 'allows a `do...end` block implementation to be provided' do
38+
wrapped.to receive(:foo) do
39+
4
40+
end
3141

32-
expect(receiver.foo).to eq(4)
33-
end
42+
expect(receiver.foo).to eq(4)
43+
end
3444

35-
if RSpec::Support::RubyFeatures.kw_args_supported?
36-
binding.eval(<<-RUBY, __FILE__, __LINE__)
3745
it 'allows a `do...end` block implementation with keyword args to be provided' do
3846
wrapped.to receive(:foo) do |**kwargs|
3947
kwargs[:kw]
@@ -57,19 +65,14 @@ module Mocks
5765

5866
expect(receiver.foo).to eq(:arg)
5967
end
60-
RUBY
61-
end
6268

63-
if RSpec::Support::RubyFeatures.required_kw_args_supported?
64-
binding.eval(<<-RUBY, __FILE__, __LINE__)
6569
it 'allows a `do...end` block implementation with required keyword args' do
6670
wrapped.to receive(:foo) do |kw:|
6771
kw
6872
end
6973

7074
expect(receiver.foo(kw: :arg)).to eq(:arg)
7175
end
72-
RUBY
7376
end
7477

7578
it 'allows chaining off a `do...end` block implementation to be provided' do

0 commit comments

Comments
 (0)