Project

General

Profile

Feature #12960 » 0010-feat-psych-add-another-test-case.patch

kwatch (makoto kuwata), 11/19/2016 03:54 AM

View differences:

test/psych/visitors/test_custom_class.rb
assert_equal "F", team.members[0].gender
end
def test_merge_mapping
input = <<-END
column-defaults:
- &id
name : id
type : int
pkey : true
tables:
- name : admin_users
columns:
- <<: *id
name: user_id
END
#
classmap = {
"tables" => Struct.new('Table', 'name', 'columns'),
"columns" => Struct.new('Column', 'name', 'type', 'pkey', 'required'),
}
#
visitor = Psych::Visitors::CustomClassVisitor.create(classmap)
tree = Psych.parse(input)
ydoc = visitor.accept(tree)
#
assert_kind_of classmap["tables"], ydoc['tables'][0]
assert_kind_of classmap["columns"], ydoc['tables'][0]['columns'][0]
#
table = ydoc['tables'][0]
assert_equal "int", table.columns[0].type # merged
assert_equal true, table.columns[0].pkey # merged
assert_equal "user_id", table.columns[0].name # ovrerwritten
end
end
end
end
(10-10/10)