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

with_message + strict + against doesn't seem to work #1279

Open
mcmire opened this issue Feb 21, 2020 · 0 comments
Open

with_message + strict + against doesn't seem to work #1279

mcmire opened this issue Feb 21, 2020 · 0 comments

Comments

@mcmire
Copy link
Collaborator

mcmire commented Feb 21, 2020

When using allow_value in combination with with_message(..., against: ...) and strict, against seems to be getting ignored.

Example:

it do
  should_not allow_value('34:21:92')
    .for(:time)
    .with_message('is not a valid date/time', against: :starts_at)
    .strict
end

This will produce an error like:

After setting :time to ‹"34:21:92"›, the matcher expected the FollowUp to be invalid and to raise a validation exception with message "is not a valid date/time". The record was indeed invalid, but the exception message was "Starts at is not a valid date/time" instead.

In order to fix this, I need to say:

it do
  should_not allow_value('34:21:92')
    .for(:time)
    .with_message('Starts at is not a valid date/time')
    .strict
end

But this seems to defeat the point of using against.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant