3
rspec을 사용하여 로그인 또는 가입 테스트를 통과하려고합니다. 모든 구성이 정상적으로 작동하고 이전의 모든 통합 테스트가 통과되었습니다. 아래capybara가 포함 된 셀레늄이 기기를 사용하여 로그인 할 수 없습니다.
사양 코드 :
visit "/"
save_and_open_page
expect(page).to have_no_selector '#register-dialog'
find(:css, 'a.button.signup').click
expect(page).to have_selector '#register-dialog'
fill_in 'customer_name', with: "abcde"
fill_in 'customer_email', with: "[email protected]"
fill_in 'customer_password', with: "abcdef"
find(:css, "input#customer_terms").set(true)
find(:css, 'input[type=\'submit\']').click
expect(page).to have_no_selector '#register-dialog'
expect(page).to have_selector '#after-register' # fails
# expected to find css "#after-register" but there were no matches
나는 마지막 단계는 테스트 데이터베이스, 에서 고객 사용자를 생성되지만 자동으로에 로그인 할 수 있는지 확인하십시오.
질문은 입니까? 개발 환경에서 모두 잘 작동합니다. 내가 유증 헬퍼에/가입하려고
RSpec.configure do |config|
config.use_transactional_examples = false
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.clean_with :truncation
DatabaseCleaner.strategy = :transaction
end
config.around(:each) do |spec|
if spec.metadata[:js] || spec.metadata[:test_commit]
spec.run
DatabaseCleaner.clean_with :deletion
else
DatabaseCleaner.start
spec.run
DatabaseCleaner.clean
begin
ActiveRecord::Base.connection.send(:rollback_transaction_records, true)
rescue
end
end
end
end
하지만 운 :
내가 데이터베이스 청소기를 사용, 설정 아래입니다.
테스트 ENV의host_name
는 셀레늄 서버 호스트와 다른했다
MyApp::Application.config.session_store :cookie_store, key: '_myapp_session', expire_after: 7.days, domain: {
...
test: AppConfig.host_name
}.fetch(Rails.env.to_sym, :all)
이 때문에 session_cookie
이 설정되지 않은 :
테스트에 로그인하지 않는다는 것을 어떻게 알 수 있습니까? 나는 아무런 주장도하지 않는다. 질문에 더 많은 정보를 추가하십시오. –
그 뒤에 sleep() 함수를 사용하고 웹 페이지 상태를 수동으로 확인합니다. 확인 메시지 상태에 대한 모든 어설 션 ("성공한 로그인"등)이 실패합니다. – justi
테스트를 게시하고 테스트 결과를 출력 한 다음 save_and_open_page를 실행하여 루트 결과 (입력 필드 및 해당 ID 확인)와 제출을 클릭 한 후 결과를 볼 수 있습니까? – HannesFostie