-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix RSpec mock expectations for Ruby 3 (#816)
Something changed in the rspec-mocks gem between versions 3.10.2 and 3.10.3, because that's what causes tests to fail like this on Ruby 3.1.0 and 3.0.3 locally and on the CI: ``` Failure/Error: monitor_transaction(name, env, &block) Appsignal received :monitor_transaction with unexpected arguments expected: ("perform_job.something", {:key=>:value}) got: ("perform_job.something", {:key=>:value}) Diff: ``` In this example the arguments are exactly the same, except they're not the identical objects. This particular issue seems to be caused by a recent change that for Ruby 3 keyword argument matching: rspec/rspec-mocks#1460 ## Rewriting specs What helps is rewriting the tests to not mock method calls and check the arguments given. Instead, assert what's being stored on the transactions, like how we want all tests to be written as described in issue #252. ## Adding curly brackets For other specs that are a little more difficult to rewrite this way right now, I've chosen to add additional curly brackets around the argument expectations so that it's clear to Ruby/RSpec it's a hash argument and not keywords arguments. To solve this more permanently, we should rewrite the specs at some point. We can remove these curly brackets if the issue is fixed in a future rspec-mocks version as well. [skip changeset]
- Loading branch information
Showing
5 changed files
with
89 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters