fix keyword arguments for future compatibility #5175
Closed
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.
Hi, thanks for your great effort to maintain this gem!
summary
Just found out a warning about keyword arguments that will potentially break with future ruby, when trying to test devise against Ruby2.7.
(thankfully the prior PR #5174 covered most of them - examining the test logs that I ran with my forked repo, this seems the only one left out)
why it's needed to change
Devise::IntegrationTest and Devise::ControllerTestCase offers sets of methods that delegate its execution to ActionController::TestCase.
As the delegated methods (and its delegated one, #process) require keyword arguments, we need to pass our hash objects as keyword arguments.
compatibility
Lots of corner cases have been discussed around this issue, luckily this patch is perfectly compatible with the current implementation, except for the deprecation warnings emitted by the existing codes (when being run on Ruby2.7).
Specifically:
When keyword arguments or hash object are provided
When no keyword arguments are given
the latter case is the only corner case. With Ruby < 2.7, we pass over empty hash to ActionController::TestCase, but it does no harm as it is interpreted as empty keyword args with < Ruby 2.7.
backup
To demonstrate how they compare (and for my own peace of mind), I created a few delegation test cases - emulating current implementation, and new implementation , as well as cases about how they compare against each other
These cases are tested against Ruby2.1.10 upto 2.7.0 with similar environment with devise. Please feel free to check in case you are interested ;)
Hope that helps!