Sha256: d49822c58d97e65055ac9397035b48ea982ea3ef67225be44b9ec7776f321099

Contents?: true

Size: 784 Bytes

Versions: 8

Compression:

Stored size: 784 Bytes

Contents

require 'spec_helper'
require 'dm-core/support/ext/hash'
require 'dm-core/support/mash'

describe DataMapper::Ext::Hash, "only" do
  before do
    @hash = { :one => 'ONE', 'two' => 'TWO', 3 => 'THREE', 4 => nil }
  end

  it "should return a hash with only the given key(s)" do
    DataMapper::Ext::Hash.only(@hash, :not_in_there).should == {}
    DataMapper::Ext::Hash.only(@hash, 4).should == {4 => nil}
    DataMapper::Ext::Hash.only(@hash, :one).should == { :one => 'ONE' }
    DataMapper::Ext::Hash.only(@hash, :one, 3).should == { :one => 'ONE', 3 => 'THREE' }
  end
end


describe Hash, 'to_mash' do
  before do
    @hash = Hash.new(10)
  end

  it "copies default Hash value to Mash" do
    @mash = DataMapper::Ext::Hash.to_mash(@hash)
    @mash[:merb].should == 10
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
ardm-core-1.3.0 spec/unit/hash_spec.rb
ardm-core-1.2.1 spec/unit/hash_spec.rb
dm-core-1.2.1 spec/unit/hash_spec.rb
ghost_dm-core-1.3.0.beta spec/unit/hash_spec.rb
dm-core-1.2.0 spec/unit/hash_spec.rb
dm-core-1.2.0.rc2 spec/unit/hash_spec.rb
dm-core-1.2.0.rc1 spec/unit/hash_spec.rb
dm-core-1.1.0 spec/unit/hash_spec.rb