-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
Subset matching broken on objects implementing to_hash and include? #1082
Comments
I'm not sure whats the correct behaviour here, if headers were a hash, it should fail:
So was headers previously behaving like an array? Or is it the individual header object not working... This feels like it's a bug that should be addressed either by Rails, or by |
If actual is a Previously the headers object was converted by calling The matcher has always and still does handle |
Subset matching on hashes is well documented too. |
Yes I'm aware, the issue is that |
@jgraichen Do you think you could have time to try to submit a patch? |
I'm still thinking about a solution. I do understand to use Given the requirement to not change the behavior of using Apparently we kindly profited from that bug and the bug fix suddenly broke our workflow. ;-) I do not see any easy patch not breaking the requirement of using Thanks for your work! |
Thanks @jgraichen for this detailed answer. I'm closing the issue for now because as you mention:
I will let @JonRowe comment if wanted. |
I'm still interested in doing something with this to better support hash shaped objects |
I'm pretty sure this change broke my test which uses expect(policy.permitted(params)).to include('foo' => 'bar') I fixed it for now by adding a |
Subject of the issue
#1073 seems to break subset hash matching for objects implementing
#to_hash
and#include?
. Previously these objects were converted using#to_hash
onactual
. Due to not converting to aHash
the check incomparing_hash_to_a_subset?
will always be false and subset check won't be performed anymore (unless the objects#include?
implements subset matching).We had lots of breaking tests after the
rspec-expectations
patch update due to having specs on e.g.ActionDispatch::Response::Header
like this:These expectations produced a nice diff when failing showing all send headers. We currently fixed it by explicitly calling
#to_hash
on these objects.It would be nice if such use case could still be supported.
Your environment
Steps to reproduce
Run the following test case:
Running the test case with
3.8.1
passes.Expected behavior
I'd expect the expectations to still pass after a patch level upgrade.
Actual behavior
All expectations failed while showing a nice diff showing no difference.
The text was updated successfully, but these errors were encountered: