Sha256: fc3df258cfaf6ee3d53a86286d7a75d023e909066d0102f20ad406f0ccaf63b3

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'
require 'lumberg/whm'

module Lumberg
  describe Whm do
    describe "#to_bool" do
      it "converts all 1/0 values to bools" do
        hash = {:true => 1, :false => 0, :other => 2}
        new_hash = Whm::to_bool(hash)
        new_hash.should include(:true => true, :false => false, :other => 2)
      end

      it "converts signle specified key" do
        hash = {:true => 1, :false => 0, :other => 2}
        new_hash = Whm::to_bool(hash, :true)
        new_hash.should include(:true => true, :false => 0, :other => 2)
      end

      it "converts all specified keys" do
        hash = {:true => 1, :false => 0, :something => 1}
        new_hash = Whm::to_bool(hash, :true, :false)
        new_hash.should include(:true => true, :false => false, :something => 1)
      end
    end

    describe "#from_bool" do
      it "converts false to 0" do
        Whm::from_bool(false).should == 0
      end

      it "converts true to 1" do
        Whm::from_bool(true).should == 1
      end

      it "converts all falses and trues to 0 and 1" do
        hash = {:true => true, :false => false}
        Whm::from_bool(hash).should include(:true => 1, :false => 0)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lumberg-2.0.0.pre4 spec/whm/whm_spec.rb
lumberg-2.0.0.pre3 spec/whm/whm_spec.rb
lumberg-1.1.1 spec/whm/whm_spec.rb
lumberg-1.0.6 spec/whm/whm_spec.rb
lumberg-1.0.3 spec/whm/whm_spec.rb
lumberg-1.0.1 spec/whm/whm_spec.rb
lumberg-1.0.0 spec/whm/whm_spec.rb
lumberg-0.9.5 spec/whm/whm_spec.rb