Sha256: 5cd55f66515d15e18946107937b6cf2b38812c06c727f4e13bed48dab072cb6c

Contents?: true

Size: 707 Bytes

Versions: 7

Compression:

Stored size: 707 Bytes

Contents

require "spec_helper"

describe NilableHash, "#nilify_blanks" do
  before do
    @blank_hash = NilableHash[
      :present => 'value', :b1 => '', 'nilval' => nil, 'b2' => '', 'another' => 'another value'
    ]
  end

  it "should nilify all blank values" do
    @blank_hash.nilify_blanks
    @blank_hash[:b1].should be_nil
    @blank_hash['b2'].should be_nil
  end

  it "should leave nils as nil" do
    @blank_hash['nilval'].should be_nil
  end

  it "should not nilify non blank values" do
    @blank_hash[:present].should == 'value'
    @blank_hash['another'].should == 'another value'
  end

  it "should respond true when sent #is_a?(Hash)" do
    NilableHash.new.is_a?(Hash).should be_true
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
brightbox-cli-1.2.2 spec/unit/nilable_hash_spec.rb
brightbox-cli-1.2.1 spec/unit/nilable_hash_spec.rb
brightbox-cli-1.2.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-1.1.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-1.0.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-1.0.0.rc2 spec/unit/nilable_hash_spec.rb
brightbox-cli-1.0.0.rc1 spec/unit/nilable_hash_spec.rb