Making tests easy on the fingers and eyes

Critical or Security advisories for 2.6.0

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

Changelog for 2.6.0

  • The boolean argument to have_db_index's unique option is now optional, for consistency with other matchers.

  • Association matchers now test that the model being referred to (either implicitly or explicitly, using :class_name) actually exists.

  • Add ability to test :autosave option on associations.

  • Fix validate_uniqueness_of(...).allow_nil so that it can be used against an non-password attribute which is in a model that has_secure_password. Doing so previously would result in a "Password digest missing on new record" error.

  • Fix description for validate_numericality_of so that if the matcher fails, the error message reported does not say the matcher accepts integer values if you didn't specify that.

  • Fix ensure_inclusion_of so that you can use it against a boolean column (and pass boolean values to in_array). There are two caveats:

    • You should not test that your attribute allows both true and false (.in_array([true, false]); there's no way to test that it doesn't accept anything other than that.
    • You cannot test that your attribute allows nil (.in_array([nil])) if the column does not allow null values.
  • Change validate_uniqueness_of(...) so that it provides default values for non-nullable attributes.

  • Running rake now installs Appraisals before running the test suite. (Additionally, we now manage Appraisals using the appraisal executable in Appraisal 1.0.0.)

  • Add allow_nil option to validate_numericality_of so that you can validate that numeric values are validated only if a value is supplied.

  • Fix validate_numericality_of so that test fails when the value with greater_than, greater_than_or_equal_to, less_than, less_than_or_equal_ to or equal_to is not appropriate.

  • Change validate_presence_of under Rails 4 so that if you are using it with a user whose model has_secure_password and whose password is set to a value, you will be instructed to use a user whose password is blank instead. The reason for this change is due to the fact that Rails 4's version of has_secure_password defines #password= such that nil will be ignored, which interferes with how validate_presence_of works.

  • Add ability to test belongs_to associations defined with :inverse_of.

  • Add back matchers that were removed in 2.0.0: permit, for testing strong parameters, and delegate_method, for testing delegation.

  • Add new matchers for testing controller filters: before_filter, after_filter, and around_filter (aliased to before_action, after_action and around_action for Rails 4).

  • Fix rescue_from matcher so that it does not raise an error when testing a method handler which has been marked as protected or private.

  • Fix compatibility issues with Rails 4.1:

    • set_the_flash and have_and_belongs_to_many no longer raise errors
    • Minitest no longer prints warnings whenever shoulda-matchers is required

Dependencies for 2.6.0

Name Requirement Status
Gems activesupport >= 3.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.