mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
fix is_equal_to submatcher for validates_numericality_of
This commit is contained in:
parent
530303300b
commit
e5dfedb80c
3 changed files with 9 additions and 1 deletions
3
NEWS.md
3
NEWS.md
|
@ -1,5 +1,8 @@
|
|||
# HEAD
|
||||
|
||||
* Fix `validates_numericality_of` so that `is_equal_to` submatcher works
|
||||
correctly (#326).
|
||||
|
||||
* Fix context support for validation matchers and disallowed values.
|
||||
|
||||
* Add a `counter_cache` submatcher for `belongs_to` associations
|
||||
|
|
|
@ -31,7 +31,7 @@ module Shoulda # :nodoc:
|
|||
case @operator
|
||||
when :> then [@value, @value - 1].sample
|
||||
when :>= then @value - 1
|
||||
when :== then @value
|
||||
when :== then @value + 1
|
||||
when :< then [@value, @value + 1].sample
|
||||
when :<= then @value + 1
|
||||
end
|
||||
|
|
|
@ -21,6 +21,11 @@ describe Shoulda::Matchers::ActiveModel::ComparisonMatcher do
|
|||
it { instance_without_validations.should_not matcher.is_less_than_or_equal_to(2) }
|
||||
end
|
||||
|
||||
context 'is_equal_to' do
|
||||
it { instance_with_validations(:equal_to => 0).should matcher.is_equal_to(0) }
|
||||
it { instance_without_validations.should_not matcher.is_equal_to(0) }
|
||||
end
|
||||
|
||||
def instance_with_validations(options = {})
|
||||
define_model :example, :attr => :string do
|
||||
validates_numericality_of :attr, options
|
||||
|
|
Loading…
Add table
Reference in a new issue