Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix: allow and_error matcher to use RSpec matcher as and_value does #51

Merged
merged 3 commits into from
Jul 18, 2024

Conversation

bvicenzo
Copy link
Contributor

as and_value matcher on success, and_error, now allow to pass a matcher instead a value to be compared using equality:

Ex:

Before:

expect(User::Create.(username: 'bruno', email: 'invalid@'))
  .to have_failed_with(:invalid_user)
  .and_error(?) # very hard to compare without mocking

After:

expect(User::Create.(username: 'bruno', email: 'invalid@'))
  .to have_failed_with(:invalid_user)
  .and_error(be_a(User))

# Or

expect(User::Create.(username: 'bruno', email: 'invalid@'))
  .to have_failed_with(:invalid_user)
  .and_error(have_attributes(email: 'invalid@'))

Copy link

@euricovidal euricovidal left a comment

Choose a reason for hiding this comment

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

🚀

@bvicenzo bvicenzo merged commit a791ee4 into master Jul 18, 2024
4 checks passed
@bvicenzo bvicenzo deleted the bv-fix-allow-and-error-use-a-matcher branch July 18, 2024 18:36
@bvicenzo bvicenzo mentioned this pull request Jul 18, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants