Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cucumber 使用Cumber提交测试表_Cucumber_Ruby On Rails 3 - Fatal编程技术网

Cucumber 使用Cumber提交测试表

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按钮后,将加载一个新页面,

我在一个演示站点上为表单编写了一个简单的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 "([^"]*)" 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层)'

  • 如果您使用Capybara驱动测试,那么“然后显示页面”步骤将把当前页面的HTML放入tmp文件夹,请看一看

  • “蛋糕店”的数据来自哪里?在运行测试之前是否重置了数据库?通常,如果您的黄瓜需要一些设置数据,最好明确说明数据存在于步骤中,并在每次测试中插入数据。e、 g

    考虑到“蛋糕店”的存在


  • 有些代码是正确的。具体来说,你的黄瓜步骤。还有一些关于失败原因的输出。@DJTripleThreat刚刚添加了我正在使用的步骤。是的,我正在使用水豚。“蛋糕店”存在——我运行了rake db:test:prepare——它应该出现在表单提交后加载的下一个页面上。这就是我要检查的页面,实际上,不是当前页面。我不知道应该用什么来检查……当前页面是指用户在提交表单时看到的页面。因此,假设表单提交正确,“当前页”将是结果页或“下一页”。只需在“我应该看到”步骤之前插入“然后显示页面”步骤。正如我之前所说,在您的步骤中手动设置数据比依赖于您的应用程序在每次测试之前处于未记录的预期状态要清晰得多。
    expected #has_content?("Cake Shop") to return true, got false