Sha256: a6039f967cc59917873eca4e87ab924aa3097e0d9d260b8350e77bd1c267c3c8

Contents?: true

Size: 1.18 KB

Versions: 12

Compression:

Stored size: 1.18 KB

Contents

$:.unshift File.expand_path('../../../lib', __FILE__)
require 'rspec'
require 'image_optim/hash_helpers'

describe ImageOptim::HashHelpers do
  HH = ImageOptim::HashHelpers

  it "should deep stringify hash keys" do
    HH.deep_stringify_keys({
      :a => 1,
      :b => {
        :c => :a,
        :d => {},
      },
    }).should == {
      'a' => 1,
      'b' => {
        'c' => :a,
        'd' => {},
      },
    }
  end

  it "should deep symbolise hash keys" do
    HH.deep_symbolise_keys({
      'a' => 1,
      'b' => {
        'c' => 'a',
        'd' => {},
      },
    }).should == {
      :a => 1,
      :b => {
        :c => 'a',
        :d => {},
      },
    }
  end

  it "should deep merge hashes" do
    HH.deep_merge({
      :a => {
        :b => 1,
        :c => {
          :d => 2,
          :e => {
            :f => true
          },
        },
      },
      :y => 10,
    }, {
      :a => {
        :b => 2,
        :c => {
          :d => 3,
          :e => false,
        },
      },
      :z => 20,
    }).should == {
      :a => {
        :b => 2,
        :c => {
          :d => 3,
          :e => false,
        },
      },
      :y => 10,
      :z => 20,
    }
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
image_optim-0.13.3 spec/image_optim/hash_helpers_spec.rb
image_optim-0.13.2 spec/image_optim/hash_helpers_spec.rb
image_optim-0.13.1 spec/image_optim/hash_helpers_spec.rb
image_optim-0.13.0 spec/image_optim/hash_helpers_spec.rb
image_optim-0.12.1 spec/image_optim/hash_helpers_spec.rb
image_optim-0.12.0 spec/image_optim/hash_helpers_spec.rb
image_optim-0.11.2 spec/image_optim/hash_helpers_spec.rb
image_optim-0.11.1 spec/image_optim/hash_helpers_spec.rb
image_optim-0.11.0 spec/image_optim/hash_helpers_spec.rb
image_optim-0.10.2 spec/image_optim/hash_helpers_spec.rb
image_optim-0.10.1 spec/image_optim/hash_helpers_spec.rb
image_optim-0.10.0 spec/image_optim/hash_helpers_spec.rb