My Minitest controller tests are working fine if I run them alone using rake minitest:controllers
but when I run rake minitest:all
then I get validation failed error. It is because email is already used in model tests. I used DatabaseCleaner to clean the database but unable to clean database.
My code for database cleaner:
require "database_cleaner"
DatabaseCleaner.strategy = :transaction
class MiniTest::Rails::ActionController::TestCase
include Devise::TestHelpers
def setup
DatabaseCleaner.start
end
def teardown
DatabaseCleaner.clean
end
super
in the child test'ssetup
method. – Tabber