我正在尝试用Devise为黄瓜创建一个测试。这是我的功能
Feature: Login to locomotive
In order to login to locomotive
As a user
I want to be able to use Locomotive
Scenario: Login to locomotive
Given I am a authenticated user
Then I should see "logged in as <email>"
Then show me the page
这是我的用户步骤
Given /^I am not authenticated$/ do
visit('/users/sign_out') # ensure that at least
end
Given /^I have one\s+user "([^\"]*)" with password "([^\"]*)" and username "([^\"]*)"$/ do |email, password, username|
@user = User.new(:email => email,
:username => username,
:first_name => 'Josh',
:last_name => 'Crowder',
:password => password,
:password_confirmation => password).save!
end
Given /^I am a authenticated user$/ do
email = 'testing@man.net'
username = 'josh'
password = 'secretpass'
Given %{I have one user "#{email}" with password "#{password}" and username "#{username}"}
And %{I go to login}
And %{I fill in "user_login" with "#{email}"}
And %{I fill in "user_password" with "#{password}"}
And %{I press "Sign in"}
end
我收到此错误消息
F--
(::) failed steps (::)
redirected more than 5 times, check for infinite redirects. (Capybara::InfiniteRedirectError)
./features/step_definitions/web_steps.rb:29:in `block (2 levels) in <top (required)>'
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:28:in `/^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/'
features/user_authentication.feature:7:in `Given I am a authenticated user'
Failing Scenarios:
cucumber features/user_authentication.feature:6 # Scenario: Login to locomotive
1 scenario (1 failed)
3 steps (1 failed, 2 skipped)
我不知道为什么会这样,有什么想法吗?
答案 0 :(得分:0)
可能有很多东西 - 如果没有更多的代码,就无法分辨。一些可能性:
当您通过浏览器尝试时会发生什么?