Cucumber BDD with capybara and devise integration
Asked Answered
E

0

4

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
Esoteric answered 28/6, 2011 at 11:11 Comment(3)
you still having problems here?Curvy
Yes. I have used a workaround in the meantime to log in directly in ApplicationController but the issue above remains.Esoteric
I've been bitten by bad test data before, sometimes it's hard to test factories fully/properly. Try running a local server with the 'test' environment, and a 'test' console on the side as well. Create a new user from the same factory in your test steps, then try to actually log in with it from your browser.Curvy

© 2022 - 2024 — McMap. All rights reserved.