Sha256: e15f78856a28f633f39ea577f538d26e0fca3eb1693df2a055f4d6cf6c059707

Contents?: true

Size: 977 Bytes

Versions: 59

Compression:

Stored size: 977 Bytes

Contents

require File.expand_path("../../../base", __FILE__)

require "vagrant/util/hash_with_indifferent_access"

describe Vagrant::Util::HashWithIndifferentAccess do
  let(:instance) { described_class.new }

  it "is a Hash" do
    instance.should be_kind_of(Hash)
  end

  it "allows indifferent access when setting with a string" do
    instance["foo"] = "bar"
    instance[:foo].should == "bar"
  end

  it "allows indifferent access when setting with a symbol" do
    instance[:foo] = "bar"
    instance["foo"].should == "bar"
  end

  it "allows indifferent key lookup" do
    instance["foo"] = "bar"
    instance.key?(:foo).should be
    instance.has_key?(:foo).should be
    instance.include?(:foo).should be
    instance.member?(:foo).should be
  end

  it "allows for defaults to be passed in via an initializer block" do
    instance = described_class.new do |h,k|
      h[k] = "foo"
    end

    instance[:foo].should == "foo"
    instance["bar"].should == "foo"
  end
end

Version data entries

59 entries across 59 versions & 11 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/util/hash_with_indifferent_access_test.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/util/hash_with_indifferent_access_test.rb
tamtam-vagrant-reload-1.1.1 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/util/hash_with_indifferent_access_test.rb
tamtam-vagrant-reload-1.1 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/util/hash_with_indifferent_access_test.rb
bmhatfield-vagrant-1.0.10 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
bmhatfield-vagrant-1.0.9 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
tnargav-1.3.6 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
tnargav-1.3.3 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
bmhatfield-vagrant-1.0.8 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/test/unit/vagrant/util/hash_with_indifferent_access_test.rb
tnargav-1.2.3 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/test/unit/vagrant/util/hash_with_indifferent_access_test.rb
bmhatfield-vagrant-1.0.7 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/test/unit/vagrant/util/hash_with_indifferent_access_test.rb
tnargav-1.2.2 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-1.1.3 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-1.1.2 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-1.1.1 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-1.1.0 test/unit/vagrant/util/hash_with_indifferent_access_test.rb