Ruby on rails 黄瓜步骤定义

Ruby on rails 黄瓜步骤定义,ruby-on-rails,cucumber,capybara,bdd,Ruby On Rails,Cucumber,Capybara,Bdd,我正在使用Cucumber/Capybara编写一些特性级测试 这是我的特征定义 Feature: User Signin As a User I want to signin So i can use my app Background: Given user with "email" email and "password" password Scenario: Signing in with correct credentials When

我正在使用Cucumber/Capybara编写一些特性级测试

这是我的特征定义

Feature: User Signin
  As a User
  I want to signin
  So i can use my app

  Background:
      Given user with "email" email and "password" password

  Scenario: Signing in with correct credentials
      When I go to sign in page
      And I fill in "user_email" with "email"
      And I fill in "user_password" with "password"
      And I click "Sign in" button
      Then I should go to the dashboard page
如何定义检查是否转到特定页面的步骤?基本上,我如何定义以下步骤

Then(/^I should go to the dashboard page$/) do
end

还有黄瓜/水豚步骤定义的文档吗?

有几种可能性:

  • 使用或方法检查页面的路径/url:

  • 使用以下选项之一检查页面内容:

  • 您还可以使用页面对象模式并执行以下操作:

    current_path.should == DashboardPage.path
    
    Then(/^I should go to the dashboard page$/) do
      page.should have_css('#id_that_is_present_only_at_dashboard_page')
    end
    
    current_path.should == DashboardPage.path