aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/test/base_errors_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-09-21 23:31:21 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-09-21 23:31:21 +0000
commitf99e5bba192938ed7e812f1ae82785ad796c636d (patch)
tree826e05f963c939db3d0640c87f8daeaebbbe4e43 /activeresource/test/base_errors_test.rb
parent6dd10d85dab9d2623deb3dc4a61106ca9be1d981 (diff)
downloadrails-f99e5bba192938ed7e812f1ae82785ad796c636d.tar.gz
rails-f99e5bba192938ed7e812f1ae82785ad796c636d.tar.bz2
rails-f99e5bba192938ed7e812f1ae82785ad796c636d.zip
Increase test coverage (closes #8699, #8700) [josh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7532 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/test/base_errors_test.rb')
-rw-r--r--activeresource/test/base_errors_test.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/activeresource/test/base_errors_test.rb b/activeresource/test/base_errors_test.rb
index 3527eb2353..f9aa58016d 100644
--- a/activeresource/test/base_errors_test.rb
+++ b/activeresource/test/base_errors_test.rb
@@ -9,22 +9,35 @@ class BaseErrorsTest < Test::Unit::TestCase
@person = Person.new(:name => '', :age => '')
assert_equal @person.save, false
end
-
+
def test_should_mark_as_invalid
assert !@person.valid?
end
-
+
def test_should_parse_xml_errors
assert_kind_of ActiveResource::Errors, @person.errors
assert_equal 4, @person.errors.size
end
def test_should_parse_errors_to_individual_attributes
+ assert @person.errors.invalid?(:name)
assert_equal "can't be blank", @person.errors.on(:age)
assert_equal ["can't be blank", "must start with a letter"], @person.errors[:name]
assert_equal "Person quota full for today.", @person.errors.on_base
end
+ def test_should_iterate_over_errors
+ errors = []
+ @person.errors.each { |attribute, message| errors << [attribute, message] }
+ assert_equal ["name", "can't be blank"], errors.first
+ end
+
+ def test_should_iterate_over_full_errors
+ errors = []
+ @person.errors.each_full { |message| errors << message }
+ assert_equal "Name can't be blank", errors.first
+ end
+
def test_should_format_full_errors
full = @person.errors.full_messages
assert full.include?("Age can't be blank")