shoulda-matchers v2.8.0 Release Notes
Release Date: 2015-01-30 // over 9 years ago-
๐ Deprecations
ensure_length_of
has been renamed tovalidate_length_of
.ensure_length_of
is deprecated and will be removed in 3.0.0.set_the_flash
has been renamed toset_flash
.set_the_flash
is deprecated and will be removed in 3.0.0.๐
set_session(:foo)
is deprecated in favor ofset_session[:foo]
.set_session(:foo)
will be invalid syntax in 3.0.0.Using
should set_session[:key].to(nil)
to assert that that a value has not been set is deprecated. Please useshould_not set_session[:key]
instead. In 3.0.0,should set_session[:key].to(nil)
will only pass if the value is truly nil.
๐ Bug fixes
๐ Fix
delegate_method
so that it works again with shoulda-context. (#591)Fix
validate_uniqueness_of
when used withscoped_to
so that when one of the scope attributes is a polymorphic*_type
attribute and the model has another validation on the same attribute, the matcher does not fail with an error. (#592)๐ Fix
has_many
used withthrough
so that when the association does not exist, and the matcher fails, it does not raise an error when producing the failure message. (#588)Fix
have_and_belong_to_many
used withjoin_table
so that it does not fail whenforeign_key
and/orassociation_foreign_key
was specified on the association as a symbol instead of a string. (#584)๐ Fix
allow_value
when an i18n translation key is passed towith_message
and the:against
option is used to specify an alternate attribute. A bug here also happened to affectvalidate_confirmation_of
when an i18n translation key is passed towith_message
. (#593)๐ Fix
class_name
qualifier for association matchers so that if the model being referenced is namespaced, the matcher will correctly resolve the class before checking it against the association'sclass_name
. (#537)Fix
validate_inclusion_of
used withwith_message
so that it fails if given a message that does not match the message on the validation. (#598)๐ Fix
route
matcher so that when controller and action are specified in hash notation (e.g.posts#show
), route parameters such asid
do not need to be specified as a string but may be specified as a number as well. (#602)
๐ Features
โ Add ability to test
:primary_key
option on associations. (#597)Add
allow_blank
qualifier tovalidate_uniqueness_of
to complement theallow_blank
option. (#543)๐ Change
set_session
so that #[] and #to qualifiers are optional, similar toset_flash
. That is, you can now sayshould set_session
to assert that any flash value has been set, orshould set_session.to('value')
to assert that any value in the session is 'value'.๐ Change
set_session
so that its #to qualifier supports regexps, similar toset_flash
.Add
with_prefix
qualifier todelegate_method
to correspond to theprefix
option for Rails'sdelegate
macro. (#622)โ Add support for Rails 4.2, especially fixing
serialize
matcher to remove warning aboutserialized_attributes
being deprecated. (#627)โก๏ธ Update
dependent
qualifier on association matchers to support:destroy
,:delete
,:nullify
,:restrict
,:restrict_with_exception
, and:restrict_with_error
. You can also passtrue
orfalse
to assert that the association has (or has not) been declared with any dependent option. (#631)
๐ Improvements
- ๐ Tweak
allow_value
failure message so that it reads a bit nicer when listing existing errors.