diff options
Diffstat (limited to 'activemodel/test/cases/validations/inclusion_validation_test.rb')
-rw-r--r-- | activemodel/test/cases/validations/inclusion_validation_test.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/inclusion_validation_test.rb b/activemodel/test/cases/validations/inclusion_validation_test.rb index 678461a037..bc1b0365d2 100644 --- a/activemodel/test/cases/validations/inclusion_validation_test.rb +++ b/activemodel/test/cases/validations/inclusion_validation_test.rb @@ -3,6 +3,8 @@ require 'cases/helper' require 'cases/tests_database' require 'models/topic' +require 'models/developer' +require 'models/person' class InclusionValidationTest < ActiveModel::TestCase include ActiveModel::TestsDatabase @@ -60,4 +62,19 @@ class InclusionValidationTest < ActiveModel::TestCase assert_equal "This string contains 'single' and \"double\" quotes", d.errors[:salary].last end end + + def test_validates_inclusion_of_for_ruby_class + repair_validations(Person) do + Person.validates_inclusion_of :karma, :in => %w( abe monkey ) + + p = Person.new + p.karma = "Lifo" + assert p.invalid? + + assert_equal ["is not included in the list"], p.errors[:karma] + + p.karma = "monkey" + assert p.valid? + end + end end |