Upgrade mocha to v2.0.0.alpha.1 without deployment actions#3
Open
floehopper wants to merge 4 commits intomainfrom
Open
Upgrade mocha to v2.0.0.alpha.1 without deployment actions#3floehopper wants to merge 4 commits intomainfrom
floehopper wants to merge 4 commits intomainfrom
Conversation
Member
floehopper
commented
Oct 18, 2022
We don't want to run those on this fork!
This avoids the following deprecation warning:
Mocha deprecation warning at test/test_helper.rb:34:in `block in
<main>': Configuration#reinstate_undocumented_behaviour_from_v1_9=
is unnecessarily being set to false, because this is now the default
value. Configuration#reinstate_undocumented_behaviour_from_v1_9=
will be removed in the future, so you should avoid calling it.
This fixes some of the warnings related to strict keyword argument
matching, like this one:
Mocha deprecation warning at app/services/asset_manager/attachment_updater/update.rb:15:in `call':
Expectation defined at test/unit/services/asset_manager/attachment_updater/draft_status_updates_test.rb:28:
in `block (3 levels) in <class:DraftStatusUpdatesTest>'
expected keyword arguments ("draft" => true),
but received positional hash ({"draft" => true}).
These will stop matching when strict keyword argument matching is enabled.
See the documentation for Mocha::Configuration#strict_keyword_argument_matching=.
In order to fix the warnings, I've changed the signature of
AssetManager::AssetUpdater#call so that new_attributes parameter must be supplied
as keyword arguments rather than a positional Hash. This had the
advantage that I only needed to change
AssetManager::AttachmentUpdater::Update#call to convert the
deep_stringify_keys into keyword arguments using a double-splat; I
didn't need to change all the places where
AssetManager::AssetUpdater#call is stubbed.
An alternative would be to leave the signature of
AssetManager::AssetUpdater#call unchanged and change the calls to
Expectation#with for all the relevant stubs to pass a positional Hash,
i.e. wrapped in braces.
This article [1] is a very useful reference.
[1]: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
67b7c3c to
0a434c0
Compare
4 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.