내 생각한 사용자는 :confirmable
이며 가입 한 후 사용자가 devise 로그인 페이지로 리디렉션되는지 테스트하고 싶습니다. 수동으로 테스트 할 때 작동하지만 rspec/capybara 기능 사양에서는 실패합니다. 리디렉션을 설정하려면 these 안내를 따르고 있습니다.확인할 수있는 리디렉션 after_inactive_sign_up_path_for 확인 가능한 리디렉션
# registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
protected
def after_inactive_sign_up_path_for(_resource)
new_user_session_path # redirect to login
end
end
# registration_spec.rb
RSpec.describe 'registration process', type: feature do
it 'works' do
visit new_user_registration_path
fill_in 'Username', with: 'user123'
fill_in 'Email', with: '[email protected]'
fill_in 'Password', with: 'password123'
fill_in 'Password confirmation', with: 'password123'
click_on 'Sign up'
expect(User.find_by(username: 'user123')).not_to be_nil # sanity check
expect(page).to have_current_path(new_user_session_path) # failure here
end
end
않으면 반환 page
것 같다
Failure/Error: expect(page).to have_current_path(new_user_session_path)
expected "/users" to equal "https://stackoverflow.com/users/sign_in"
# ./spec/features/registration_spec.rb:19:in `block (2 levels) in <top (required)>'
는 포스트 경로에 갇혀있다, 또는 잘못 /users
로 리디렉션되고있다? 나는 사용자가 존재한다는 나의 온 전성 체크 때문에 폼이 입력을 받아들이는 것을 안다.