Created
September 26, 2012 14:41
-
-
Save svlasov/3788439 to your computer and use it in GitHub Desktop.
Minitest Rails setup
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
group :test, :development do | |
gem 'minitest-rails' | |
end | |
group :test do | |
gem "minitest-rails-capybara" | |
end |
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
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! |
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
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 |
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
require "minitest_helper" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment