我遇到奇怪的非常測試行爲,登錄狀態處理不一致。爲什麼這些測試在同時運行時失敗,但每個都單獨通過?
該規範會記錄用戶,訪問(嵌套或非嵌套)索引頁,並檢查是否顯示正確的內容。記錄是異步提取的,但我認爲這不會產生影響。
當每個規格單獨運行時,它們都通過。當所有規格一起運行時,它們會因爲預期內容丟失而失敗。使用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的認爲用戶不會在所有規格一起運行在簽訂,但每個單獨的規格經過?