From 2c110b825e743f62c84a0c3e247ad524a9ac81c6 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 11 Feb 2005 13:05:38 +0000 Subject: Added IndifferentAccess as a way to wrap a hash by a symbol-based store that also can be accessed by string keys git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@581 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/hash_ext_test.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'activesupport/test') diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 52a28c1553..de85db2edf 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -2,7 +2,6 @@ require 'test/unit' require File.dirname(__FILE__) + '/../../lib/core_ext/hash' class HashExtTest < Test::Unit::TestCase - def setup @strings = { 'a' => 1, 'b' => 2 } @symbols = { :a => 1, :b => 2 } @@ -33,6 +32,17 @@ class HashExtTest < Test::Unit::TestCase assert_raises(NoMethodError) { { [] => 1 }.symbolize_keys! } end + def test_indifferent_access + @strings = @strings.with_indifferent_access + @symbols = @symbols.with_indifferent_access + @mixed = @mixed.with_indifferent_access + + assert_equal @strings[:a], @strings["a"] + assert_equal @symbols[:a], @symbols["a"] + assert_equal @strings["b"], @mixed["b"] + assert_equal @strings[:b], @mixed["b"] + end + def test_assert_valid_keys assert_nothing_raised do { :failure => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) -- cgit v1.2.3