Sha256: fff6a61ec87670e9e0d6dc122e1001d43d24d656dc8ecabd453378ef34432999

Contents?: true

Size: 882 Bytes

Versions: 6

Compression:

Stored size: 882 Bytes

Contents

require 'spec_helper'
require 'active_support/core_ext/object/blank'
require 'empty_bool'

describe 'Object#blank?' do
  BLANK = [ EmptyTrue.new, nil, false, '', '   ', "  \n\t  \r ", ' ', [], {} ]
  NOT   = [ EmptyFalse.new, Object.new, true, 0, 1, 'a', [nil], { nil => 0 } ]

  BLANK.each do |v|
    describe "The value of #{v.inspect}" do
      it 'is #blank?' do
        v.blank?.should == true
      end

      it 'is not #present?' do
        v.present?.should == false
      end

      it 'has nil #presence' do
        v.presence.should == nil
      end
    end
  end

  NOT.each do |v|
    describe "The value of #{v.inspect}" do
      it 'is not #blank?' do
        v.blank?.should == false
      end

      it 'is not #present?' do
        v.present?.should == true
      end

      it 'has self #presence' do
        v.presence.should == v
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-activesupport-0.2.0 spec/core_ext/object/blank_spec.rb
opal-activesupport-0.1.0 spec/core_ext/object/blank_spec.rb
opal-activesupport-0.0.5 spec/core_ext/object/blank_spec.rb
opal-activesupport-0.0.4 spec/core_ext/object/blank_spec.rb
opal-activesupport-0.0.3 spec/core_ext/object/blank_spec.rb
opal-activesupport-0.0.2 spec/core_ext/object/blank_spec.rb