Skip to content
This repository

MiniTest integration for Rails 3 and 4

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 gemfiles
Octocat-spinner-32 lib
Octocat-spinner-32 tasks
Octocat-spinner-32 test
Octocat-spinner-32 .autotest Add Hoe
Octocat-spinner-32 .gemtest Add .gemtest file
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 CHANGELOG.rdoc
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Manifest.txt
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 minitest-rails.gemspec
README.rdoc

minitest-rails

MiniTest integration for Rails 3.x

Build
Status

Install

gem install minitest-rails

This installs the following gems:

minitest

Configure

Create a new rails app without Test::Unit:

rails new MyApp --skip-test-unit

Add minitest-rails to the :test and :development groups in Gemfile:

group :test, :development do
  gem 'minitest-rails'
end

Next run the installation generator with the following:

rails generate mini_test:install

This will add the minitest_helper.rb file to the test directory.

Usage

We aim to expose MiniTest with minimal changes for testing within Rails. Because of this, we allow Test::Unit and MiniTest tests to live side by side. Your test classes will inherit from MiniTest::Rails::ActiveSupport::TestCase a opposed to ActiveSupport::TestCase. You can use the MiniTest::Spec DSL. You can generate test files with the standard model, controller, resource, and other generators:

rails generate model User

And you can specify generating the tests using the MiniTest::Spec DSL on any of the generators by providing the --spec option:

rails generate model User --spec

And you can specify not generating the fixture for a model by providing the --skip-fixture option:

rails generate model User --skip-fixture

You can also set these as defaults by adding the following to the config/application.rb file:

config.generators do |g|
  g.test_framework :mini_test, :spec => true, :fixture => false
end

Overriding Test::Unit

Of course, you may not want to maintain separate Test::Unit and MiniTest tests. If this is the behavior you are wanting, simply add the following to your test_helper.rb file:

require "minitest/rails"
MiniTest::Rails.override_testunit!

Capybara

You can use Capybara in your acceptance/integration tests by adding minitest-rails-capybara as a dependency.

group :test, :development do
  gem 'minitest-rails'
  gem 'minitest-rails-capybara'
end

And add the following to your test helper file:

require "minitest/rails/capybara"

See the minitest-rails-capybara project for more information.

Incompatibilities

Existing tests that call describe will not work, since describe is used by MiniTest::Spec blocks.

Get Involved

Join the mailing list to get help or offer suggestions.

groups.google.com/group/minitest-rails

License

Copyright © 2012 Mike Moore

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.