Skip to content

Instantly share code, notes, and snippets.

@agraves
Created October 4, 2012 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save agraves/3834525 to your computer and use it in GitHub Desktop.
Save agraves/3834525 to your computer and use it in GitHub Desktop.
Allow Minitest and Rspec to coexist
# Minitest and Rspec will need separate environments because both gems define 'describe'
# 'm' is a nice test runner gem. It lets you run 'm test/models/foo.rb:21'
# Gemfile
group :minitest do
gem 'minitest-rails'
gem 'minitest-rails-capybara'
gem 'factory_girl_rails'
gem 'm'
end
# Next, configure your Rakefile
# Rakefile
require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'rake/testtask'
Web::Application.load_tasks
Rake::TestTask.new do |t|
t.pattern = 'test/**/*.rb'
t.libs.push 'test'
end
Rake.application.instance_variable_get('@tasks').delete('default') # This prevents Rspec from owning 'rake'
task :default => [:spec, :test]
# Now let Minitest own your generators:
# config/application.rb, inside Web, Application
config.generators do |g|
g.test_framework :mini_test, :spec => true, :fixture => false
end
# Next, create the environment file
$ cp config/environments/test.rb config/environments/minitest.rb
# test/test_helper.rb
# Finally, make sure your test/test_helper.rb uses the minitest environment.
ENV["RAILS_ENV"] = "minitest"
require File.expand_path('../../config/environment', __FILE__)
class << ActiveSupport::TestCase
remove_method :describe
end
require "minitest/spec"
require "minitest/autorun"
require "minitest/rails"
# Uncomment if you want Capybara in accceptance/integration tests
require "minitest/rails/capybara"
# Uncomment if you want awesome colorful output
require "minitest/pride"
class MiniTest::Rails::ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
# fixtures :all
# Add more helper methods to be used by all tests here...
include FactoryGirl::Syntax::Methods
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment