Devise feature tests not redirecting to sign_in page

I’ve noticed some strange behavior ONLY in feature tests when a user is not logged in and they aren’t being redirected to the sign in page and I’m trying to understand why. I’m using poltergeist as the javascript driver.

Here’s a couple of examples:

# works as expected
it 'redirects to sign_in page when not logged in' do
  get :index, {}
  expect(response).to redirect_to('/users/sign_in')
end

# does not redirect to '/users/sign_in'
it 'should redirect to the user sign in page' do
  visit '/'
  expect(page.current_path).to eq('/users/sign_in')
end

Does anyone know why devise isn’t redirecting to the sign_in page in feature tests?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.