shoulda-matchers v3.1.0 Release Notes

Release Date: 2016-01-11 // over 8 years ago
  • ๐Ÿ› Bug fixes

    • Update validate_numericality_of so that submatchers are applied lazily instead of immediately. Previously, qualifiers were order-dependent, meaning that if you used strict before you used, say, odd, then strict wouldn't actually apply to odd. Now the order that you specify qualifiers doesn't matter. (6c67a5e)

    • ๐Ÿ›  Fix allow_value so that it does not raise an AttributeChangedValueError (formerly CouldNotSetAttributeError) when used against an attribute that is an enum in an ActiveRecord model. (9e8603e)

    • Add a ignoring_interference_by_writer qualifier to all matchers, not just allow_value. This is enabled by default, which means that you should never get a CouldNotSetAttributeError again. (You may get some more information if a test fails, however.) (#786, #799, #801, #804, #817, #841, #849, #872, #873, #874, 1189934, 5532f43)

    • Fix validate_numericality_of so that it does not blow up when used against a virtual attribute defined in an ActiveRecord model (that is, an attribute that is not present in the database but is defined using attr_accessor). (#822)

    • Update validate_numericality_of so that it no longer raises an IneffectiveTestError if used against a numeric column. (#832, 5ed0362)

    ๐Ÿ”‹ Features

    • Add a new qualifier, ignoring_case_sensitivity, to validate_uniqueness_of. This provides a way to test uniqueness of an attribute whose case is normalized, either in a custom writer method for that attribute, or in a custom before_validation callback. (#836, #840)

    ๐Ÿ‘Œ Improvements

    • ๐Ÿ‘Œ Improve failure messages and descriptions of all matchers across the board so that it is easier to understand what the matcher was doing when it failed. (You'll see a huge difference in the output of the numericality and uniqueness matchers in particular.)

    • Matchers now raise an error if any attributes that the matcher is attempting to set do not exist on the model. (2962112)

    • Update validate_numericality_of so that it doesn't always run all of the submatchers, but stops on the first one that fails. Since failure messages now contain information as to what value the matcher set on the attribute when it failed, this change guarantees that the correct value will be shown. (8e24a6e)

    • Continue to detect if attributes change incoming values, but now instead of immediately seeing a CouldNotSetAttributeError, you will only be informed about it if the test you've written fails. (1189934)

    • Add an additional check to define_enum_for to ensure that the column that underlies the enum attribute you're testing is an integer column. (68dd70a)

    • Add a test for validate_numericality_of so that it officially supports money columns. (#841, a559713)