Skip to content

Commit

Permalink
Merge pull request #1581 from rspec/fix-ruby-head
Browse files Browse the repository at this point in the history
Fix build for Ruby 3.4.0 preview 1
  • Loading branch information
JonRowe authored Jul 14, 2024
2 parents d7cc042 + 9996096 commit fe4d292
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/rspec/mocks/message_expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class MessageExpectation
# counter.count # => 3
# counter.count # => 3
# # etc
def and_return(first_value, *values)
def and_return(first_value, *values, &_block)
raise_already_invoked_error_if_necessary(__method__)
if negative?
raise "`and_return` is not supported with negative message expectations"
Expand Down Expand Up @@ -106,7 +106,7 @@ def and_return(first_value, *values)
# api.get_foo # => :a_foo
# api.get_foo # => :a_foo
# # etc
def and_invoke(first_proc, *procs)
def and_invoke(first_proc, *procs, &_block)
raise_already_invoked_error_if_necessary(__method__)
if negative?
raise "`and_invoke` is not supported with negative message expectations"
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/mocks/syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def receive(method_name, &block)
Matchers::Receive.new(method_name, block)
end

def receive_messages(message_return_value_hash)
def receive_messages(message_return_value_hash, &_block)
matcher = Matchers::ReceiveMessages.new(message_return_value_hash)
matcher.warn_about_block if block_given?
matcher
Expand Down
4 changes: 2 additions & 2 deletions spec/rspec/mocks/stub_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ def existing_private_instance_method

it "remains private when it stubs a private instance method" do
allow(@instance).to receive(:existing_private_instance_method).and_return(1)
expect { @instance.existing_private_instance_method }.to raise_error NoMethodError, /private method `existing_private_instance_method/
expect { @instance.existing_private_instance_method }.to raise_error NoMethodError, /private method [`']existing_private_instance_method/
end

it "remains private when it stubs a private class method" do
allow(@class).to receive(:existing_private_class_method).and_return(1)
expect { @class.existing_private_class_method }.to raise_error NoMethodError, /private method `existing_private_class_method/
expect { @class.existing_private_class_method }.to raise_error NoMethodError, /private method [`']existing_private_class_method/
end

context "using `with`" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def use; end
it 'can mock private module methods' do
double = Module.new
allow(double).to receive(:use)
expect { double.use }.to raise_error(/private method `use' called/)
expect { double.use }.to raise_error(/private method [`']use' called/)

double = class_double("NonloadedClass")
expect(double).to receive(:use).and_return(:ok)
Expand Down

0 comments on commit fe4d292

Please sign in to comment.