diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-11 13:05:38 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-11 13:05:38 +0000 |
commit | 2c110b825e743f62c84a0c3e247ad524a9ac81c6 (patch) | |
tree | ba98b103e0839e2bc013aa93e0ea865e328805fd /activesupport/test | |
parent | e505a4517387e1f628f6b2e5f6689526c7a74354 (diff) | |
download | rails-2c110b825e743f62c84a0c3e247ad524a9ac81c6.tar.gz rails-2c110b825e743f62c84a0c3e247ad524a9ac81c6.tar.bz2 rails-2c110b825e743f62c84a0c3e247ad524a9ac81c6.zip |
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
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 12 |
1 files changed, 11 insertions, 1 deletions
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 ]) |