Cucumber 和 Devise,重定向太多?
我正在尝试用黄瓜为 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 = '[email protected]'
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)
我不知道为什么会发生这种情况,有什么想法吗?
I am trying to create a test with cucumber for Devise. This is my feature
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
and this is my user steps
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 = '[email protected]'
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
Im getting this error message
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)
I have no clue why this is happening, any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能有很多事情——如果没有更多代码就无法判断。一些可能性:
当您通过浏览器尝试时会发生什么?
Could be tons of things -- no way to tell without more code. Some possibilities:
What happens when you try it through the browser?