Cucumber BDD 与水豚和设计集成

发布于 2024-11-18 00:05:49 字数 1744 浏览 2 评论 0原文

作为我之前关于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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文