Sha256: 55f3c41704e5746d040b5f7d6a8122a80eaa247d28226ffd05e5e4c465eb563b
Contents?: true
Size: 914 Bytes
Versions: 2
Compression:
Stored size: 914 Bytes
Contents
# encoding: utf-8 require 'yarder/core_ext/object/blank' class EmptyTrue def empty?() true; end end class EmptyFalse def empty?() false; end end class BlankTest < ActiveSupport::TestCase BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", ' ', [], {} ] NOT = [ EmptyFalse.new, Object.new, true, 0, 1, 'a', [nil], { nil => 0 } ] 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" } end def test_present BLANK.each { |v| assert !v.present?, "#{v.inspect} should not be present" } NOT.each { |v| assert v.present?, "#{v.inspect} should be present" } end def test_presence BLANK.each { |v| assert_equal nil, v.presence, "#{v.inspect}.presence should return nil" } NOT.each { |v| assert_equal v, v.presence, "#{v.inspect}.presence should return self" } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yarder-0.1.0 | test/core_ext/blank_test.rb |
yarder-0.0.2 | test/core_ext/blank_test.rb |