Skip to content

Instantly share code, notes, and snippets.

@svlasov
Created September 26, 2012 14:41
Show Gist options
  • Save svlasov/3788439 to your computer and use it in GitHub Desktop.
Save svlasov/3788439 to your computer and use it in GitHub Desktop.
Minitest Rails setup
group :test, :development do
gem 'minitest-rails'
end
group :test do
gem "minitest-rails-capybara"
end
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require "minitest/autorun"
require "minitest/spec"
require "minitest/rails"
require "minitest/rails/capybara"
require "minitest/pride"
require "minitest_let"
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...
end
# Do you want all existing Rails tests to use MiniTest::Rails?
# Comment out the following and either:
# A) Change the require on the existing tests to `require "minitest_helper"`
# B) Require this file's code in test_helper.rb
MiniTest::Rails.override_testunit!
require 'minitest/spec'
require 'minitest/autorun'
module Helpers
module Let
def let(name, &blk)
define_method name do
@let_assigments ||= {}
@let_assigments[name] ||= send(:"original_#{name}")
end
define_method "original_#{name}", &blk
end
end
end
class MiniTest::Unit::TestCase
extend Helpers::Let
end
require "minitest_helper"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment