0

Using Rails 3.2.13 and Test::Unit (actually implemented by MiniTest, if I understand right), I'm seeing fixture data remaining in the database after running the tests. I'm hoping there's a way to set it up so that the database is clean after the tests run.

This is my test_helper.rb file, mentioning transactional fixtures:

ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

class ActiveSupport::TestCase
  self.use_transactional_fixtures = true
  fixtures :all
end 

class ActionController::TestCase
  include Devise::TestHelpers
end

I had hoped that use_transactional_fixtures would do the trick, but either my hopes were misplaced, or I'm doing it wrong. Can you get me pointed in the right direction? Or am I hoping for something that is not commonly done?

Daniel Ashton
  • 1,388
  • 11
  • 23
  • 2
    Rails testing doesn't clean the database at the end of testing. All transactional fixtures does is reset the fixture data after each test. But the fixture data itself will still remain in the DB. Just the changes made during testing are reset. I.e. there is a ROLLBACK which is run after each test. – Casper Jun 18 '13 at 01:47
  • Thanks for the clarification. What I'm looking for is some way to get the fixture data itself to be added to the DB within the transaction, so that the rollback will clear it. I just don't understand the fixtures code well enough to see yet whether this is possible. – Daniel Ashton Jun 24 '13 at 14:56

0 Answers0