Closed dblock closed 2 years ago
Error message for this is improved in this PR. Problem is this is using keyword arguments:
expect(subject).to receive(:namespace_inheritable).with(:version_options, using: :path)
and this is using positional hash:
options = options.reverse_merge(using: :path)
namespace_inheritable(:version_options, options)
I believe changing the spec to:
expect(subject).to receive(:namespace_inheritable).with(:version_options, {using: :path})
would fix it.
Spot on, thanks @pirj! Closing this since this is not a bug in rspec-expectations, and looking forward to #1461 to be merged.
This issue also baffled me. Here is a small repro case (passes in ruby < 3, fails in ruby >= 3)
# run with `rspec <this_file.rb>`
class Subject
def method_missing(method_sym, *args)
say method_sym, *args
end
def say(greeting, name, opts = {})
puts "#{greeting} #{name} (opts: #{opts})"
end
end
describe Subject do
it "works" do
expect(subject).to receive(:say).with :hello, "world", color: true
subject.hello "world", color: true
end
end
I understand how to work around it, and the trickiness of keyword arguments, but this is the error received:
expected: (:hello, "world", {:color=>true})
got: (:hello, "world", {:color=>true})
and I wonder, if rspec already knows it is different, isn't there a way to specify how it is different? Just receiving strings that look identical, with a statement that they are not is confusing.
@DannyBen Error message for this is improved in https://github.com/rspec/rspec-mocks/pull/1461.
@DannyBen Error message for this is improved in rspec/rspec-mocks#1461.
Cool. So does it mean one of the upcoming versions will have this fixed? I am sorry, I am unfamiliar with which sub-gem is responsible for this behavior.
Once that PR is merged the error message will make sense. The spec is failing as expected though, so do fix your code as in https://github.com/ruby-grape/grape/pull/2248.
Cool, thanks!
The spec is failing as expected though
Of course, makes sense.
Subject of the issue
Coming from https://github.com/ruby-grape/grape/issues/2247, getting unexpected arguments but expected value matches parameters.
Your environment
Steps to reproduce
I tried to get a small repro but so far have failed. If I have time will try to bisect next.
In Grape:
Expected behavior
Arguments to match.
Actual behavior