Ticket #8700: improve_ares_validations_test_coverage.diff
| File improve_ares_validations_test_coverage.diff, 1.4 kB (added by josh, 2 years ago) |
|---|
-
activeresource/test/base_errors_test.rb
old new 9 9 @person = Person.new(:name => '', :age => '') 10 10 assert_equal @person.save, false 11 11 end 12 12 13 13 def test_should_mark_as_invalid 14 14 assert !@person.valid? 15 15 end 16 16 17 17 def test_should_parse_xml_errors 18 18 assert_kind_of ActiveResource::Errors, @person.errors 19 19 assert_equal 4, @person.errors.size 20 20 end 21 21 22 22 def test_should_parse_errors_to_individual_attributes 23 assert @person.errors.invalid?(:name) 23 24 assert_equal "can't be blank", @person.errors.on(:age) 24 25 assert_equal ["can't be blank", "must start with a letter"], @person.errors[:name] 25 26 assert_equal "Person quota full for today.", @person.errors.on_base 26 27 end 27 28 29 def test_should_iterate_over_errors 30 errors = [] 31 @person.errors.each { |attribute, message| errors << [attribute, message] } 32 assert_equal ["name", "can't be blank"], errors.first 33 end 34 35 def test_should_iterate_over_full_errors 36 errors = [] 37 @person.errors.each_full { |message| errors << message } 38 assert_equal "Name can't be blank", errors.first 39 end 40 28 41 def test_should_format_full_errors 29 42 full = @person.errors.full_messages 30 43 assert full.include?("Age can't be blank")