Skip to content
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

Fix hash vs keyword arguments in RSpec expectations (bsc#1204871) #1314

Merged
merged 2 commits into from Nov 24, 2022

Conversation

mvidner
Copy link
Member

@mvidner mvidner commented Nov 22, 2022

New rspec-mocks distinguish between hash and keyword arguments passed to `with`.

The tested code does use hashes but we've used keywords in tests because
it's shorter to write. Fixed.

rspec-mocks 3.11.2 / 2022-10-25:

> Bug Fixes: Support keyword argument semantics when constraining argument
> expectations using with on Ruby 3.0+ with instance_double
> rspec/rspec-mocks#1473

Why this took longer to fix? Misleading RSpec messages:

Even with current rspec-mocks 3.12.0 the error message can be confusing,
differing only in the object_id of the Path:

       Yast::SCR received :Write with unexpected arguments
         expected: (#<Yast::Path:0x00007f92c30a6f88 @components=["modules", "options", "virtio_net"]>, {"debug"=>"16"})
              got: (#<Yast::Path:0x00007f92c30a4d00 @components=["modules", "options", "virtio_net"]>, {"debug"=>"16"})

That's because rspec/rspec-mocks@e931e81
only adds the distinguishing "(keyword arguments)" or "(options hash)"
when the _inspect representations_ of the arguments are the same.

To avoid this bug we could override #inspect to omit the #object_id
whenever we override #==.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 80.325% when pulling f89bf2c on rspec-kw-hash into 485c46f on master.

Copy link
Contributor

@teclator teclator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mvidner mvidner merged commit 1c37acd into master Nov 24, 2022
@mvidner mvidner deleted the rspec-kw-hash branch November 24, 2022 09:21
@yast-bot
Copy link
Contributor

✔️ Internal Jenkins job #210 successfully finished
✔️ Created IBS submit request #285052

@yast-bot
Copy link
Contributor

yast-bot commented Dec 1, 2022

✔️ Public Jenkins job #314 successfully finished
✔️ Created OBS submit request #1039350

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants