diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-11 08:23:50 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-11 08:23:50 +0000 |
commit | 8ae68efcf84d9c9927c4db7dfeb0f41693b9e555 (patch) | |
tree | 777b582e86de7194091067155d0e17aca48d395f /activesupport/test | |
parent | c1007377ba010448e55030c37f3fee24208e9912 (diff) | |
download | rails-8ae68efcf84d9c9927c4db7dfeb0f41693b9e555.tar.gz rails-8ae68efcf84d9c9927c4db7dfeb0f41693b9e555.tar.bz2 rails-8ae68efcf84d9c9927c4db7dfeb0f41693b9e555.zip |
Added Hash#reverse_merge, Hash#reverse_merge!, and Hash#reverse_update to ease the use of default options. Added :connector and :skip_last_comma options to Array#to_sentence
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2192 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/array_ext_test.rb | 10 | ||||
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb index 2ee86c8af9..159dc2a478 100644 --- a/activesupport/test/core_ext/array_ext_test.rb +++ b/activesupport/test/core_ext/array_ext_test.rb @@ -19,7 +19,15 @@ class ArrayExtConversionTests < Test::Unit::TestCase end def test_to_sentence_with_connector - assert_equal "one, two, and also three", ['one', 'two', 'three'].to_sentence('and also') + assert_equal "one, two, and also three", ['one', 'two', 'three'].to_sentence(:connector => 'and also') + end + + def test_to_sentence_with_skip_last_comma + assert_equal "one, two and three", ['one', 'two', 'three'].to_sentence(:skip_last_comma => true) + end + + def test_two_elements + assert_equal "one and two", ['one', 'two'].to_sentence end def test_one_element diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index f42b6fde2f..4ae2dd8e7c 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -118,4 +118,8 @@ class HashExtTest < Test::Unit::TestCase indiff = original.with_indifferent_access assert(!indiff.keys.any? {|k| k.kind_of? String}, "A key was converted to a string!") end + + def test_reverse_merge + assert_equal({ :a => 1, :b => 2, :c => 10 }, { :a => 1, :b => 2 }.reverse_merge({:a => "x", :b => "y", :c => 10}) ) + end end |