1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
Commit graph

16 commits

Author SHA1 Message Date
Elliot Winkler
a4045a1f9b Remove Rails 3.x, Ruby 1.9.2, Ruby 1.9.3
Ruby 1.9.3 will be end-of-lifed on February 23, 2015. We might as well
remove support for it now.
2015-02-09 10:52:22 -07:00
Elliot Winkler
d7f7f58637 Remove debugger, byebug, and web-console from 4.2
debugger and byebug cannot be present in Appraisals because they only
work on specific Ruby versions, and we test against a range of Ruby
versions. Hence, they can't be present in the Rails application that
gets generated in acceptance tests, either.

Also, we don't really need web-console to be there, it's just an extra
dependency.
2015-02-05 10:22:12 -07:00
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
Elliot Winkler
de111ea5e8 Improve output of fail_with_message matcher 2015-01-22 21:05:08 -07:00
Elliot Winkler
c49241601f Remove warning about #capture under 4.2+ 2014-12-25 00:45:06 -05:00
Elliot Winkler
547d8b762f Fix AR matcher tests for Rails 4.2 2014-12-25 00:45:06 -05:00
Elliot Winkler
fab4f02da3 Fix AC matcher tests for Rails 4.2
Modify helper methods provided by ControllerBuilder so that we use as
much of rspec-rails's controller example group capabilities as possible.
All of this can still be improved but this is a good start for now.
2014-12-25 00:45:04 -05:00
Elliot Winkler
8e049c149f Improve failure messages for failure message matchers 2014-12-16 20:31:31 -07:00
Elliot Winkler
ab08fef63e Fix warning for this file 2014-12-16 20:21:22 -07:00
Elliot Winkler
b84ec8cc16 Bring set_session in line with set_flash
* Deprecate `set_session(:foo)` in favor of `set_session[:foo]`
* Make both #[] and #to optional (`should set_session` simply checks
  that the session is non-empty, `should set_session.to('value')` checks
  that *any* value is 'value')
* Add support for regexps to #to
* Deprecate `should set_session(...).to(nil)` in favor of using
  `should_not set_session`
* Improve failure message
2014-11-21 14:27:44 -07:00
Elliot Winkler
c8fb8022b1 Deprecate set_the_flash in favor of set_flash 2014-11-21 14:24:00 -07:00
Elliot Winkler
df6c0ef56e Clear schema cache after each test
When running unit tests in a random order, some tests may fail as the
columns hash within a model may not be in sync with the database. This
is because the columns hash is cached outside of the model, so removing
the model from the object space and then recreating that model won't
clear the columns hash.
2014-11-06 14:16:17 -07:00
Elliot Winkler
4c9dfa7616 Fix another warning 2014-11-05 16:39:04 -07:00
Elliot Winkler
366026b937 Fix unit tests to use new acceptance stuff 2014-11-05 09:53:53 -07:00
Elliot Winkler
f922613386 Reorganize unit tests, part II
* Change 'spec' Rake task to 'spec:unit'
* Require unit_spec_helper.rb in unit tests, not spec_helper.rb
* Re-namespace files in spec/support/unit under UnitTests
* Files in spec/support/unit/helpers no longer automatically add
  themselves to RSpec - this happens in unit_spec_helper.rb
* Extract RecordWithDifferentErrorAttributeBuilder and
  RecordValidatingConfirmationBuilder to separate files
2014-11-05 09:53:20 -07:00
Elliot Winkler
bbdf8a807e Reorganize unit tests, part I
* Move spec/shoulda to spec/unit_tests/shoulda
* Move spec/support/*.rb to spec/support/unit_tests/{helpers,matchers}
* Move spec_helper.rb to unit_spec_helper.rb
2014-11-04 14:43:59 -07:00