Khi cố gắng để làm theo ví dụ trên database_cleaner của GitHub page, tôi gặp phải lỗi sau từ RSpec:SQLite3 :: SQLException khi sử dụng database_cleaner với Rails/Spork/RSpec
ActiveRecord::StatementInvalid:
SQLite3::SQLException: cannot start a transaction within a transaction: begin transaction
Cấu hình sử dụng trong spec_helper.rb là:
require 'spork'
require 'database_cleaner'
Spork.prefork do
# .. snip
RSpec.configure do |config|
# .. snip
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
end
Spork.each_run do
end
Tôi gặp lỗi tương tự khi tạo bản ghi, có thể bạn có thể trợ giúp? http://stackoverflow.com/questions/14367396/sql-error-cannot-start-a-transaction-within-a-transaction-while-testing-with-cuc – pahnin