-
-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected arguments error with correct hash value #1505
Comments
Error message for this is improved in this PR. 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. |
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:
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. |
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 ruby-grape/grape#2248. |
Cool, thanks!
Of course, makes sense. |
Subject of the issue
Coming from ruby-grape/grape#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
The text was updated successfully, but these errors were encountered: