-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
Using the last argument as keyword parameters is deprecated for arbitrary handling with a block #1326
Comments
@linkyndy Would you like to tackle that? You can get some inspiration from recent commits in PS Not sure if this works as intended: expect(item).to eq(item) |
What are "# ...other expectations..." exactly? Won't it be sufficient to |
Thanks for your quick answer @pirj! I would love to tackle that, however I can't consider that one of my priorities at the moment, unfortunately. I've updated my snippet. The other expectations are related to the double that's yielded to the given block. I could stub Thanks for pointing out the silly first expectation, also! 😊 |
No rush, we're slowly moving there, no work on expect(another_double).to receive(:another_method) I believe you can move this out of the block and it will have the same effect: expect(double).to receive(:method) do |item:, &block|
expect(item).to eq(item_double)
# ...other expectations...
block.call(another_double)
end
expect(another_double).to receive(:another_method) This will get you closer to |
Yes, I did it that way and removed the block altogether. I thought it was more expressive with the block, but it's not that big of a difference. Thanks! I think we can keep this issue open, to actually solve the Ruby warning at some point. |
I think I am running into this same issue. I'm getting:
With a spec like this: allow(File).to receive(:read) do |*args, **kwargs|
if args.first == "special"
""
else
IO.read(*args, **kwargs)
end
end (in this test I wanted to handle a certain file in a special way but actually read the other files) |
Most likely you are, sorry! We are working on this but its complicated to fix even through its just a warning. |
Subject of the issue
I am performing a complex expectation as described in the arbitrary handling section of the docs. Here is the expectation:
I get the following warning from Ruby 2.7:
where the line mentioned is the first line in the Ruby snippet above.
Your environment
I am not sure how I can fix this; tried
expect(double).to receive(:method) do |item:, **kwargs, &block|
but it yielded the same error.The text was updated successfully, but these errors were encountered: