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

Respect verify partial doubles config when verifying job/mailer arguments #2808

Merged
merged 4 commits into from
Nov 8, 2024

Conversation

odlp
Copy link
Contributor

@odlp odlp commented Oct 25, 2024

Following on from #2745, this PR skips the job/mailer verification that arguments match the signature when:

This direction was suggested by @JonRowe here:

I'm leaving this open because I think this should respect the existing configuration for verifying doubles, we should check to see if we should verify arguments.

Closes #2801.

@odlp odlp force-pushed the pr-suppress-job-and-mail-signature-checks branch from cf5f3f8 to 67a538f Compare November 1, 2024 16:25
@odlp odlp requested a review from JonRowe November 1, 2024 16:28
Copy link
Member

@JonRowe JonRowe left a comment

Choose a reason for hiding this comment

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

Rather than creating a new helper, I would rather the specs be setup with an around block that restores the original behaviour, and explicitly setting the values to true/false in a before in the context, I don't mind if you make a helper for the "restore" part (in an around hook) but I would strongly prefer it if the contexts set the correct values directly in a before.

@odlp
Copy link
Contributor Author

odlp commented Nov 4, 2024

Rather than creating a new helper, I would rather the specs be setup with an around block that restores the original behaviour, and explicitly setting the values to true/false in a before in the context, I don't mind if you make a helper for the "restore" part (in an around hook) but I would strongly prefer it if the contexts set the correct values directly in a before.

👍 Updated to match the requested style

FWIW I find a block-based helper superior when temporarily mutating global state because that interface guarantees the state is reset (like Timecop safe mode for example).

I've worked in many codebases which mutate global state in before hooks and don't have a corresponding after or around hook to reset said state, leading to order-dependent test failures. Appreciate this codebase is safeguarded with good code review with high standards... but to err is human and so on...

@odlp odlp requested a review from JonRowe November 4, 2024 10:19
@JonRowe
Copy link
Member

JonRowe commented Nov 4, 2024

FWIW I find a block-based helper superior when temporarily mutating global state because that interface guarantees the state is reset (like Timecop safe mode for example).

I've worked in many codebases which mutate global state in before hooks and don't have a corresponding after or around hook to reset said state, leading to order-dependent test failures. Appreciate this codebase is safeguarded with good code review with high standards... but to err is human and so on...

An around hook is essentially a block based helper, the problem I had with it is the implementation obscured the actual config setting that was being set, as our specs act as part of our documentation its less obvious whats being tweaked, an alternative would be to use the without_partial_double_verification block helper thats actually part of rspec-mocks if you prefer.

@odlp
Copy link
Contributor Author

odlp commented Nov 4, 2024

@JonRowe

An around hook is essentially a block based helper

Very true.

an alternative would be to use the without_partial_double_verification block helper

I do use this in the other specs - but it sets a distinct flag Mocks.configuration.temporarily_suppress_partial_double_verification rather than Mocks.configuration.verify_partial_doubles. It's a pity in a way there are two flags at play here, but that's why we need to check both flags and test accordingly.

Overall I think the PR is fine now; I'm happy to adopt the house style and appreciate the trade-offs you mention between obscuring the config setting vs safety.

@JonRowe JonRowe merged commit b819663 into rspec:main Nov 8, 2024
16 checks passed
@JonRowe
Copy link
Member

JonRowe commented Nov 8, 2024

Thank you for this!

JonRowe added a commit that referenced this pull request Nov 8, 2024
@JonRowe
Copy link
Member

JonRowe commented Nov 9, 2024

Released in 7.1.0

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.

Add configuration to disable ActiveJob job signature matching check
2 participants