Skip to content

Commit

Permalink
Fix validate_inclusion_of + with_message
Browse files Browse the repository at this point in the history
It did not fail if the given message did not match the message on the
validation itself.
  • Loading branch information
mcmire committed Nov 18, 2014
1 parent 2162965 commit aa33ab5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
referenced is namespaced, the matcher will correctly resolve the class before
checking it against the association's `class_name`. ([#537])

* Fix `validate_inclusion_of` used with `with_message` so that it fails if given
a message that does not match the message on the validation. ([#598])

### Features

* Add ability to test `:primary_key` option on associations. ([#597])
Expand All @@ -47,6 +50,8 @@
[#593]: https://github.com/thoughtbot/shoulda-matchers/pull/593
[#597]: https://github.com/thoughtbot/shoulda-matchers/pull/597
[#537]: https://github.com/thoughtbot/shoulda-matchers/pull/537
[#595]: https://github.com/thoughtbot/shoulda-matchers/pull/595
[#598]: https://github.com/thoughtbot/shoulda-matchers/pull/598

# 2.7.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ def disallows_value_outside_of_array?
end
end

!allows_value_of(*values_outside_of_array)
!values_outside_of_array.any? do |value|
allows_value_of(value, @low_message)
end
end

def values_outside_of_array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ def add_outside_value_to(values)
end

it 'does not match when validation uses the default message instead of given message' do
skip 'does not work'

builder = build_object_allowing(valid_values)

expect_not_to_match_on_values(builder, valid_values) do |matcher|
Expand All @@ -198,8 +196,6 @@ def add_outside_value_to(values)
end

it 'does not match when validation uses a message but it is not same as given' do
skip 'does not work'

builder = build_object_allowing(valid_values, message: 'a different message')

expect_not_to_match_on_values(builder, valid_values) do |matcher|
Expand All @@ -218,8 +214,6 @@ def add_outside_value_to(values)
end

it 'does not match when validation uses the default message instead of given message' do
skip 'does not work'

builder = build_object_allowing(valid_values)

expect_not_to_match_on_values(builder, valid_values) do |matcher|
Expand All @@ -228,8 +222,6 @@ def add_outside_value_to(values)
end

it 'does not match when validation uses a message but it does not match regex' do
skip 'does not work'

builder = build_object_allowing(valid_values, message: 'a different message')

expect_not_to_match_on_values(builder, valid_values) do |matcher|
Expand Down

0 comments on commit aa33ab5

Please sign in to comment.