instiki/vendor/rails/activesupport/test/core_ext/blank_test.rb

20 lines
515 B
Ruby
Raw Normal View History

require File.dirname(__FILE__) + '/../abstract_unit'
2007-01-22 14:43:50 +01:00
class EmptyTrue
def empty?() true; end
end
class EmptyFalse
def empty?() false; end
end
2007-01-22 14:43:50 +01:00
class BlankTest < Test::Unit::TestCase
BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", [], {} ]
NOT = [ EmptyFalse.new, Object.new, true, 0, 1, 'a', [nil], { nil => 0 } ]
2007-01-22 14:43:50 +01:00
def test_blank
BLANK.each { |v| assert v.blank?, "#{v.inspect} should be blank" }
NOT.each { |v| assert !v.blank?, "#{v.inspect} should not be blank" }
2007-01-22 14:43:50 +01:00
end
end