diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-05-01 18:31:33 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-05-01 18:31:33 -0700 |
commit | b3a74a14a3d6efa22a07116c4cb26aadc479fb41 (patch) | |
tree | f5e7fe3933183c796cf82d2bada32417eb0b65e8 /activemodel/test/cases/validations/format_validation_test.rb | |
parent | dd1f36078eff18721eed76d236796c8d26d81e58 (diff) | |
parent | eebb9ddf9ba559a510975c486fe59a4edc9da97d (diff) | |
download | rails-b3a74a14a3d6efa22a07116c4cb26aadc479fb41.tar.gz rails-b3a74a14a3d6efa22a07116c4cb26aadc479fb41.tar.bz2 rails-b3a74a14a3d6efa22a07116c4cb26aadc479fb41.zip |
Merge pull request #10408 from patricksrobertson/convert_activemodel_to_new_hash_syntax
Convert ActiveModel to 1.9 hash syntax.
Diffstat (limited to 'activemodel/test/cases/validations/format_validation_test.rb')
-rw-r--r-- | activemodel/test/cases/validations/format_validation_test.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/activemodel/test/cases/validations/format_validation_test.rb b/activemodel/test/cases/validations/format_validation_test.rb index 308a3c6cef..26e8dbf19c 100644 --- a/activemodel/test/cases/validations/format_validation_test.rb +++ b/activemodel/test/cases/validations/format_validation_test.rb @@ -11,7 +11,7 @@ class PresenceValidationTest < ActiveModel::TestCase end def test_validate_format - Topic.validates_format_of(:title, :content, :with => /\AValidation\smacros \w+!\z/, :message => "is bad data") + Topic.validates_format_of(:title, :content, with: /\AValidation\smacros \w+!\z/, message: "is bad data") t = Topic.new("title" => "i'm incorrect", "content" => "Validation macros rule!") assert t.invalid?, "Shouldn't be valid" @@ -27,7 +27,7 @@ class PresenceValidationTest < ActiveModel::TestCase end def test_validate_format_with_allow_blank - Topic.validates_format_of(:title, :with => /\AValidation\smacros \w+!\z/, :allow_blank => true) + Topic.validates_format_of(:title, with: /\AValidation\smacros \w+!\z/, allow_blank: true) assert Topic.new("title" => "Shouldn't be valid").invalid? assert Topic.new("title" => "").valid? assert Topic.new("title" => nil).valid? @@ -36,7 +36,7 @@ class PresenceValidationTest < ActiveModel::TestCase # testing ticket #3142 def test_validate_format_numeric - Topic.validates_format_of(:title, :content, :with => /\A[1-9][0-9]*\z/, :message => "is bad data") + Topic.validates_format_of(:title, :content, with: /\A[1-9][0-9]*\z/, message: "is bad data") t = Topic.new("title" => "72x", "content" => "6789") assert t.invalid?, "Shouldn't be valid" @@ -63,24 +63,24 @@ class PresenceValidationTest < ActiveModel::TestCase end def test_validate_format_with_formatted_message - Topic.validates_format_of(:title, :with => /\AValid Title\z/, :message => "can't be %{value}") - t = Topic.new(:title => 'Invalid title') + Topic.validates_format_of(:title, with: /\AValid Title\z/, message: "can't be %{value}") + t = Topic.new(title: 'Invalid title') assert t.invalid? assert_equal ["can't be Invalid title"], t.errors[:title] end def test_validate_format_of_with_multiline_regexp_should_raise_error - assert_raise(ArgumentError) { Topic.validates_format_of(:title, :with => /^Valid Title$/) } + assert_raise(ArgumentError) { Topic.validates_format_of(:title, with: /^Valid Title$/) } end def test_validate_format_of_with_multiline_regexp_and_option assert_nothing_raised(ArgumentError) do - Topic.validates_format_of(:title, :with => /^Valid Title$/, :multiline => true) + Topic.validates_format_of(:title, with: /^Valid Title$/, multiline: true) end end def test_validate_format_with_not_option - Topic.validates_format_of(:title, :without => /foo/, :message => "should not contain foo") + Topic.validates_format_of(:title, without: /foo/, message: "should not contain foo") t = Topic.new t.title = "foobar" @@ -97,19 +97,19 @@ class PresenceValidationTest < ActiveModel::TestCase end def test_validates_format_of_with_both_regexps_should_raise_error - assert_raise(ArgumentError) { Topic.validates_format_of(:title, :with => /this/, :without => /that/) } + assert_raise(ArgumentError) { Topic.validates_format_of(:title, with: /this/, without: /that/) } end def test_validates_format_of_when_with_isnt_a_regexp_should_raise_error - assert_raise(ArgumentError) { Topic.validates_format_of(:title, :with => "clearly not a regexp") } + assert_raise(ArgumentError) { Topic.validates_format_of(:title, with: "clearly not a regexp") } end def test_validates_format_of_when_not_isnt_a_regexp_should_raise_error - assert_raise(ArgumentError) { Topic.validates_format_of(:title, :without => "clearly not a regexp") } + assert_raise(ArgumentError) { Topic.validates_format_of(:title, without: "clearly not a regexp") } end def test_validates_format_of_with_lambda - Topic.validates_format_of :content, :with => lambda{ |topic| topic.title == "digit" ? /\A\d+\Z/ : /\A\S+\Z/ } + Topic.validates_format_of :content, with: lambda { |topic| topic.title == "digit" ? /\A\d+\Z/ : /\A\S+\Z/ } t = Topic.new t.title = "digit" @@ -121,7 +121,7 @@ class PresenceValidationTest < ActiveModel::TestCase end def test_validates_format_of_without_lambda - Topic.validates_format_of :content, :without => lambda{ |topic| topic.title == "characters" ? /\A\d+\Z/ : /\A\S+\Z/ } + Topic.validates_format_of :content, without: lambda { |topic| topic.title == "characters" ? /\A\d+\Z/ : /\A\S+\Z/ } t = Topic.new t.title = "characters" @@ -133,7 +133,7 @@ class PresenceValidationTest < ActiveModel::TestCase end def test_validates_format_of_for_ruby_class - Person.validates_format_of :karma, :with => /\A\d+\Z/ + Person.validates_format_of :karma, with: /\A\d+\Z/ p = Person.new p.karma = "Pixies" |