MiniTest integration for Rails 3 and 4
<img src=“https://secure.travis-ci.org/blowmage/minitest-rails.png” alt=“Build Status” /> <img src=“https://codeclimate.com/badge.png” />
gem install minitest-rails
This installs the following gems:
minitest
Create a new rails app without Test::Unit:
rails new MyApp --skip-test-unit
Add minitest-rails
to the Gemfile:
gem "minitest-rails"
Next run the installation generator with the following:
rails generate mini_test:install
This will add the test_helper.rb
file to the test
directory.
This project aims to enable MiniTest within the Rails TestCase classes. Your test will continue to inherit from ActiveSupport::TestCase
, which will now support the 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
Efforts have been made to be compatible with Ruby 1.8.7, but some rough edges may remain. For the latest information on 1.8 compatibility see the wiki: github.com/blowmage/minitest-rails/wiki/Running-on-1.8
You can use Capybara for feature tests by adding minitest-rails-capybara
as a dependency. See the README for more information: github.com/blowmage/minitest-rails-capybara
The 0.9 release marks a new direction for minitest-rails. Deprecations have been added for the features that won’t make it to 1.0. See instructions for upgrading to 0.9: github.com/blowmage/minitest-rails/wiki/Upgrading-to-0.9
Existing tests that call describe
will not work, since describe
is used by MiniTest::Spec
blocks.
Join the mailing list to get help or offer suggestions.
groups.google.com/group/minitest-rails
Copyright © 2013 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.