두 가지 카피 바라 테스트가 있습니다. 첫 번째 테스트는 사용자로 로그인하고, 두 번째 테스트는 로그인 한 사용자 만 사용할 수 있습니다.Capybara와 Rails 세션 유지 3
그러나 두 번째 테스트는 세션이 테스트를 통해 유지 관리되지 않으므로 수행 할 수 없습니다 (분명히 있어야 함).
require 'integration_test_helper'
class SignupTest < ActionController::IntegrationTest
test 'sign up' do
visit '/'
click_link 'Sign Up!'
fill_in 'Email', :with => '[email protected]'
click_button 'Sign up'
assert page.has_content?("Password can't be blank")
fill_in 'Email', :with => '[email protected]'
fill_in 'Password', :with => 'password'
fill_in 'Password confirmation', :with => 'password'
click_button 'Sign up'
assert page.has_content?("You have signed up successfully.")
end
test 'create a product' do
visit '/admin'
save_and_open_page
end
end
save_and_open_page 호출에 의해 생성 된 페이지는 글로벌 로그인 화면이 아닌 내가 (가입에서 로그에서)를 예상하는대로 관리자 홈페이지입니다. 여기서 내가 뭘 잘못하고 있니?