I have this spec:
it 'can parse armies with only section headers' do
list = <<-LIST
:Core
:Special
:Omgg
:Moarheaders
LIST
expected_output = "## Core\n## Special\n## Omgg\n## Moarheaders\n"
parsed = @parser.parse(list)
parsed.should_not be_nil
parsed.transform.should be expected_output
end
Which produces this output:
expected ## Core
## Special
## Omgg
## Moarheaders
, got "## Core\n## Special\n## Omgg\n## Moarheaders\n"
If I remove the double quotes, I get this output:
expected ## Core\n## Special\n## Omgg\n## Moarheaders\n,
got "## Core\n## Special\n## Omgg\n## Moarheaders\n"
If I add quotes to my expected_output开发者_如何学C, I get this:
(expected_output = '"## Core\n## Special\n## Omgg\n## Moarheaders\n"'
)
expected "## Core\n## Special\n## Omgg\n## Moarheaders\n",
got "## Core\n## Special\n## Omgg\n## Moarheaders\n"
What's going on here?
I can't get the Treetop result to evaluate the \n as newlines, and I can't get the expected_output to match regardless of what I try.
I'm confused.
Did you try:
parsed.transform.should == expected_output
be
might use object identity instead of comparing the string values.
精彩评论