fix is_equal_to submatcher for validates_numericality_of

This commit is contained in:
barelyknown 2013-07-29 22:31:24 -05:00 committed by Elliot Winkler
parent 530303300b
commit e5dfedb80c
3 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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