diff options
Diffstat (limited to 'activemodel/test/cases/validations/format_validation_test.rb')
-rw-r--r-- | activemodel/test/cases/validations/format_validation_test.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/format_validation_test.rb b/activemodel/test/cases/validations/format_validation_test.rb index 301cb36e61..2c06a9dd02 100644 --- a/activemodel/test/cases/validations/format_validation_test.rb +++ b/activemodel/test/cases/validations/format_validation_test.rb @@ -3,6 +3,8 @@ require 'cases/helper' require 'cases/tests_database' require 'models/topic' +require 'models/developer' +require 'models/person' class PresenceValidationTest < ActiveModel::TestCase include ActiveModel::TestsDatabase @@ -78,4 +80,19 @@ class PresenceValidationTest < ActiveModel::TestCase assert_equal ["format 'single' and \"double\" quotes"], d.errors[:name] end end + + def test_validates_format_of_for_ruby_class + repair_validations(Person) do + Person.validates_format_of :karma, :with => /\A\d+\Z/ + + p = Person.new + p.karma = "Pixies" + assert p.invalid? + + assert_equal ["is invalid"], p.errors[:karma] + + p.karma = "1234" + assert p.valid? + end + end end |