rspec+capybara を使用していくつかのテストを作成しました。テストコード
rspecでそれらを実行すると、すべて合格します
git:(master) ✗ rspec
Rack::File headers parameter replaces cache_control after Rack 1.5.
WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
.WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
.WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
.WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
.WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
.WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
.WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
.WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
.
Finished in 32.54 seconds
8 examples, 0 failures
しかし、ガードを使用すると、一部が失敗する傾向があります(一部のテストは失敗する場合があり、時々失敗する場合があります)
ガード出力
この動作はどのように説明できますか? そして、それはどのように修正できますか?
更新 1
私はすでにgem 'database_cleaner'
この構成で使用しています:
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:transaction)
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = :transaction
config.use_transactional_examples = true
更新 2
いくつかのファイルを変更しましたhttps://github.com/Asmmund/notes/commit/a5e0a43d6247bb8f937fb7e9dcc8d8cfa7bfc4ea