私は奇妙な非常にテストの動作を経験しており、ログイン状態が一貫して処理されていません。なぜこれらのテストは同時に実行されても、それぞれ個別にテストが失敗するのですか?
specはユーザーをログインさせ、(ネストされたまたはネストされていない)インデックスページを訪問し、正しい内容が表示されていることを確認します。レコードは非同期的にフェッチされますが、これは影響があるとは思いません。
各スペックを個別に実行すると、それぞれが通過します。すべての仕様が一緒に実行されると、期待される内容が失われているために失敗します。 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
スペック(つまり、ここでは重要であるかどうか私は知らない)のようなものを見て。
認証は工夫によって処理され、ユーザは、すべての仕様は一緒に実行された場合には署名されていないと思いますが、まだ各仕様は個別に渡しRSpecのないなぜrails_helper.rb
は
config.append_after(:each) do
DatabaseCleaner.clean
Warden.test_reset!
end
が含まれて?