From 15153a6d56d0b40c1303e22202371fc69ee19ad7 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 6 Jan 2021 18:01:12 +0900 Subject: [PATCH 1/9] Make `with` aware of Ruby 3 keywords This change makes `receive(:foo).with(a: "A")` allow only `foo(a: "A")` and deny `foo({ a: "A" })` in Ruby 3. Also, `receive(:foo).with({ a: "A" })` allows only `foo({ a: "A" })` and denies `foo(a: "A")`. --- lib/rspec/mocks/argument_list_matcher.rb | 20 ++++++++++-- lib/rspec/mocks/matchers/receive.rb | 1 + lib/rspec/mocks/message_expectation.rb | 1 + spec/rspec/mocks/argument_matchers_spec.rb | 36 +++++++++++++++++----- spec/rspec/mocks/partial_double_spec.rb | 2 +- spec/rspec/mocks/should_syntax_spec.rb | 10 +++--- 6 files changed, 54 insertions(+), 16 deletions(-) diff --git a/lib/rspec/mocks/argument_list_matcher.rb b/lib/rspec/mocks/argument_list_matcher.rb index 1ee647bb6..be5869027 100644 --- a/lib/rspec/mocks/argument_list_matcher.rb +++ b/lib/rspec/mocks/argument_list_matcher.rb @@ -46,16 +46,30 @@ def initialize(*expected_args) @expected_args = expected_args ensure_expected_args_valid! end + ruby2_keywords :initialize if Module.private_method_defined?(:ruby2_keywords) # @api public - # @param [Array] args + # @param [Array] actual_args # # Matches each element in the `expected_args` against the element in the same # position of the arguments passed to `new`. # # @see #initialize - def args_match?(*args) - Support::FuzzyMatcher.values_match?(resolve_expected_args_based_on(args), args) + def args_match?(*actual_args) + expected_args = resolve_expected_args_based_on(actual_args) + + return false if expected_args.size != actual_args.size + + if Hash.respond_to?(:ruby2_keywords_hash?, true) + # if both arguments end with Hashes, and if one is a keyword hash and the other is not, they don't match + if Hash === expected_args.last && Hash === actual_args.last + if Hash.ruby2_keywords_hash?(actual_args.last) != Hash.ruby2_keywords_hash?(expected_args.last) + return false + end + end + end + + Support::FuzzyMatcher.values_match?(expected_args, actual_args) end # @private diff --git a/lib/rspec/mocks/matchers/receive.rb b/lib/rspec/mocks/matchers/receive.rb index 980a01dde..f1ac58684 100644 --- a/lib/rspec/mocks/matchers/receive.rb +++ b/lib/rspec/mocks/matchers/receive.rb @@ -62,6 +62,7 @@ def setup_any_instance_allowance(subject, &block) @recorded_customizations << ExpectationCustomization.new(method, args, block) self end + ruby2_keywords(method) if Module.private_method_defined?(:ruby2_keywords) end private diff --git a/lib/rspec/mocks/message_expectation.rb b/lib/rspec/mocks/message_expectation.rb index cb5a39922..dbb59881a 100644 --- a/lib/rspec/mocks/message_expectation.rb +++ b/lib/rspec/mocks/message_expectation.rb @@ -322,6 +322,7 @@ def with(*args, &block) @argument_list_matcher = ArgumentListMatcher.new(*args) self end + ruby2_keywords(:with) if Module.private_method_defined?(:ruby2_keywords) # Expect messages to be received in a specific order. # diff --git a/spec/rspec/mocks/argument_matchers_spec.rb b/spec/rspec/mocks/argument_matchers_spec.rb index 3df91728d..acdc76f03 100644 --- a/spec/rspec/mocks/argument_matchers_spec.rb +++ b/spec/rspec/mocks/argument_matchers_spec.rb @@ -381,16 +381,36 @@ def ==(other) a_double.random_call(:a => "a", :b => "b") end - it "matches against a hash submitted by reference and received by value" do - opts = {:a => "a", :b => "b"} - expect(a_double).to receive(:random_call).with(opts) - a_double.random_call(:a => "a", :b => "b") + if RSpec::Support::RubyFeatures.required_kw_args_supported? + it "fails to match against a hash submitted by reference and received by value in Ruby 3", :reset => true do + opts = {:a => "a", :b => "b"} + expect(a_double).to receive(:random_call).with(opts) + expect do + a_double.random_call(:a => "a", :b => "b") + end.to fail_with(/expected: \(\{:a=>"a", :b=>"b"|:b=>"b", :a=>"a"\}\)/) + end + else + it "matches against a hash submitted by reference and received by value in Ruby 2" do + opts = {:a => "a", :b => "b"} + expect(a_double).to receive(:random_call).with(opts) + a_double.random_call(:a => "a", :b => "b") + end end - it "matches against a hash submitted by value and received by reference" do - opts = {:a => "a", :b => "b"} - expect(a_double).to receive(:random_call).with(:a => "a", :b => "b") - a_double.random_call(opts) + if RUBY_VERSION >= "2.7" + it "fails to match against a hash submitted by value and received by reference in Ruby 2.7 or later", :reset => true do + opts = {:a => "a", :b => "b"} + expect(a_double).to receive(:random_call).with(:a => "a", :b => "b") + expect do + a_double.random_call(opts) + end.to fail_with(/expected: \(\{(:a=>\"a\", :b=>\"b\"|:b=>\"b\", :a=>\"a\")\}\)/) + end + else + it "matches against a hash submitted by value and received by reference in Ruby 2.6 or before" do + opts = {:a => "a", :b => "b"} + expect(a_double).to receive(:random_call).with(:a => "a", :b => "b") + a_double.random_call(opts) + end end it "fails for a hash w/ wrong values", :reset => true do diff --git a/spec/rspec/mocks/partial_double_spec.rb b/spec/rspec/mocks/partial_double_spec.rb index 39b929f58..6a010840f 100644 --- a/spec/rspec/mocks/partial_double_spec.rb +++ b/spec/rspec/mocks/partial_double_spec.rb @@ -84,7 +84,7 @@ def call(name) it "can accept an inner hash as a message argument" do hash = {:a => {:key => "value"}} expect(object).to receive(:foobar).with(:key => "value").and_return(1) - expect(object.foobar(hash[:a])).to equal(1) + expect(object.foobar(**hash[:a])).to equal(1) end it "can create a positive message expectation" do diff --git a/spec/rspec/mocks/should_syntax_spec.rb b/spec/rspec/mocks/should_syntax_spec.rb index 255f5be21..527178d79 100644 --- a/spec/rspec/mocks/should_syntax_spec.rb +++ b/spec/rspec/mocks/should_syntax_spec.rb @@ -466,12 +466,14 @@ def use_rspec_mocks let(:expected_arguments) { [ /Using.*without explicitly enabling/, - {:replacement => "the new `:expect` syntax or explicitly enable `:should`"} ] } + let(:expected_keywords) { + {:replacement => "the new `:expect` syntax or explicitly enable `:should`"} + } it "it warns about should once, regardless of how many times it is called" do - expect(RSpec).to receive(:deprecate).with(*expected_arguments) + expect(RSpec).to receive(:deprecate).with(*expected_arguments, **expected_keywords) o = Object.new o2 = Object.new o.should_receive(:bees) @@ -482,7 +484,7 @@ def use_rspec_mocks end it "warns about should not once, regardless of how many times it is called" do - expect(RSpec).to receive(:deprecate).with(*expected_arguments) + expect(RSpec).to receive(:deprecate).with(*expected_arguments, **expected_keywords) o = Object.new o2 = Object.new o.should_not_receive(:bees) @@ -490,7 +492,7 @@ def use_rspec_mocks end it "warns about stubbing once, regardless of how many times it is called" do - expect(RSpec).to receive(:deprecate).with(*expected_arguments) + expect(RSpec).to receive(:deprecate).with(*expected_arguments, **expected_keywords) o = Object.new o2 = Object.new From 20499b9784c61a3ceb357bd7054984938f4847ec Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Thu, 7 Jan 2021 09:42:34 +0900 Subject: [PATCH 2/9] Respect Ruby 3's conversion from keywords to a positional last Hash This change allows a Hash argument expectation (`with({ a: 'a' })`) to accept keyword arguments (`foo(a: 'a')`) both in Ruby 2 and in Ruby 3. ``` allow(foo).to receive(:bar).with({ a: 'a' }) foo.bar(a: 'a') foo.bar({ a: 'a' }) ``` This is because Ruby 3 also allows the automatic conversion from keywords to a positional Hash. (But the conversion from a positional last Hash to keywords is not allowed.) ``` def foo(opts = {}) end foo(a: 'a') foo({ a: 'a' }) ``` --- lib/rspec/mocks/argument_list_matcher.rb | 2 +- spec/rspec/mocks/argument_matchers_spec.rb | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/rspec/mocks/argument_list_matcher.rb b/lib/rspec/mocks/argument_list_matcher.rb index be5869027..7b2a41f45 100644 --- a/lib/rspec/mocks/argument_list_matcher.rb +++ b/lib/rspec/mocks/argument_list_matcher.rb @@ -63,7 +63,7 @@ def args_match?(*actual_args) if Hash.respond_to?(:ruby2_keywords_hash?, true) # if both arguments end with Hashes, and if one is a keyword hash and the other is not, they don't match if Hash === expected_args.last && Hash === actual_args.last - if Hash.ruby2_keywords_hash?(actual_args.last) != Hash.ruby2_keywords_hash?(expected_args.last) + if !Hash.ruby2_keywords_hash?(actual_args.last) && Hash.ruby2_keywords_hash?(expected_args.last) return false end end diff --git a/spec/rspec/mocks/argument_matchers_spec.rb b/spec/rspec/mocks/argument_matchers_spec.rb index acdc76f03..3bf679066 100644 --- a/spec/rspec/mocks/argument_matchers_spec.rb +++ b/spec/rspec/mocks/argument_matchers_spec.rb @@ -381,20 +381,10 @@ def ==(other) a_double.random_call(:a => "a", :b => "b") end - if RSpec::Support::RubyFeatures.required_kw_args_supported? - it "fails to match against a hash submitted by reference and received by value in Ruby 3", :reset => true do - opts = {:a => "a", :b => "b"} - expect(a_double).to receive(:random_call).with(opts) - expect do - a_double.random_call(:a => "a", :b => "b") - end.to fail_with(/expected: \(\{:a=>"a", :b=>"b"|:b=>"b", :a=>"a"\}\)/) - end - else - it "matches against a hash submitted by reference and received by value in Ruby 2" do - opts = {:a => "a", :b => "b"} - expect(a_double).to receive(:random_call).with(opts) - a_double.random_call(:a => "a", :b => "b") - end + it "matches against a hash submitted by reference and received by value (in both Ruby 2 and Ruby 3)" do + opts = {:a => "a", :b => "b"} + expect(a_double).to receive(:random_call).with(opts) + a_double.random_call(:a => "a", :b => "b") end if RUBY_VERSION >= "2.7" From 3ecb3258c1dcf5960137c2b227813b811b84aa6b Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 8 Jan 2021 15:30:35 +0900 Subject: [PATCH 3/9] Rephrase the spec descriptions about keyword/positional arguments https://github.com/rspec/rspec-mocks/pull/1394#discussion_r552568643 --- spec/rspec/mocks/argument_matchers_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/rspec/mocks/argument_matchers_spec.rb b/spec/rspec/mocks/argument_matchers_spec.rb index 3bf679066..345872183 100644 --- a/spec/rspec/mocks/argument_matchers_spec.rb +++ b/spec/rspec/mocks/argument_matchers_spec.rb @@ -381,14 +381,14 @@ def ==(other) a_double.random_call(:a => "a", :b => "b") end - it "matches against a hash submitted by reference and received by value (in both Ruby 2 and Ruby 3)" do + it "matches against a hash submitted as keyword arguments a and received as a positional argument (in both Ruby 2 and Ruby 3)" do opts = {:a => "a", :b => "b"} expect(a_double).to receive(:random_call).with(opts) a_double.random_call(:a => "a", :b => "b") end if RUBY_VERSION >= "2.7" - it "fails to match against a hash submitted by value and received by reference in Ruby 2.7 or later", :reset => true do + it "fails to matches against a hash submitted as a positional argument and received as keyword arguments in Ruby 2.7 or later", :reset => true do opts = {:a => "a", :b => "b"} expect(a_double).to receive(:random_call).with(:a => "a", :b => "b") expect do @@ -396,7 +396,7 @@ def ==(other) end.to fail_with(/expected: \(\{(:a=>\"a\", :b=>\"b\"|:b=>\"b\", :a=>\"a\")\}\)/) end else - it "matches against a hash submitted by value and received by reference in Ruby 2.6 or before" do + it "matches against a hash submitted as a positional argument and received as keyword arguments in Ruby 2.6 or before" do opts = {:a => "a", :b => "b"} expect(a_double).to receive(:random_call).with(:a => "a", :b => "b") a_double.random_call(opts) From 644c7a6027004e2be427dc76211ad207176bd7aa Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 8 Jan 2021 16:30:18 +0900 Subject: [PATCH 4/9] Use eval to avoid SyntaxError on Ruby 1.9.3 --- spec/rspec/mocks/partial_double_spec.rb | 11 ++++-- spec/rspec/mocks/should_syntax_spec.rb | 49 ++++++++++++++----------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/spec/rspec/mocks/partial_double_spec.rb b/spec/rspec/mocks/partial_double_spec.rb index 6a010840f..636d1aad6 100644 --- a/spec/rspec/mocks/partial_double_spec.rb +++ b/spec/rspec/mocks/partial_double_spec.rb @@ -81,10 +81,13 @@ def call(name) expect(object.foobar(:key => "value")).to equal(1) end - it "can accept an inner hash as a message argument" do - hash = {:a => {:key => "value"}} - expect(object).to receive(:foobar).with(:key => "value").and_return(1) - expect(object.foobar(**hash[:a])).to equal(1) + if RSpec::Support::RubyFeatures.required_kw_args_supported? + it "can accept an inner hash as a message argument" do + hash = {:a => {:key => "value"}} + expect(object).to receive(:foobar).with(:key => "value").and_return(1) + # Use eval to avoid syntax error on 1.8 and 1.9 + eval("expect(object.foobar(**hash[:a])).to equal(1)") + end end it "can create a positive message expectation" do diff --git a/spec/rspec/mocks/should_syntax_spec.rb b/spec/rspec/mocks/should_syntax_spec.rb index 527178d79..147229013 100644 --- a/spec/rspec/mocks/should_syntax_spec.rb +++ b/spec/rspec/mocks/should_syntax_spec.rb @@ -472,32 +472,37 @@ def use_rspec_mocks {:replacement => "the new `:expect` syntax or explicitly enable `:should`"} } - it "it warns about should once, regardless of how many times it is called" do - expect(RSpec).to receive(:deprecate).with(*expected_arguments, **expected_keywords) - o = Object.new - o2 = Object.new - o.should_receive(:bees) - o2.should_receive(:bees) + if RSpec::Support::RubyFeatures.required_kw_args_supported? + it "it warns about should once, regardless of how many times it is called" do + # Use eval to avoid syntax error on 1.8 and 1.9 + eval("expect(RSpec).to receive(:deprecate).with(*expected_arguments, **expected_keywords)") + o = Object.new + o2 = Object.new + o.should_receive(:bees) + o2.should_receive(:bees) - o.bees - o2.bees - end + o.bees + o2.bees + end - it "warns about should not once, regardless of how many times it is called" do - expect(RSpec).to receive(:deprecate).with(*expected_arguments, **expected_keywords) - o = Object.new - o2 = Object.new - o.should_not_receive(:bees) - o2.should_not_receive(:bees) - end + it "warns about should not once, regardless of how many times it is called" do + # Use eval to avoid syntax error on 1.8 and 1.9 + eval("expect(RSpec).to receive(:deprecate).with(*expected_arguments, **expected_keywords)") + o = Object.new + o2 = Object.new + o.should_not_receive(:bees) + o2.should_not_receive(:bees) + end - it "warns about stubbing once, regardless of how many times it is called" do - expect(RSpec).to receive(:deprecate).with(*expected_arguments, **expected_keywords) - o = Object.new - o2 = Object.new + it "warns about stubbing once, regardless of how many times it is called" do + # Use eval to avoid syntax error on 1.8 and 1.9 + eval("expect(RSpec).to receive(:deprecate).with(*expected_arguments, **expected_keywords)") + o = Object.new + o2 = Object.new - o.stub(:faces) - o2.stub(:faces) + o.stub(:faces) + o2.stub(:faces) + end end it "warns about unstubbing once, regardless of how many times it is called" do From 57de5aa48626a4f62db3bea0cd5c05a8608a2881 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 8 Jan 2021 16:36:58 +0900 Subject: [PATCH 5/9] Avoid "warning: assigned but unused variable - hash" --- spec/rspec/mocks/partial_double_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/rspec/mocks/partial_double_spec.rb b/spec/rspec/mocks/partial_double_spec.rb index 636d1aad6..044f570b1 100644 --- a/spec/rspec/mocks/partial_double_spec.rb +++ b/spec/rspec/mocks/partial_double_spec.rb @@ -87,6 +87,8 @@ def call(name) expect(object).to receive(:foobar).with(:key => "value").and_return(1) # Use eval to avoid syntax error on 1.8 and 1.9 eval("expect(object.foobar(**hash[:a])).to equal(1)") + # Avoid warning: assigned but unused variable - hash + hash = hash end end From cdd9a0465a001f20479922ae3f6e45d1fa29f3a4 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 5 Feb 2021 13:28:40 +0900 Subject: [PATCH 6/9] Wrap the whole spec in an eval to avoid a warning: "assigned but unused variable - hash" --- spec/rspec/mocks/partial_double_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/rspec/mocks/partial_double_spec.rb b/spec/rspec/mocks/partial_double_spec.rb index 044f570b1..099b15517 100644 --- a/spec/rspec/mocks/partial_double_spec.rb +++ b/spec/rspec/mocks/partial_double_spec.rb @@ -82,14 +82,14 @@ def call(name) end if RSpec::Support::RubyFeatures.required_kw_args_supported? + # Use eval to avoid syntax error on 1.8 and 1.9 + binding.eval(<<-CODE, __FILE__, __LINE__) it "can accept an inner hash as a message argument" do hash = {:a => {:key => "value"}} expect(object).to receive(:foobar).with(:key => "value").and_return(1) - # Use eval to avoid syntax error on 1.8 and 1.9 - eval("expect(object.foobar(**hash[:a])).to equal(1)") - # Avoid warning: assigned but unused variable - hash - hash = hash + expect(object.foobar(**hash[:a])).to equal(1) end + CODE end it "can create a positive message expectation" do From 7c7500cb9e947a7ceb73d7cdf87924039f15031f Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 5 Feb 2021 13:29:37 +0900 Subject: [PATCH 7/9] Restore the old spec for the older rubies that does not support keywords --- spec/rspec/mocks/should_syntax_spec.rb | 51 +++++++++++++++++++++----- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/spec/rspec/mocks/should_syntax_spec.rb b/spec/rspec/mocks/should_syntax_spec.rb index 147229013..bef8a5ab1 100644 --- a/spec/rspec/mocks/should_syntax_spec.rb +++ b/spec/rspec/mocks/should_syntax_spec.rb @@ -463,16 +463,15 @@ def use_rspec_mocks after(:all) { RSpec::Mocks.configuration.syntax = orig_syntax } before { RSpec::Mocks.configuration.reset_syntaxes_to_default } - let(:expected_arguments) { - [ - /Using.*without explicitly enabling/, - ] - } - let(:expected_keywords) { - {:replacement => "the new `:expect` syntax or explicitly enable `:should`"} - } - if RSpec::Support::RubyFeatures.required_kw_args_supported? + let(:expected_arguments) { + [ + /Using.*without explicitly enabling/, + ] + } + let(:expected_keywords) { + {:replacement => "the new `:expect` syntax or explicitly enable `:should`"} + } it "it warns about should once, regardless of how many times it is called" do # Use eval to avoid syntax error on 1.8 and 1.9 eval("expect(RSpec).to receive(:deprecate).with(*expected_arguments, **expected_keywords)") @@ -500,6 +499,40 @@ def use_rspec_mocks o = Object.new o2 = Object.new + o.stub(:faces) + o2.stub(:faces) + end + else + let(:expected_arguments) { + [ + /Using.*without explicitly enabling/, + {:replacement => "the new `:expect` syntax or explicitly enable `:should`"} + ] + } + it "it warns about should once, regardless of how many times it is called" do + expect(RSpec).to receive(:deprecate).with(*expected_arguments) + o = Object.new + o2 = Object.new + o.should_receive(:bees) + o2.should_receive(:bees) + + o.bees + o2.bees + end + + it "warns about should not once, regardless of how many times it is called" do + expect(RSpec).to receive(:deprecate).with(*expected_arguments) + o = Object.new + o2 = Object.new + o.should_not_receive(:bees) + o2.should_not_receive(:bees) + end + + it "warns about stubbing once, regardless of how many times it is called" do + expect(RSpec).to receive(:deprecate).with(*expected_arguments) + o = Object.new + o2 = Object.new + o.stub(:faces) o2.stub(:faces) end From 21fdd062b82642ddc523f320c0715fcaf9b654d7 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 17 Feb 2021 11:23:32 +0900 Subject: [PATCH 8/9] Try making the change for Ruby 3.0+ only --- lib/rspec/mocks/argument_list_matcher.rb | 2 +- spec/rspec/mocks/argument_matchers_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rspec/mocks/argument_list_matcher.rb b/lib/rspec/mocks/argument_list_matcher.rb index 7b2a41f45..d96dc1e83 100644 --- a/lib/rspec/mocks/argument_list_matcher.rb +++ b/lib/rspec/mocks/argument_list_matcher.rb @@ -60,7 +60,7 @@ def args_match?(*actual_args) return false if expected_args.size != actual_args.size - if Hash.respond_to?(:ruby2_keywords_hash?, true) + if RUBY_VERSION >= "3" # if both arguments end with Hashes, and if one is a keyword hash and the other is not, they don't match if Hash === expected_args.last && Hash === actual_args.last if !Hash.ruby2_keywords_hash?(actual_args.last) && Hash.ruby2_keywords_hash?(expected_args.last) diff --git a/spec/rspec/mocks/argument_matchers_spec.rb b/spec/rspec/mocks/argument_matchers_spec.rb index 345872183..3c0f43e67 100644 --- a/spec/rspec/mocks/argument_matchers_spec.rb +++ b/spec/rspec/mocks/argument_matchers_spec.rb @@ -387,8 +387,8 @@ def ==(other) a_double.random_call(:a => "a", :b => "b") end - if RUBY_VERSION >= "2.7" - it "fails to matches against a hash submitted as a positional argument and received as keyword arguments in Ruby 2.7 or later", :reset => true do + if RUBY_VERSION >= "3" + it "fails to matches against a hash submitted as a positional argument and received as keyword arguments in Ruby 3.0 or later", :reset => true do opts = {:a => "a", :b => "b"} expect(a_double).to receive(:random_call).with(:a => "a", :b => "b") expect do From 865ea3a795e0e56309b823e76e3f65eff5cfa448 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Thu, 18 Feb 2021 09:51:40 +0900 Subject: [PATCH 9/9] Fix a wrong version description: "2.6 or before" -> "2.7 or before" --- spec/rspec/mocks/argument_matchers_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/rspec/mocks/argument_matchers_spec.rb b/spec/rspec/mocks/argument_matchers_spec.rb index 3c0f43e67..cd17bb34a 100644 --- a/spec/rspec/mocks/argument_matchers_spec.rb +++ b/spec/rspec/mocks/argument_matchers_spec.rb @@ -396,7 +396,7 @@ def ==(other) end.to fail_with(/expected: \(\{(:a=>\"a\", :b=>\"b\"|:b=>\"b\", :a=>\"a\")\}\)/) end else - it "matches against a hash submitted as a positional argument and received as keyword arguments in Ruby 2.6 or before" do + it "matches against a hash submitted as a positional argument and received as keyword arguments in Ruby 2.7 or before" do opts = {:a => "a", :b => "b"} expect(a_double).to receive(:random_call).with(:a => "a", :b => "b") a_double.random_call(opts)