1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/spec
Elliot Winkler 9ba21381d7 Handle RangeErrors emitted now in ActiveRecord 4.2
In Rails 4.2, ActiveRecord was changed such that if you attempt to set
an attribute to a value and that value is outside the range of the
column, then it will raise a RangeError. For instance, an integer column
with a limit of 2 (i.e. a smallint) only accepts values between -32768
and +32767.

This means that if you try to do any of these three things, a RangeError
could be raised:

* Use validate_numericality_of along with any of the comparison
  submatchers and a value that sits on either side of the boundary.
* Use allow_value with a value that sits outside the range.
* Use validates_inclusion_of against an integer column. (Here we attempt
  to set that column to a non-integer value to verify that the attribute
  does not allow said value. That value is really a string version of a
  large number, so if the column does not take large numbers then the
  matcher could blow up.)

Ancillary changes in this commit:

* Remove ValidationMessageFinder and ExceptionMessageFinder in favor of
  Validator, StrictValidator, and ValidatorWithCapturedRangeError.
* The allow_value matcher now uses an instance of Validator under the
  hood. StrictValidator and/or ValidatorWithCapturedRangeError may be
  mixed into the Validator object as needed.
2015-01-22 21:05:09 -07:00
..
acceptance Fix acceptance tests where we should be using Bundler 2014-12-25 00:45:06 -05:00
support Handle RangeErrors emitted now in ActiveRecord 4.2 2015-01-22 21:05:09 -07:00
unit/shoulda/matchers Handle RangeErrors emitted now in ActiveRecord 4.2 2015-01-22 21:05:09 -07:00
warnings_spy Be better about looking for warnings on Travis 2014-12-16 20:30:05 -07:00
acceptance_spec_helper.rb Run tests in a random order 2014-11-06 14:16:51 -07:00
report_warnings.rb Remove all Ruby-emitted warnings 2014-07-18 18:00:08 -06:00
unit_spec_helper.rb Handle RangeErrors emitted now in ActiveRecord 4.2 2015-01-22 21:05:09 -07:00
warnings_spy.rb Remove all Ruby-emitted warnings 2014-07-18 18:00:08 -06:00