Reputation: 3681
Looking into using Minitest for an existing Rails 3.2. I'm trying to understand the difference between minitest-rails and minitest-spec-rails.
Upvotes: 8
Views: 1694
Reputation: 8984
The main differences between minitest-spec-rails and minitest-rails is the scope of the problems they solve.
minitest-spec-rails overrides the test infrastructure that Rails provides by default and adds the ability to use the Minitest Spec DSL and matchers in your tests. This means that you don't have to make any changes to your existing tests to start using the Spec DSL. It also means that the Spec DSL is available in every test.
minitest-rails adds the ability to use the Spec DSL, but also changes the approach to how tests are written. It provides new generators for your tests, and allows you to choose from the TDD-style assertions or the BDD-style expectations. It places test files in more sensible locations.
It also allows your existing tests to live side by side with your new Minitest tests. You have the option to override the default test infrastructure similar to minitest-spec-rails, but you also have the option to leave them untouched.
Disclosure: I am the author of minitest-rails
Upvotes: 13
Reputation: 1383
With minitest-spec-rails, we have a working solution by replacing MiniTest::Spec as the superclass for ActiveSupport::TestCase. This solution is simple and does not require you to recreate a new test case in your test_helper.rb or to use generators supplied by gems like minitest-rails.
Minitest changes for testing within Rails. 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
or
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
Upvotes: 1