I am writing a Groovy test to check a method's yaml output and I am having trouble comparing the expected yaml with the generated yaml. The expected yaml string is missing double quotes for values that require double quotes. I am using snakeYaml as my yaml parser.
Generated yaml output:
key_a: 3
key_b: "value_b"
key_c:
key_c1: "value_c1"
key_c2: "value_c2"
key_c3: "value_c3"
Expected yaml output:
key_a: 3
key_b: value_b
key_c:
key_c1: value_c1
key_c2: value_c2
key_c3: value_c3
In this case the generated yaml is correct but my test is failing as the expected yaml does not contain the required quotations.
Creating yaml string using yaml.dump
:
def expected = yaml.dump(yaml.load("""
key_a: 3
key_b: "value_b"
key_c:
key_c1: "value_c1"
key_c2: "value_c2"
key_c3: "value_c3"
"""))
How do I create the expected yaml string with the quotations?? Any suggestions on this will help. Thanks!!