Sha256: 28c8955f25a823cf08be5701257c1336a3a25a1dec1c81c0d573180fa53a1888

Contents?: true

Size: 966 Bytes

Versions: 61

Compression:

Stored size: 966 Bytes

Contents

require "test_helper"

class HashWithIndifferentAccessUtilTest < Test::Unit::TestCase
  setup do
    @klass = Vagrant::Util::HashWithIndifferentAccess
    @instance = @klass.new
  end

  should "be a hash" do
    assert @instance.is_a?(Hash)
  end

  should "allow indifferent access when setting with a string" do
    @instance["foo"] = "bar"
    assert_equal "bar", @instance[:foo]
  end

  should "allow indifferent access when setting with a symbol" do
    @instance[:foo] = "bar"
    assert_equal "bar", @instance["foo"]
  end

  should "allow indifferent key lookup" do
    @instance["foo"] = "bar"
    assert @instance.key?(:foo)
    assert @instance.has_key?(:foo)
    assert @instance.include?(:foo)
    assert @instance.member?(:foo)
  end

  should "forward up block to Hash if given to initializer" do
    instance = @klass.new do |h,k|
      h[k] = "foo"
    end

    assert_equal "foo", instance[:foo]
    assert_equal "foo", instance["foo"]
  end
end

Version data entries

61 entries across 61 versions & 5 rubygems

Version Path
vagrantup-0.8.9 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.8.8 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.8.7 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.8.6 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.8.5 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.8.4 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.8.3 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.8.2 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.8.10 test/unit/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.8.1 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.8.0 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.7.8 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.7.7 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.7.6 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.7.5 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.7.4 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.7.3 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.7.2 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.7.1 test/vagrant/util/hash_with_indifferent_access_test.rb
vagrantup-0.7.0 test/vagrant/util/hash_with_indifferent_access_test.rb