diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-04 15:01:51 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-04 15:07:15 -0800 |
commit | 4fabad7cf125178c95468a573951e587928c333b (patch) | |
tree | 84a1031ee49501d47e835d7ddb43e451e0bdc9cd /activesupport | |
parent | a84b84efaca02a0164c32a10df59f581eef16ac8 (diff) | |
download | rails-4fabad7cf125178c95468a573951e587928c333b.tar.gz rails-4fabad7cf125178c95468a573951e587928c333b.tar.bz2 rails-4fabad7cf125178c95468a573951e587928c333b.zip |
test that the custom ordered hash can be round-tripped
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/ordered_hash.rb | 5 | ||||
-rw-r--r-- | activesupport/test/ordered_hash_test.rb | 17 |
2 files changed, 17 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb index ac20988230..5b8c342f4f 100644 --- a/activesupport/lib/active_support/ordered_hash.rb +++ b/activesupport/lib/active_support/ordered_hash.rb @@ -1,8 +1,3 @@ -begin - require 'psych' -rescue LoadError -end - require 'yaml' YAML.add_builtin_type("omap") do |type, val| diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb index 69f24dd6f8..09203465c3 100644 --- a/activesupport/test/ordered_hash_test.rb +++ b/activesupport/test/ordered_hash_test.rb @@ -261,6 +261,23 @@ class OrderedHashTest < Test::Unit::TestCase assert_equal @ordered_hash.values, @deserialized_ordered_hash.values end + begin + require 'psych' + + def test_psych_serialize + @deserialized_ordered_hash = Psych.load(Psych.dump(@ordered_hash)) + + values = @deserialized_ordered_hash.map { |_, value| value } + assert_equal @values, values + end + + def test_psych_serialize_tag + yaml = Psych.dump(@ordered_hash) + assert_match '!omap', yaml + end + rescue LoadError + end + def test_has_yaml_tag @ordered_hash[:array] = %w(a b c) assert_match '!omap', YAML.dump(@ordered_hash) |