我有两个 capybara 测试,第一个是登录用户,第二个是为了测试仅对登录用户可用的功能。
但是,我无法让第二个测试正常工作,因为会话没有在测试中得到维护(显然,它应该是)。
require 'integration_test_helper'
class SignupTest < ActionController::IntegrationTest
test 'sign up' do
visit '/'
click_link 'Sign Up!'
fill_in 'Email', :with => 'bob@wagonlabs.com'
click_button 'Sign up'
assert page.has_content?("Password can't be blank")
fill_in 'Email', :with => 'bob@wagonlabs.com'
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 调用生成的页面是全局登录屏幕,而不是我期望的管理主页(注册登录)。我在这里做错了什么?