لا يتطابق اختبار RSPEC لإخراج Treetop Parser عندما ينبغي

StackOverflow https://stackoverflow.com/questions/3444597

  •  27-09-2019
  •  | 
  •  

سؤال

لدي هذا المواصفات:

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

الذي ينتج هذا الإخراج:

expected ## Core
## Special
## Omgg
## Moarheaders
, got "## 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"

إذا أضفت عروض أسعار إلى متوقعة _output ، أحصل على هذا: (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"

ماذا يحدث هنا؟

لا يمكنني الحصول على نتيجة TRETOP لتقييم n كخطوط جديدة ، ولا يمكنني الحصول على متوقع _output لمطابقة بغض النظر عن ما أحاول.

انا مرتبك.

هل كانت مفيدة؟

المحلول

هل جربت:

parsed.transform.should == expected_output

be قد يستخدم هوية الكائن بدلاً من مقارنة قيم السلسلة.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top