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

ARCH-2109 ensure errors.messages doesn't raise in have_error_on_attribute matcher #445

Conversation

MichelleMik
Copy link
Contributor

https://freshly.atlassian.net/browse/ARCH-2109

To test :
Use referral service branch: ARCH-2019-rraise-on-missing-i18n-translations-in-development, and run the specs . They should be all green .

update spicerack line in Gemfile to following :
gem "spicerack", git: "git@github.com:Freshly/spicerack.git", branch: "ARCH-2109-assert-have-error-on-attribute-matcher-doesnt-raise"

run bundle install

run the rspecs, you should have a failure for a missing translation :

  1) CreateExtoleReferralState Validations #identity_token_present? when the referrer does not have an identity_token behaves like an invalid state returns the correct error message
     Failure/Error: expect(state).to have_error_on_attribute(attribute).with_detail_key(expected_key)

     I18n::MissingTranslationData:
       translation missing: en.activemodel.errors.models.create_extole_referral_state.attributes.identity_token.referrer_must_have_identity_token

@@ -26,6 +26,7 @@
@errors = (record.errors.details[attribute.to_sym] || []).pluck(:error).map(&:to_sym)

expect(@errors).to include(@detail_key.to_sym)
expect(record.errors.messages).to_not raise_error(I18n::MissingTranslationData)
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems a little heavy-handed. maybe record.errors[attribute] just to limit the scope?

@@ -26,6 +26,7 @@
@errors = (record.errors.details[attribute.to_sym] || []).pluck(:error).map(&:to_sym)

expect(@errors).to include(@detail_key.to_sym)
expect(record.errors[attribute.to_sym]).to_not raise_error(I18n::MissingTranslationData)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe raise_error shouldn't take an argument I18n::MissingTranslationData since that is specific to our use case and this is a public gem. expect(record.errors[attribute.to_sym]).to_not raise_error should still work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@tbconroy
Copy link
Contributor

tbconroy commented Apr 12, 2021

@MichelleMik question: are there no tests to test this matcher? That might be a dumb question 😬

@MichelleMik
Copy link
Contributor Author

@MichelleMik question are there no tests to test this matcher? That might be a dumb question 😬

@tbconroy didnt find any

Copy link

@pearlshin pearlshin left a comment

Choose a reason for hiding this comment

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

tested locally 👍

@arettberg arettberg merged commit 844c63d into develop Apr 12, 2021
@arettberg arettberg deleted the ARCH-2109-assert-have-error-on-attribute-matcher-doesnt-raise branch April 12, 2021 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants