2013-08-27 4 views
0

Я использую 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 

Также имеется документация для определения ступеней огурца/Capybara?

ответ

1

Есть несколько возможностей:

  1. Check страница путь/URL с помощью current_path или current_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 
Смежные вопросы