rspec-expectations
rspec-expectations copied to clipboard
Ruby 3+ causes an empty diff error when using `expect .... to receive`
Subject of the issue
I'm running CI. ~When using ruby3 I get a weird error I'm struggling to triage. I'm 99% certain I'm doing something wrong~
When using ruby3, the keyword args vs hashable args isn't being picked up from rspec expectations. Maybe add a line in to the debug message advising people to check this?
Your environment
- Ruby version: 3+
- rspec-expectations version: Latest
Steps to reproduce
View this CI run: https://github.com/site-prism/site_prism/runs/6226827374?check_suite_focus=true
Expected behavior
Ruby 3 doesn't give an error, or if I've done something wrong I know what to fix... EDIT: This is caused by the hashable args issue / keyword issue.
Actual behavior
Related to https://github.com/rspec/rspec-expectations/issues/123 We get a diff where there is no error One specific example is....
expected: (".class-one", {:css=>".my-css", :text=>"Hi", :wait=>0})
got: (".class-one", {:css=>".my-css", :text=>"Hi", :wait=>0})
Diff:
Suggested solution
expected: (".class-one", {:css=>".my-css", :text=>"Hi", :wait=>0})
got: (".class-one", {:css=>".my-css", :text=>"Hi", :wait=>0})
Diff:
**You are running Ruby 3+ and have an empty diff. Please check your keyword args are matched up correct and convert them to a hash if the method expects a hash**
:wave: We're aware, there a couple of similar issues surrounding diffing keyword hashes vs normal hashes. We're working on it :)
Great to hear. I did manage to fix my bug luckily. Just yeh keep up the great work!
I am getting this error now. What is the solution?
The solution is to "check" manually whether your hashing the kwargs correctly.
I use the term solution because it's actually broken. I.e. your tests are failing validly. Because you've made a user error. Just that rspec doesn't highlight this error nicely.
I think this was actually completed, because we now differentiate between keywords and hashes in diffs but if its not please re-open against the monorepo.