Skip to content

Instantly share code, notes, and snippets.

@francogonzaga
Created November 2, 2012 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francogonzaga/4000620 to your computer and use it in GitHub Desktop.
Save francogonzaga/4000620 to your computer and use it in GitHub Desktop.
Minitest helper file with spork, factory girl and database cleaner
# 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