aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJuanjo Bazan <jjbazan@gmail.com>2010-03-30 23:39:00 +0200
committerXavier Noria <fxn@hashref.com>2010-03-30 15:25:38 -0700
commit589deb39c79cac40eec40d4ee3d86fac16c1f31f (patch)
tree112aca950139cc39ac213cb0a8ee16c8d042395b /activesupport/test
parent7212c29802e34fe7368d5b484a479c31fad49c5d (diff)
downloadrails-589deb39c79cac40eec40d4ee3d86fac16c1f31f.tar.gz
rails-589deb39c79cac40eec40d4ee3d86fac16c1f31f.tar.bz2
rails-589deb39c79cac40eec40d4ee3d86fac16c1f31f.zip
New assertion: assert_present [#4299 state:committed]
Signed-off-by: Xavier Noria <fxn@hashref.com>
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/test_test.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/activesupport/test/test_test.rb b/activesupport/test/test_test.rb
index 390670570d..f9482c8e90 100644
--- a/activesupport/test/test_test.rb
+++ b/activesupport/test/test_test.rb
@@ -96,7 +96,7 @@ end
class AssertBlankTest < ActiveSupport::TestCase
BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", [], {} ]
- NOT_BLANK = [ EmptyFalse.new, Object.new, true, 0, 1, 'j', [nil], { nil => 0 } ]
+ NOT_BLANK = [ EmptyFalse.new, Object.new, true, 0, 1, 'x', [nil], { nil => 0 } ]
def test_assert_blank_true
BLANK.each { |v| assert_blank v }
@@ -114,6 +114,26 @@ class AssertBlankTest < ActiveSupport::TestCase
end
end
+class AssertPresentTest < ActiveSupport::TestCase
+ BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", [], {} ]
+ NOT_BLANK = [ EmptyFalse.new, Object.new, true, 0, 1, 'x', [nil], { nil => 0 } ]
+
+ def test_assert_blank_true
+ NOT_BLANK.each { |v| assert_present v }
+ end
+
+ def test_assert_blank_false
+ BLANK.each { |v|
+ begin
+ assert_present v
+ fail 'should not get to here'
+ rescue Exception => e
+ assert_match(/is blank/, e.message)
+ end
+ }
+ end
+end
+
# These should always pass
if ActiveSupport::Testing.const_defined?(:Default)
class NotTestingThingsTest < Test::Unit::TestCase