Grrr、私は以前この問題にぶつかり、時間を無駄にしてからそれを計算しました。
問題は、RSpecでテストが実行されていることです。その結果、トランザクションが使用され、結果としてトランザクション機能がコードから削除されます(この人はRSpecチームからこれを読んでいます。それにはトランザクションが含まれています - ty!)。 RSpecの内のトランザクション作業は、次のコードでそれを包むようにするために
:
describe "the set of cases you want to address" do
# make sure this next line is contained within a describe block or it'll affect everything
self.use_transactional_fixtures = false
after(:each) do
# destroy all objects you created (since RSpec won't roll them back for you)
# use delete rather than destroy to force removal
User.delete_all
Question.delete_all
end
it "should not destroy any questions when one fails to be destroyed" do
# assuming one of the questions throws an error on being destroyed
expect{
@user.destroy
}.to change{ Question.all.count }.by(0)
end
end
エンド
は、データベースとテーブル型を使用して、サポートのトランザクションを使用していることを確認していますか? – JofoCodin
こんにちは - 私はちょうど問題を解決し、以下に投稿しようとしています - それは、RSpecでテストしていたためです。 –