Sha256: 998df8510236b4866ff2575c174ef17607a121987fb8f1023a87fa6f102d68ec

Contents?: true

Size: 762 Bytes

Versions: 9

Compression:

Stored size: 762 Bytes

Contents

require 'spec_helper'
require 'mspec/guards'
require 'mspec/helpers'

describe Object, "#hash_class" do
  it "returns the Hash class" do
    hash_class.should == Hash
  end
end

describe Object, "#new_hash" do
  it "returns a default hash" do
    new_hash.should == {}
  end

  it "returns a hash having a default value" do
    hash = new_hash(5)
    hash[:none].should == 5
  end

  it "returns a hash having a default proc" do
    hash = new_hash { |h, k| h[k] = :default }
    hash[:none].should == :default
  end

  it "returns a hash constructed from keys and values" do
    new_hash({:a => 1, :b => 2}).should == { :a => 1, :b => 2 }
    new_hash(1 => 2, 3 => 4).should == { 1 => 2, 3 => 4 }
    new_hash(1, 2, 3, 4).should == { 1 => 2, 3 => 4 }
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mspec-1.9.1 spec/helpers/hash_spec.rb
mspec-1.9.0 spec/helpers/hash_spec.rb
mspec-1.8.0 spec/helpers/hash_spec.rb
mspec-1.7.0 spec/helpers/hash_spec.rb
mspec-1.6.0 spec/helpers/hash_spec.rb
mspec-1.5.21 spec/helpers/hash_spec.rb
mspec-1.5.20 spec/helpers/hash_spec.rb
mspec-1.5.19 spec/helpers/hash_spec.rb
mspec-1.5.18 spec/helpers/hash_spec.rb