diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-07-05 01:09:40 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-07-05 01:09:40 +0000 |
commit | 760bcc6ea93d235294cb741a2359365794365c34 (patch) | |
tree | 507873cfcb9f2e31c58a209c84010683cddf7603 /activesupport/test/core_ext/hash_ext_test.rb | |
parent | f384622a20bfa701b5bce9582ce58d8235ed0185 (diff) | |
download | rails-760bcc6ea93d235294cb741a2359365794365c34.tar.gz rails-760bcc6ea93d235294cb741a2359365794365c34.tar.bz2 rails-760bcc6ea93d235294cb741a2359365794365c34.zip |
Fixed HashWithIndifferentAccess#default (closes #5586) [chris@seagul.co.uk]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4539 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext/hash_ext_test.rb')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index bd197a7e4e..327d884ecd 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -380,4 +380,26 @@ class HashToXmlTest < Test::Unit::TestCase assert_equal expected_topic_hash, Hash.create_from_xml(topic_xml)["rsp"]["photos"]["photo"] end + + def test_should_use_default_value_for_unknown_key + hash_wia = HashWithIndifferentAccess.new(3) + assert_equal 3, hash_wia[:new_key] + end + + def test_should_use_default_value_if_no_key_is_supplied + hash_wia = HashWithIndifferentAccess.new(3) + assert_equal 3, hash_wia.default + end + + def test_should_nil_if_no_default_value_is_supplied + hash_wia = HashWithIndifferentAccess.new + assert_nil hash_wia.default + end + + def test_should_copy_the_default_value_when_converting_to_hash_with_indifferent_access + hash = Hash.new(3) + hash_wia = hash.with_indifferent_access + assert_equal 3, hash_wia.default + end + end
\ No newline at end of file |