Created
November 2, 2012 11:47
-
-
Save francogonzaga/4000620 to your computer and use it in GitHub Desktop.
Minitest helper file with spork, factory girl and database cleaner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is the minitest helper file i use for a rails project | |
# TODO: add capybara | |
require 'spork' | |
if Spork.using_spork? | |
# make spork aware of changes in rails models | |
ActiveSupport::Dependencies.clear | |
ActiveRecord::Base.instantiate_observers | |
Spork.prefork do | |
ENV["RAILS_ENV"] = "test" | |
require File.expand_path('../../config/environment', __FILE__) | |
require "minitest/autorun" | |
require "minitest/rails" | |
require 'minitest/reporters' | |
require 'database_cleaner' | |
class MiniTest::Rails::ActiveSupport::TestCase | |
fixtures :all | |
end | |
# for formatting of reports | |
MiniTest::Reporters.use! MiniTest::Reporters::DefaultReporter.new | |
# Database cleaner. | |
# from: https://gist.github.com/raw/2257519/65ec4f11aee10e9e3fda8409c3ffd295ac0074f6/minitest_spec_setup.rb | |
DatabaseCleaner.strategy = :truncation | |
class MiniTest::Spec | |
before :each do | |
DatabaseCleaner.clean | |
end | |
end | |
end | |
Spork.each_run do | |
FactoryGirl.reload | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment