mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
test that the custom ordered hash can be round-tripped
This commit is contained in:
parent
a84b84efac
commit
4fabad7cf1
2 changed files with 17 additions and 5 deletions
|
@ -1,8 +1,3 @@
|
|||
begin
|
||||
require 'psych'
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
require 'yaml'
|
||||
|
||||
YAML.add_builtin_type("omap") do |type, val|
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue