Cucumber BDD 与水豚和设计集成
作为我之前关于SO的问题的后续行动,我已经按照以下教程进行操作https://github.com/RailsApps/rails3-devise-rspec-cucumber/wiki/Tutorial 虔诚地尝试查明我的测试失败的根源。
我的基本方案失败:
Feature: Sign in
Scenario: User signs in successfully with email
Given I am a new, authenticated user
When I go to the tour page
Then I should be signed in
这些是我的步骤:
Given /^I have one\s+user "([^\"]*)" with password "([^\"]*)"$/ do |email, password|
u = User.new(:email => email,
:password => password,
:password_confirmation => password)
u.skip_confirmation!
u.save!
end
Given /^I am a new, authenticated user$/ do
email = '[email protected]'
password = 'please'
Given %{I have one user "#{email}" with password "#{password}"}
And %{I go to the sign in page}
And %{I fill in "user_email" with "#{email}"}
And %{I fill in "user_password" with "#{password}"}
And %{I press "Log Me In"}
end
Then /^I should be signed in$/ do
And %{I should see "Sign out"}
end
即使我的测试用户已正确创建,登录也会失败。使用 save_and_open_page 显示水豚按预期填写了表单,因此这似乎是一个设计问题。
我想知道组件是否存在集成问题,因为我使用的是 Rails 3.0 设置(教程是关于 3.1 的)。
我的环境使用以下内容:
- ruby 1.8.7
- Rails 3.0.3
- capybara 1.0.0
- cucumber 1.0.0
- devise 1.2.rc
- rake 0.9.2
As a followup to my previous question on SO, I have followed the tutorial at https://github.com/RailsApps/rails3-devise-rspec-cucumber/wiki/Tutorial religiously to try pinpoint the origin of my test failures.
My basic scenario fails:
Feature: Sign in
Scenario: User signs in successfully with email
Given I am a new, authenticated user
When I go to the tour page
Then I should be signed in
These are my steps:
Given /^I have one\s+user "([^\"]*)" with password "([^\"]*)"$/ do |email, password|
u = User.new(:email => email,
:password => password,
:password_confirmation => password)
u.skip_confirmation!
u.save!
end
Given /^I am a new, authenticated user$/ do
email = '[email protected]'
password = 'please'
Given %{I have one user "#{email}" with password "#{password}"}
And %{I go to the sign in page}
And %{I fill in "user_email" with "#{email}"}
And %{I fill in "user_password" with "#{password}"}
And %{I press "Log Me In"}
end
Then /^I should be signed in$/ do
And %{I should see "Sign out"}
end
The login fails even though my test user is correctly created. Using save_and_open_page shows that capybara fills the form as expected so it seems like this is a devise issue.
I am wondering whether there is an integration issue with the components since I am using a rails 3.0 setup (the tutorial is on 3.1).
My environment is using the following:
- ruby 1.8.7
- rails 3.0.3
- capybara 1.0.0
- cucumber 1.0.0
- devise 1.2.rc
- rake 0.9.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论