From df5691aa94f209a59945d60d750a5040b24dbc40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 11 Apr 2011 17:47:55 +0200 Subject: No need to rescue here. Invoking the wrong method in an object can happen anywhere if you are not careful. In other words, test your shit. --- .../test/cases/validations/exclusion_validation_test.rb | 9 --------- .../test/cases/validations/format_validation_test.rb | 16 ---------------- .../test/cases/validations/inclusion_validation_test.rb | 9 --------- 3 files changed, 34 deletions(-) (limited to 'activemodel/test/cases/validations') diff --git a/activemodel/test/cases/validations/exclusion_validation_test.rb b/activemodel/test/cases/validations/exclusion_validation_test.rb index fe0d13ec33..72a383f128 100644 --- a/activemodel/test/cases/validations/exclusion_validation_test.rb +++ b/activemodel/test/cases/validations/exclusion_validation_test.rb @@ -54,13 +54,4 @@ class ExclusionValidationTest < ActiveModel::TestCase p.title = "wasabi" assert p.valid? end - - def test_validates_exclustion_with_invalid_lambda_return - Topic.validates_exclusion_of :title, :in => lambda{ |topic| false } - - p = Topic.new - p.title = "wasabi" - p.author_name = "sikachu" - assert_raise(ArgumentError){ p.valid? } - end end diff --git a/activemodel/test/cases/validations/format_validation_test.rb b/activemodel/test/cases/validations/format_validation_test.rb index 1ff29134ee..73647efea5 100644 --- a/activemodel/test/cases/validations/format_validation_test.rb +++ b/activemodel/test/cases/validations/format_validation_test.rb @@ -122,22 +122,6 @@ class PresenceValidationTest < ActiveModel::TestCase assert p.valid? end - def test_validates_format_of_with_lambda_not_returns_regexp - Topic.validates_format_of :content, :with => lambda{ |topic| false } - - p = Topic.new - p.content = "Pixies" - assert_raise(ArgumentError){ p.valid? } - end - - def test_validates_format_of_without_lambda_not_returns_regexp - Topic.validates_format_of :content, :without => lambda{ |topic| false } - - p = Topic.new - p.content = "Pixies" - assert_raise(ArgumentError){ p.valid? } - end - def test_validates_format_of_for_ruby_class Person.validates_format_of :karma, :with => /\A\d+\Z/ diff --git a/activemodel/test/cases/validations/inclusion_validation_test.rb b/activemodel/test/cases/validations/inclusion_validation_test.rb index e6adb6d187..92c473de0e 100644 --- a/activemodel/test/cases/validations/inclusion_validation_test.rb +++ b/activemodel/test/cases/validations/inclusion_validation_test.rb @@ -86,13 +86,4 @@ class InclusionValidationTest < ActiveModel::TestCase p.title = "elephant" assert p.valid? end - - def test_validates_inclustion_with_invalid_lambda_return - Topic.validates_inclusion_of :title, :in => lambda{ |topic| false } - - p = Topic.new - p.title = "monkey" - p.author_name = "sikachu" - assert_raise(ArgumentError){ p.valid? } - end end -- cgit v1.2.3