diff options
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 35 | ||||
-rw-r--r-- | activesupport/test/misc_test.rb | 32 |
2 files changed, 33 insertions, 34 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index f481cf0242..52a28c1553 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -1,7 +1,38 @@ require 'test/unit' -require File.dirname(__FILE__) + '/../../lib/core_ext/hash_ext' +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 } + @mixed = { :a => 1, 'b' => 2 } + end + + def test_methods + h = {} + assert_respond_to h, :symbolize_keys + assert_respond_to h, :symbolize_keys! + assert_respond_to h, :to_options + assert_respond_to h, :to_options! + end + + def test_symbolize_keys + assert_equal @symbols, @symbols.symbolize_keys + assert_equal @symbols, @strings.symbolize_keys + assert_equal @symbols, @mixed.symbolize_keys + + assert_raises(NoMethodError) { { [] => 1 }.symbolize_keys } + end + + def test_symbolize_keys! + assert_equal @symbols, @symbols.dup.symbolize_keys! + assert_equal @symbols, @strings.dup.symbolize_keys! + assert_equal @symbols, @mixed.dup.symbolize_keys! + + assert_raises(NoMethodError) { { [] => 1 }.symbolize_keys! } + end + def test_assert_valid_keys assert_nothing_raised do { :failure => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) @@ -11,4 +42,4 @@ class HashExtTest < Test::Unit::TestCase { :failore => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) end end -end
\ No newline at end of file +end diff --git a/activesupport/test/misc_test.rb b/activesupport/test/misc_test.rb index 2a6c40709a..5a2d1d33e8 100644 --- a/activesupport/test/misc_test.rb +++ b/activesupport/test/misc_test.rb @@ -17,35 +17,3 @@ class MiscTest < Test::Unit::TestCase end end end - -class HashOptionsTest < Test::Unit::TestCase - def setup - @strings = { 'a' => 1, 'b' => 2 } - @symbols = { :a => 1, :b => 2 } - @mixed = { :a => 1, 'b' => 2 } - end - - def test_methods - h = {} - assert_respond_to h, :symbolize_keys - assert_respond_to h, :symbolize_keys! - assert_respond_to h, :to_options - assert_respond_to h, :to_options! - end - - def test_symbolize_keys - assert_equal @symbols, @symbols.symbolize_keys - assert_equal @symbols, @strings.symbolize_keys - assert_equal @symbols, @mixed.symbolize_keys - - assert_raises(NoMethodError) { { [] => 1 }.symbolize_keys } - end - - def test_symbolize_keys! - assert_equal @symbols, @symbols.dup.symbolize_keys! - assert_equal @symbols, @strings.dup.symbolize_keys! - assert_equal @symbols, @mixed.dup.symbolize_keys! - - assert_raises(NoMethodError) { { [] => 1 }.symbolize_keys! } - end -end |