mirror of https://github.com/rails/rails
Merge pull request #17022 from prathamesh-sonpatki/test-for-validate-message
Added test for exception message for validate method
This commit is contained in:
commit
92cef19519
|
@ -167,10 +167,12 @@ class ValidationsTest < ActiveModel::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_options_to_validate
|
def test_invalid_options_to_validate
|
||||||
assert_raises(ArgumentError) do
|
error = assert_raises(ArgumentError) do
|
||||||
# A common mistake -- we meant to call 'validates'
|
# A common mistake -- we meant to call 'validates'
|
||||||
Topic.validate :title, presence: true
|
Topic.validate :title, presence: true
|
||||||
end
|
end
|
||||||
|
message = 'Unknown key: :presence. Valid keys are: :on, :if, :unless. Perhaps you meant to call `validates` instead of `validate`?'
|
||||||
|
assert_equal message, error.message
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_errors_conversions
|
def test_errors_conversions
|
||||||
|
|
Loading…
Reference in New Issue