Cucumber 使用Cumber提交测试表
我在一个演示站点上为表单编写了一个简单的Cuke功能。该功能如下所示Cucumber 使用Cumber提交测试表,cucumber,ruby-on-rails-3,Cucumber,Ruby On Rails 3,我在一个演示站点上为表单编写了一个简单的Cuke功能。该功能如下所示 Given I am on the home page When I set the "Start Date" to "2010-10-25" And I set the "End Date" to "2011-1-3" And I press the "Go" button Then I should see "Cake Shop" 这个想法是,在我按下Go按钮后,将加载一个新页面,
Given I am on the home page
When I set the "Start Date" to "2010-10-25"
And I set the "End Date" to "2011-1-3"
And I press the "Go" button
Then I should see "Cake Shop"
这个想法是,在我按下Go按钮后,将加载一个新页面,显示结果列表,其中一个结果应该是“蛋糕店”
但我还没能让它发挥作用。有什么我遗漏的吗
编辑:以下是步骤定义
Given /^I am on the "([^"]*)" page$/ do |page|
visit root_path
end
When /^I set the "([^"]*)" to "([^"]*)"$/ do |field, date|
fill_in field, :with=>date
end
When /^I press the "([^"]*)" button$/ do |arg1|
click_button('Go')
end
我相信,最后一步是在web_steps.rb中定义的……它总是在那里失败
(RSpec::Expections::ExpectationNotMetError)
./features/step\u definitions/web\u steps.rb:110:in
`'中的块(2层)'
有些代码是正确的。具体来说,你的黄瓜步骤。还有一些关于失败原因的输出。@DJTripleThreat刚刚添加了我正在使用的步骤。是的,我正在使用水豚。“蛋糕店”存在——我运行了rake db:test:prepare——它应该出现在表单提交后加载的下一个页面上。这就是我要检查的页面,实际上,不是当前页面。我不知道应该用什么来检查……当前页面是指用户在提交表单时看到的页面。因此,假设表单提交正确,“当前页”将是结果页或“下一页”。只需在“我应该看到”步骤之前插入“然后显示页面”步骤。正如我之前所说,在您的步骤中手动设置数据比依赖于您的应用程序在每次测试之前处于未记录的预期状态要清晰得多。
expected #has_content?("Cake Shop") to return true, got false