validate_uniqueness_of expects has been taken, receives is taken #100

Closed
patrickhno opened this Issue Apr 20, 2012 · 6 comments

Comments

Projects
None yet
5 participants

Any knowledge of this weirdness?

Failure/Error: it { should validate_uniqueness_of(:index) }
Expected errors to include "has already been taken" when index is set to "OSE", got errors: ["calendar can't be blank (nil)", "post_trade_at can't be blank (nil)", "index is already taken ("OSE")"]

As seen, index taken is reported, but the expectation tests for a different error string, or at least so it says.

rails 3.2
shoulda-matchers 1.1.0

Contributor

gabebw commented Apr 20, 2012

shoulda-matchers looks up the localized error message (or at least it should). Do you have anything in config/locales/?

I don't, but there is a conflict with mongoid.
The obvious workaround would be:

en:
  mongoid:
    errors:
      messages:
        taken:
          has already been taken
Owner

mike-burns commented Jul 9, 2012

We could change lib/shoulda/matchers/active_model/helpers.rb#default_error_message to include the mongoid messages, too.

Contributor

gabebw commented Dec 27, 2012

@patrickhno, does the latest version of shoulda-matchers from HEAD fix this problem?

# Gemfile
gem "shoulda-matchers", :git => "git://github.com/thoughtbot/shoulda-matchers.git"
Member

mxie commented Mar 28, 2013

@patrickhno Have you tried updating your shoulda-matchers to see if the issue has been resolved? There have been many changes since 1.1.0.

Owner

drapergeek commented May 6, 2013

This should be fixed in version 2.1.0. Please reply back if it is not and we will reopen. Thanks.

drapergeek closed this May 6, 2013

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