-
-
Notifications
You must be signed in to change notification settings - Fork 909
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
Indifference to I18n errors.format
translation
#1492
Comments
Mekajiki
changed the title
Indifference to I18n "errors.format" translation
Indifference to I18n May 10, 2022
errors.format
translation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
When
errors.format
translation is defined differently than%{attribute} %{message}
, a test usingvalidate_presence_of
matcher with
strict
seems not to be proved.Example
If the translations are defined as;
And if you write a test as below;
The test above isn't proved with message like;
The matcher seems to expect a space exists between attribute name and message, but actually doesn't.
Possible Solution
Taking
errors.format
definition into account might be a good solution.Seeing how Ruby on Rails raise exceptions, it uses
errors.format
to compose attribute name and message into a string.https://github.com/rails/rails/blob/4bbd05c90e5a62c0316307b3ca7c2262ed98b567/activemodel/lib/active_model/errors.rb#L290-L294
But validation matcher seems to check messages with fixed format.
shoulda-matchers/lib/shoulda/matchers/active_model/allow_value_matcher.rb
Line 615 in 206d2da
Changing this code into the same manner as in RoR may solve the problem.
The text was updated successfully, but these errors were encountered: