From 24f34d35976ace4317892a0d06af8c8d0a2ed089 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 14 Jul 2024 09:49:55 +0200 Subject: [PATCH] Merge pull request #1581 from rspec/fix-ruby-head Fix build for Ruby 3.4.0 preview 1 --- lib/rspec/mocks/message_expectation.rb | 4 ++-- lib/rspec/mocks/syntax.rb | 2 +- spec/rspec/mocks/stub_spec.rb | 4 ++-- .../class_double_with_class_not_loaded_spec.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/rspec/mocks/message_expectation.rb b/lib/rspec/mocks/message_expectation.rb index 8b21ae0be..8376a1c7a 100644 --- a/lib/rspec/mocks/message_expectation.rb +++ b/lib/rspec/mocks/message_expectation.rb @@ -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" @@ -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" diff --git a/lib/rspec/mocks/syntax.rb b/lib/rspec/mocks/syntax.rb index 6305ab961..2caabd1a3 100644 --- a/lib/rspec/mocks/syntax.rb +++ b/lib/rspec/mocks/syntax.rb @@ -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 diff --git a/spec/rspec/mocks/stub_spec.rb b/spec/rspec/mocks/stub_spec.rb index efa82d37a..0b86302b3 100644 --- a/spec/rspec/mocks/stub_spec.rb +++ b/spec/rspec/mocks/stub_spec.rb @@ -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 diff --git a/spec/rspec/mocks/verifying_doubles/class_double_with_class_not_loaded_spec.rb b/spec/rspec/mocks/verifying_doubles/class_double_with_class_not_loaded_spec.rb index a41ee406e..411a0a054 100644 --- a/spec/rspec/mocks/verifying_doubles/class_double_with_class_not_loaded_spec.rb +++ b/spec/rspec/mocks/verifying_doubles/class_double_with_class_not_loaded_spec.rb @@ -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)