我目前正在尝试为带有黄瓜和水豚的新 Rails 3 应用程序设置集成/验收测试。(我本来打算用webrat,但是好像不支持rails 3,所以最后还是用capybara)
我正在尝试进行基本的登录测试:
Feature: Login user
In order to access the non-public parts of the site,
as a user,
I want to login to the site
Scenario: login with valid credentials
Given I am on the login page
When I fill in "Email" with "bender@planetexpress.com"
And I fill in "Password" with "pass"
And I press "Login"
Then I should be on the users home page
And I should see "Login successful"
现在的问题是,登录表单将我发送到/user_session
该表单,然后将我重定向到用户 home /home
。Cucumber 不遵循导致Then I should be on the users home page
线路失败的重定向。
我如何告诉 cucumber/capybara 跟随重定向,以便在我点击跟随链接按钮后我在正确的页面上?
我正在使用的 rack_test 驱动程序中似乎有一个follow_redirect!
方法,但它是私有的,我不知道如何调用该功能。
提前谢谢,
西蒙