This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 395
Require an argument for the Include matcher #1479
Merged
JonRowe
merged 3 commits into
rspec:main
from
nevinera:nev--1478--include-with-no-args-should-fail
Aug 19, 2024
Merged
Require an argument for the Include matcher #1479
JonRowe
merged 3 commits into
rspec:main
from
nevinera:nev--1478--include-with-no-args-should-fail
Aug 19, 2024
Conversation
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
There are some edge-case ways you can try to invoke this matcher that end up parsing as an argument-less call and a separate expression; this will stop that from happening.
Thanks for making the PR! Looks good to me 🫠 |
pirj
approved these changes
Aug 18, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I'm happier with as an error, its a bug in the matcher due to implementation that should never have worked. I actually played around with this a bit improving the error and there are other things that can break (like the description) when there are no expected. |
Thank you @nevinera |
JonRowe
added a commit
that referenced
this pull request
Aug 20, 2024
…s-should-fail Require an argument for the Include matcher
Released in 3.13.2 |
jrmhaig
added a commit
to ministryofjustice/Claim-for-Crown-Court-Defence
that referenced
this pull request
Aug 23, 2024
Version 3.13.2 of the rspec-expectations gems updates the `include` matcher to raise an exception if no arguments are passed. See rspec/rspec-expectations#1479 The `expected_interim_fees_for` helper is meant to return an array of expected options in a case type selection to be used in the `include` matcher. However, in some cases `nil` is returned resulting in no arguments resulting in an exception. This was masking failures as the test was checking that the list included items in an empty array and was therefore always passing. It turns out that an update to `govuk-form-builder` from some time ago changed the id of select boxes and so the list of options being tested was always empty. This should have immediately resulted in a a failure but it was missed due to the bug in `expected_interim_fees_for`.
Thanks for this! Caught a few |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Resolves #1478
Purpose
There are some edge-case ways you can try to invoke this matcher that end up parsing as an argument-less call and a separate expression; this will stop that from happening.
Implementation
Treat instantiation of the
Include
matcher with no arguments as an ArgumentError.Note
This might count as a breaking change - while it seems like something nobody would ever want to do, the case where this can happen legitimately comes up when the caller is taking an array to splat into the
include
matcher, and ignoring the empty case because it currently passes.