Upgrading to 0.9

semmons99 edited this page Apr 4, 2013 · 3 revisions

Discontinue use of test/minitest_helper.rb

You can simply rename test/minitest_helper.rb to test/test_helper.rb.

You must also change the helper requires in your tests to point to the new helper. You can perform a search and replace with your editor, or you can execute the following in your terminal:

find . -name '*_test.rb' -exec sed -i 's/minitest_helper/test_helper/g' "{}" \;

Require rails/test_help in test/test_helper

Versions of minitest-rails below 0.9 created a test helper file that didn't include the rails/test_help file. This was due to how minitest-rails used to manipulate how rails loaded test classes in order to add a dependency on minitest. This is no longer needed and your test helper should require this file now, so that it is more closely matches the default test helper.

The test helper should start like so:

ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
require "minitest/rails"

Removing MiniTest::Rails namespace from TestCases

Versions of minitest-rails below 0.5 created TestCase objects under the MiniTest::Rails namespace. They were:

  • MiniTest::Rails::ActiveSupport::TestCase
  • MiniTest::Rails::ActionController::TestCase
  • MiniTest::Rails::ActionView::TestCase
  • MiniTest::Rails::ActionMailer::TestCase
  • MiniTest::Rails::ActionDispatch::TestCase

You should replace these classes in your tests with their standard classes:

  • MiniTest::Rails::ActiveSupport::TestCase should be renamed to ActiveSupport::TestCase
  • MiniTest::Rails::ActionController::TestCase should be renamed to ActionController::TestCase
  • MiniTest::Rails::ActionView::TestCase should be renamed to ActionView::TestCase
  • MiniTest::Rails::ActionMailer::TestCase should be renamed to ActionMailer::TestCase
  • MiniTest::Rails::ActionDispatch::TestCase should be renamed to ActionDispatch::TestCase

You can perform a search and replace with your editor, or you can execute the following in your terminal:

find . -name '*_test.rb' -exec sed -i '' 's/MiniTest::Rails:://g' "{}" \;

Renaming "Acceptance" tests

Versions of minitest-rails below 0.5 replaced the term "integration" with "acceptance", and created tests in the test/acceptance directory. These tests can be moved to test/integration and the term "Acceptance" in the test names can be replaced with "Integration".

If you want to leave these tests in test/acceptance, you will have to add the following to your test/test_helper.rb file:

class ActionDispatch::IntegrationTest
  # Register for "Acceptance"
  register_spec_type(/Acceptance( ?Test)?\z/i, self)

Remove override_testunit!

Versions of minitest-rails below 0.5 allowed users to choose whether to replace the default test classes by calling MiniTest::Rails.override_testunit! in the test helper. This functionality is no longer needed and all calls to this method can be removed.