Sha256: 01045fc710f2c7f3ccb2629f5d976c405dbe92955d2072694112237ffafc4257

Contents?: true

Size: 733 Bytes

Versions: 14

Compression:

Stored size: 733 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
    expect(@blank_hash[:b1]).to be_nil
    expect(@blank_hash["b2"]).to be_nil
  end

  it "should leave nils as nil" do
    expect(@blank_hash["nilval"]).to be_nil
  end

  it "should not nilify non blank values" do
    expect(@blank_hash[:present]).to eq("value")
    expect(@blank_hash["another"]).to eq("another value")
  end

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
brightbox-cli-4.8.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.7.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.6.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.5.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.5.0.rc1 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.4.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.3.2 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.3.1 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.3.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.2.1 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.2.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.1.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.0.0 spec/unit/nilable_hash_spec.rb
brightbox-cli-4.0.0.rc2 spec/unit/nilable_hash_spec.rb