Permalink
Browse files

Added test for obj.errors.as_json

  • Loading branch information...
1 parent f5a944f commit 8817796167d6aba16e67b99ad4010500a797f2c4 @lawrencepit lawrencepit committed Sep 9, 2011
Showing with 11 additions and 0 deletions.
  1. +11 −0 activemodel/test/cases/errors_test.rb
View
11 activemodel/test/cases/errors_test.rb
@@ -102,4 +102,15 @@ def test_has_key?
assert_equal "name can not be blank", person.errors.full_message(:name, "can not be blank")
end
+ test 'should return a JSON hash representation of the errors' do
+ person = Person.new
+ person.errors.add(:name, "can not be blank")
+ person.errors.add(:name, "can not be nil")
+ person.errors.add(:email, "is invalid")
+ hash = person.errors.as_json
+ assert_equal ["can not be blank", "can not be nil"], hash[:name]
+ assert_equal ["is invalid"], hash[:email]
+ end
+
end
+

0 comments on commit 8817796

Please sign in to comment.