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

Explicit deprecation warning mocks #3753

Merged
merged 2 commits into from
Sep 8, 2020

Conversation

cedum
Copy link
Contributor

@cedum cedum commented Sep 4, 2020

When testing, instead of silencing/mocking all deprecation warnings, test the specific deprecation warning needed for the specific test case.
Since we make fail the CI build when there're unhandled deprecation warnings, this ensures we have expectations only for specific deprecation warnings instead of silencing/mocking all warnings.

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

When testing, instead of silencing/mocking all deprecation warnings,
test the specific deprecation warning needed for the specific test case.
Since we make fail the CI build when there're unhandled deprecation
warning, this ensures when testing we have an expectation for only a
specific deprecation warning in test cases.
@cedum cedum force-pushed the explicit-deprecation-mocks branch from fcddf9a to b62ced6 Compare September 4, 2020 16:14
@spaghetticode
Copy link
Member

@cedum thank you for this PR, I think it's a good improvement 👍

Have you considered the idea of adding a helper method for improving readability? Something that would allow us to replace this:

expect(Spree::Deprecation).to receive(:warn).
              with(/^Passing existing_card_id to PaymentCreate is deprecated/, any_args)

with something like:
expect_deprecation_with(/^Passing existing_card_id to PaymentCreate is deprecated/)

it adds a bit of overhead, so I'm not really sure it's worth the effort, still I'd like to know others' opinions.

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Super in favor of this! Let us know what do you think about the @spaghetticode comment.

Copy link
Member

@jarednorman jarednorman left a comment

Choose a reason for hiding this comment

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

I like this too.

@kennyadsl kennyadsl merged commit f36e61f into solidusio:master Sep 8, 2020
@kennyadsl kennyadsl deleted the explicit-deprecation-mocks branch September 8, 2020 07:26
@cedum
Copy link
Contributor Author

cedum commented Sep 8, 2020

Agree with @spaghetticode, a helper might simplify a bit the work with deprecations in tests.

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.

4 participants