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

Message matching is wrong for strict matchers #973

Closed
samstickland opened this issue Nov 4, 2016 · 4 comments
Closed

Message matching is wrong for strict matchers #973

samstickland opened this issue Nov 4, 2016 · 4 comments

Comments

@samstickland
Copy link

Hi,

The strict tests don't seem to take into account that the Exception message includes the field name.

Given this validation:

validates :username, length: { minimum: 3 }, strict: true

And this test:

it { is_expected.to validate_length_of(:username).is_at_least(3).strict }

I get the following test failure:

       User did not properly validate that the length of :username is at least
       3, raising a validation exception on failure.
         After setting :username to ‹"xx"›, the matcher expected the User to be
         invalid and to raise a validation exception with message "is too short
         (minimum is 3 characters)". The record was indeed invalid, but the
         exception message was "Username is too short (minimum is 3
         characters)" instead.

This is with shoulda-matchers 3.1.1 and Rails 4.2.7

@kheppenstall
Copy link

kheppenstall commented Apr 6, 2017

Hello,

Just wanted to confirm this bug report as I ran into the same problem.

With the following test and validation I get the error message below:

Validation:

  validates :name, length: { minimum: 3 }, strict: true

Test:

it { is_expected.to validate_length_of(:name).is_at_least(3).strict }

screen shot 2017-04-06 at 11 12 37 am

However, with the following validation and test (without the strict) the test passes:

Validation:

  validates :name, length: { minimum: 3 }

Test:

  it { is_expected.to validate_length_of(:name).is_at_least(3) }

screen shot 2017-04-06 at 11 14 57 am

@emcooper
Copy link

emcooper commented Nov 6, 2017

Hi there! I’m a big fan of shoulda-matchers and was hoping to help out with this issue. I noticed nobody was assigned to it, but if there’s already a solution in progress I’m happy to try helping out elsewhere. Thanks!

@mcmire
Copy link
Collaborator

mcmire commented Nov 8, 2017

Hey @emcooper! No one's started working on this yet and it's been sitting here for quite some time as you can see. We would sure love some help in fixing this if you'd like to take a crack at it!

@mcmire
Copy link
Collaborator

mcmire commented May 6, 2020

Hey folks. In an effort to lighten our load as maintainers and be able to serve you better in the future, the shoulda-matchers team is working on cleaning out the cobwebs in this repo by pruning the backlog. As there are few of us, there are a lot of items that will simply never earn our attention in a reasonable time frame, and rather than giving you an empty promise, we think it makes more sense to focus on more recent issues. That means, unfortunately, that we must close this issue.

Don't take this the wrong way: our aim is not to diminish the effort people have made or dismiss problems that have been raised. If you feel that we should reopen this issue, then please let us know so that we can reprioritize it. Thanks!

@mcmire mcmire closed this as completed May 6, 2020
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

4 participants