我遇到奇怪的非常测试行为,登录状态处理不一致。为什么这些测试在同时运行时失败,但每个都单独通过?
该规范会记录用户,访问(嵌套或非嵌套)索引页,并检查是否显示正确的内容。记录是异步提取的,但我认为这不会产生影响。
当每个规格单独运行时,它们都通过。当所有规格一起运行时,它们会因为预期内容丢失而失败。使用save_and_open_page
显示这是因为正在呈现登录页面,而不是预期的索引页面。
为什么rspec认为当所有规格一起运行时用户没有登录,但每个规格都单独传递?
测试看起来像所有需要JavaScript本
let(:user) {create :user}
let(:team) {create :team}
let(:country) {create :country}
before :each do
login_as(user, scope: :user)
end
describe 'unnested' do
it 'should have the expected content', :js do
visit users_path
is_expected.to have_content "some content on the page"
end
end
describe 'nested by team' do
it 'should have the expected content', :js do
visit team_users_path(team)
is_expected.to have_content "some content on the page"
end
end
describe 'nested by nationality' do
it 'should have the expected content', :js do
visit country_users_path(country)
is_expected.to have_content "some content on the page"
end
end
的规格(我不知道这是否是重要的在这里)。
认证是由设计处理,我rails_helper.rb
包括
config.append_after(:each) do
DatabaseCleaner.clean
Warden.test_reset!
end
为什么RSpec的认为用户不会在所有规格一起运行在签订,但每个单独的规格经过?