Sha256: 8b1772810a43443d50be771a062d586b5407fb274d1c9fedbc11d1682f28c082

Contents?: true

Size: 850 Bytes

Versions: 5

Compression:

Stored size: 850 Bytes

Contents

require 'spec_helper'

describe Crystal::HashWithStringifyKeys do
  def new(*args)
    Crystal::HashWithStringifyKeys.new(*args)
  end

  context '.new' do
    it 'stringifies keys when hash is passed' do
      new(:key => {:key2 => 1}).should == {'key' => {'key2' => 1}}
    end

    it 'keeps a default value if one argument has been passed' do
      new(1)['unknown'].should == 1
    end

    it 'returns an empty hash when no args have been passed' do
      new.should be_empty
      new['unknown'].should be_nil
    end
  end

  context '#deep_merge with the same tag' do
    it 'returns a hash with stringified keys' do
      hash = new(:key => {:key2 => 1})
      merge = hash.deep_merge!(new(:key => {:key2 => 2}))
      merge.should == {'key' => {'key2' => 2}}
      merge.should be_kind_of(Crystal::HashWithStringifyKeys)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
crystalmeta-0.9.4 spec/unit/hash_with_stringify_keys_spec.rb
crystalmeta-0.9.3 spec/unit/hash_with_stringify_keys_spec.rb
crystalmeta-0.9.2 spec/unit/hash_with_stringify_keys_spec.rb
crystalmeta-0.9.1 spec/unit/hash_with_stringify_keys_spec.rb
crystalmeta-0.9.0 spec/unit/hash_with_stringify_keys_spec.rb