Making tests easy on the fingers and eyes

Critical or Security advisories for 3.1.1

This version doesn't have any advisory. Want to report one?

Changelog for 3.1.1

  • Some matchers make use of ActiveSupport's in? method, but do not include the file where this is defined in ActiveSupport. This causes problems with projects using shoulda-matchers that do not include all of ActiveSupport by default. To fix this, replace in? with Ruby's builtin include?.

    • Pull request: #879
  • validate_uniqueness_of works by creating a record if it doesn't exist, and then testing against a new record with various attributes set that are equal to (or different than) corresponding attributes in the existing record. In 3.1.0 a change was made whereby when the uniqueness matcher is given a new record and creates an existing record out of it, it ensures that the record is valid before continuing on. This created a problem because if the subject, before it was saved, was empty and therefore in an invalid state, it could not effectively be saved. While ideally this should be enforced, doing so would be a backward-incompatible change, so this behavior has been rolled back. (#880, #884, #885)

  • Fix an issue with validate_uniqueness_of + scoped_to when used against a model where the attribute has multiple uniqueness validations and each validation has a different set of scopes. In this case, a test written for the first validation (and its scopes) would pass, but tests for the other validations (and their scopes) would not, as the matcher only considered the first set of scopes as the actual set of scopes.


  • Update validate_uniqueness_of so that if an existing record fails to be created because a column is non-nullable and was not filled in, raise an ExistingRecordInvalid exception with details on how to fix the test.

Dependencies for 3.1.1

Name Requirement Status
>= 4.0.0

My projects using shoulda-matchers

Name Locked version Requirement
You should be logged in to see which of your projects use shoulda-matchers.