diff options
author | Gregor Schmidt <ruby@schmidtwisser.de> | 2010-01-26 12:02:31 +0100 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-01-27 15:29:06 -0800 |
commit | 7b8c6472ffb6df4d341b0657f82e63c19e9a429c (patch) | |
tree | 4149671cd3573ef37fcf483d87339e08b5febb05 /activesupport/test | |
parent | b6b3db6734af8d5b42c7bdcea7c73923a5b88463 (diff) | |
download | rails-7b8c6472ffb6df4d341b0657f82e63c19e9a429c.tar.gz rails-7b8c6472ffb6df4d341b0657f82e63c19e9a429c.tar.bz2 rails-7b8c6472ffb6df4d341b0657f82e63c19e9a429c.zip |
Adding custom yaml (de-)serialization for OrderedHash
[#3608 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/ordered_hash_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb index 1521279437..d070206d44 100644 --- a/activesupport/test/ordered_hash_test.rb +++ b/activesupport/test/ordered_hash_test.rb @@ -198,4 +198,28 @@ class OrderedHashTest < Test::Unit::TestCase assert_same original, @ordered_hash assert_equal @other_ordered_hash.keys, @ordered_hash.keys end + + def test_each_after_yaml_serialization + values = [] + @deserialized_ordered_hash = YAML::load(YAML::dump(@ordered_hash)) + + @deserialized_ordered_hash.each {|key, value| values << value} + assert_equal @values, values + end + + def test_order_after_yaml_serialization + @deserialized_ordered_hash = YAML::load(YAML::dump(@ordered_hash)) + + assert_equal @keys, @deserialized_ordered_hash.keys + assert_equal @values, @deserialized_ordered_hash.values + end + + def test_order_after_yaml_serialization_with_nested_arrays + @ordered_hash[:array] = %w(a b c) + + @deserialized_ordered_hash = YAML::load(YAML::dump(@ordered_hash)) + + assert_equal @ordered_hash.keys, @deserialized_ordered_hash.keys + assert_equal @ordered_hash.values, @deserialized_ordered_hash.values + end end |