Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix is_equal_to submatcher for validates_numericality_of #326

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# HEAD

* Fix `is_equal_to` submatcher bug for `validates_numericality_of`

* Fix context support for validation matchers and disallowed values.

* Add a `counter_cache` submatcher for `belongs_to` associations
Expand Down
2 changes: 1 addition & 1 deletion lib/shoulda/matchers/active_model/comparison_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def value_to_compare
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
Expand Down
5 changes: 5 additions & 0 deletions spec/shoulda/matchers/active_model/comparison_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
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
Expand Down