Sha256: d684662f645bc271356f8f50371305da9acd3da0eec1cba8b0d29de2e5531987

Contents?: true

Size: 1.84 KB

Versions: 25

Compression:

Stored size: 1.84 KB

Contents

require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper')

Sequel.extension :blank

describe "Object#blank?" do
  specify "it should be true if the object responds true to empty?" do
    [].blank?.should == true
    {}.blank?.should == true
    o = Object.new
    def o.empty?; true; end
    o.blank?.should == true
  end

  specify "it should be false if the object doesn't respond true to empty?" do
    [2].blank?.should == false
    {1=>2}.blank?.should == false
    Object.new.blank?.should == false
  end
end

describe "Numeric#blank?" do
  specify "it should always be false" do
    1.blank?.should == false
    0.blank?.should == false
    -1.blank?.should == false
    1.0.blank?.should == false
    0.0.blank?.should == false
    -1.0.blank?.should == false
    10000000000000000.blank?.should == false
    -10000000000000000.blank?.should == false
    10000000000000000.0.blank?.should == false
    -10000000000000000.0.blank?.should == false
  end
end

describe "NilClass#blank?" do
  specify "it should always be true" do
    nil.blank?.should == true
  end
end

describe "TrueClass#blank?" do
  specify "it should always be false" do
    true.blank?.should == false
  end
end

describe "FalseClass#blank?" do
  specify "it should always be true" do
    false.blank?.should == true
  end
end

describe "String#blank?" do
  specify "it should be true if the string is empty" do
    ''.blank?.should == true
  end
  specify "it should be true if the string is composed of just whitespace" do
    ' '.blank?.should == true
    "\r\n\t".blank?.should == true
    (' '*4000).blank?.should == true
    ("\r\n\t"*4000).blank?.should == true
  end
  specify "it should be false if the string has any non whitespace characters" do
    '1'.blank?.should == false
    ("\r\n\t"*4000 + 'a').blank?.should == false
    ("\r\na\t"*4000).blank?.should == false
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
sequel-4.22.0 spec/extensions/blank_spec.rb
sequel-4.21.0 spec/extensions/blank_spec.rb
sequel-4.20.0 spec/extensions/blank_spec.rb
sequel-4.19.0 spec/extensions/blank_spec.rb
sequel-4.18.0 spec/extensions/blank_spec.rb
sequel-4.17.0 spec/extensions/blank_spec.rb
sequel-4.16.0 spec/extensions/blank_spec.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/sequel-4.15.0/spec/extensions/blank_spec.rb
sequel-4.15.0 spec/extensions/blank_spec.rb
sequel-4.14.0 spec/extensions/blank_spec.rb
sequel-4.13.0 spec/extensions/blank_spec.rb
sequel-4.12.0 spec/extensions/blank_spec.rb
sequel-4.11.0 spec/extensions/blank_spec.rb
sequel-4.10.0 spec/extensions/blank_spec.rb
sequel-4.9.0 spec/extensions/blank_spec.rb
sequel-4.8.0 spec/extensions/blank_spec.rb
sequel-4.7.0 spec/extensions/blank_spec.rb
sequel-4.6.0 spec/extensions/blank_spec.rb
sequel-4.5.0 spec/extensions/blank_spec.rb
sequel-4.4.0 spec/extensions/blank_spec.rb