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 Oct 10, 2014
1 parent 0dd79ce commit e066c0d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
when `foreign_key` and/or `association_foreign_key` was specified on the
association as a symbol instead of a string. ([#584])

* 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. ([#592])

[#591]: https://github.com/thoughtbot/shoulda-matchers/pull/591
[#592]: https://github.com/thoughtbot/shoulda-matchers/pull/592
[#588]: https://github.com/thoughtbot/shoulda-matchers/pull/588
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def disallows_value_outside_of_array?
end
end

!allows_value_of(*values_outside_of_array)
!allows_value_of(*values_outside_of_array, @low_message)
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 e066c0d

Please sign in to comment.