thoughtbot--shoulda-matchers/lib/shoulda/matchers
Elliot Winkler ebe60449ee Fix inclusion to correctly disallow outside values
The inclusion matcher, when qualified with `in_array`, was using
AllowValueMatcher to check that values outside the array were disallowed
by the model (and then inverting its result). However, it should have
been using DisallowValueMatcher all this time. This commit fixes that.

Without this fix, the following error is raised when using the inclusion
matcher against a model which does not have the proper inclusion
validation on it:

    undefined method `attribute_setter' for nil:NilClass

This happens because the inclusion matcher is a complex matcher, i.e.,
it runs a series of submatchers internally and the result of those
submatchers contributes to whether or not the matcher matches. If one of
those submatchers fails, the inclusion matcher immediately fails and
spits out the failure message associated with that submatcher.

However, there is a fundamental difference between AllowValueMatcher and
DisallowValueMatcher as it relates to how they function:

* AllowValueMatcher sets an attribute to a value on a record and expects
  the record not to fail validation.
* DisallowValueMatcher sets an attribute to a value on a record, but
  expects the record *to* fail validation.

The issue in this case is that, because AllowValueMatcher was used
instead of DisallowValueMatcher, the inclusion matcher thought that the
AllowValueMatcher failed, when in fact it passed (this result was just
inverted). So it tried to generate a failure message for a matcher that
didn't fail in the first place. By using DisallowValueMatcher, we set
the proper expectations.
2018-09-15 13:43:30 -03:00
..
action_controller Replace the with_port qualifier on route with port option 2018-01-25 22:31:23 -06:00
active_model Fix inclusion to correctly disallow outside values 2018-09-15 13:43:30 -03:00
active_record Fix typo (#1119) 2018-08-10 14:36:12 +01:00
doublespeak Doublespeak: Define #respond_to_missing? on ObjectDouble 2017-09-17 17:46:06 -05:00
independent Update docs for delegate_method 2018-01-24 02:54:30 -06:00
integrations Add a new Routing module 2015-09-25 17:45:33 -06:00
util Improve failure messages for define_enum_for 2018-01-28 00:47:44 -06:00
action_controller.rb Rename StrongParametersMatcher to PermitMatcher 2015-02-28 19:30:33 -07:00
active_model.rb Update RSpec test style across docs 2016-06-15 18:02:07 -06:00
active_record.rb Merge pull request #1058 from thoughtbot/add-optional-and-required 2017-10-18 20:26:46 -02:00
configuration.rb Remove auto-detection of Rails / test framework 2015-02-09 10:52:51 -07:00
doublespeak.rb Permit matcher now supports subparameters 2015-03-01 01:32:00 -07:00
error.rb Tighten CouldNotSetAttributeError restriction 2015-09-27 14:56:59 -06:00
independent.rb Rename DelegateMatcher to DelegateMethodMatcher 2014-08-29 11:57:26 -06:00
integrations.rb Omit newest private modules from docs 2015-03-01 01:20:45 -07:00
matcher_context.rb Documentation updates 2014-12-25 01:13:30 -05:00
rails_shim.rb Add required/optional qual's to belongs_to/has_one 2017-10-06 23:38:47 -05:00
routing.rb Replace the with_port qualifier on route with port option 2018-01-25 22:31:23 -06:00
util.rb Improve failure messages for define_enum_for 2018-01-28 00:47:44 -06:00
version.rb Bump version to 3.1.2 2017-01-09 21:53:20 -05:00
warn.rb Improve the word_wrap utility method 2015-10-08 21:30:41 -06:00