문제

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, 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top