简体   繁体   中英

redirect to example.com when trying to sign in with Capybara, Cucumber, RSpec and Devise

Trying to get a very simple scenario passing using Cucumber and Devise - Signing in user... (EPIC FAIL)

I have a step like this:

user = create(user_sym)
user.confirm!

visit new_user_session_path
fill_in 'Email',:with => user.email
fill_in 'Password',:with => attributes_for(user_sym)[:password]
click_button 'Sign in'
page.should have_content('Sign out')

The logs show me all is good (confirm email sent, UPDATE inserts correct confirm flags), and then I see the redirect to

www.example.com

Lots of posts here and other places mention this and use login_user with :callback => false to make it work, but I want to use "visit".

What can be causing this. The actual error is the failing TEST ie that the Sign Out text doesn;t appear. What is being rendered is the Rails Homepage ie

 expected there to be text "Sign out" in "Browse the documentation Rails Guides Rails API Ruby core Ruby standard library Welcome aboard

I can't figure out which part of the stack is throwing this (as I'm NEW!). Presumably Capybara is redirecting? I've seen people get this is to work, and in my Dev stack it clearly redirects to the Users index page as you would expect.

Any light much appreciated.

I fixed this by returning specific path in after_sign_in_path_for in ApplicationController

  def after_sign_in_path_for(resource)
    xxxxx_path
  end

Somehow root route in cucumber tests gets redirected to "example.com"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM