When creating a YAML file for data, especially a complex data structure, I let YAML generate it for me. Then, if necessary, configure:
require 'yaml' require 'pp' foo = ["Skill 1","Act 1", "B"], ["","Act 2" "B"],["Skill 2","Act 1", "B"] puts foo.to_yaml
When I run this code, I get this output:
--- - - Skill 1 - Act 1 - B - - "" - Act 2B - - Skill 2 - Act 1 - B
You can prove that the data is correctly generated using YAML generation, then immediately analyze the code and show how it looks like a return structure, allowing you to compare it and check for equality:
bar = YAML.load(foo.to_yaml) pp bar puts "foo == bar: #{ foo == bar }"
What will be output:
[["Skill 1", "Act 1", "B"], ["", "Act 2B"], ["Skill 2", "Act 1", "B"]] foo == bar: true
source share