3
我开始探索BDD和黄瓜。 所以我想检查一下我的页面是否显示了我拥有的两篇文章的内容。 这是我使用的检查步骤;如果内容有:检查黄瓜测试网页的内容
Then /^I should see "([^"]*)"$/ do |desc|
page.should have_content desc
expected = Article.find_by_description(desc)
page.should have_content(expected.navision_code)
page.should have_content(expected.category.name)
end
通常这应该做的我猜的伎俩,但是当我运行测试,我得到这个错误信息:
expected there to be content "---\n- tenetur\n" in "Alfa Paints Order System\n\n\n\nAlfa Paints\n\n\n\nSeth abernathy, admin\n\n\nVerander paswoord\n\nLogout\n\n\n\n\n\n\n\n\n\n\n\nAlfa Paints\nordering system\n\n\n\n\n\nOverzicht van alle artikelen\n\n\n\nBack\n\n\n\n\n\n\nProduct ID\nBeschrijving\nCategorie\n3001\nPaint\n---\n- tenetur\n\n3002\nBrush\n---\n- tenetur\n\n\n\n\n\n\n\n\n\n\n
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/admin_articles_steps.rb:41:in `/^I should see "([^"]*)"$/'
features/admin_articles.feature:10:in `Then I should see "Paint"'
正如你所看到的,我期望绘画和错误信息显示内容已经在内部绘制。 但不知何故,黄瓜不认识它。
我是新来的黄瓜,我可能错过了一些东西,但也许有人可以帮我在路上。
它看起来像水豚不换行发挥好。你可以尝试用下面这样的东西来解决它们:http://praktikanten.brueckenschlaeger.org/2011/11/15/working-in-cucumber-with-new-lines-and-have_content – DVG
我不认为你需要确定“整个”文章是否有“成功”的测试,可能是检查文章中的随机线? – omarvelous