2013-08-27 119 views
0

我正在使用黄瓜/水豚写一些功能水平测试。黄瓜步定义

这里是我的特征定义

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 

另外,是否有Cucumber/Capybara步骤定义的文档?

回答

1

有几种可能性:

  1. 检查网页的路径/使用current_pathcurrent_url方法网址:

    Then(/^I should go to the dashboard page$/) do 
        current_path.should == expected_path 
        # or current_path.should == expected_url 
    end 
    
  2. 页的检查内容使用的一个RSpec matchers

    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