What is the difference between b / w minitest-rails and minitest-spec-rails?

Enabling use of Minitest for existing Rails 3.2. I am trying to understand the difference between minitest-rails and minitest-spec-rails.

+8
ruby-on-rails minitest
source share
2 answers

The main differences between minitest-spec-rails and minitest-rails are the volume of problems they solve.

MiniTest-SPEC-rails

minitest-spec-rails overrides the test framework that Rails provides by default and adds the ability to use DSL and Minitest Spec matches in your tests. This means that you do not need to make any changes to existing tests to start using Spec DSL. It also means that Spec DSL is available in every test.

MiniTest Rails

minitest-rails adds the ability to use Spec DSL, but also changes the way we write tests. It provides new generators for your tests and allows you to choose from statements such as TDD or BDD style expectations. It puts test files in more reasonable places.

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 framework similar to minitest-spec-rails, but you also have the option of leaving them untouched.

Disclaimer: I am the author of minitest-rails

+13
source share

With minitest-spec-rails, we have a working solution, replacing MiniTest :: Spec as the superclass for ActiveSupport :: TestCase. This solution is simple and does not require you to re-create a new test case in your test_helper.rb or to use the generators supplied with gems such as minitest-rails.

Minimal changes for testing in Rails. Your test classes inherit from MiniTest :: Rails :: ActiveSupport :: TestCase, the opposite of ActiveSupport :: TestCase. You can use MiniTest :: Spec DSL. You can create test files with a standard model, controller, resource and other generators.

rails generate model User 

or

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

 rails generate model User --spec 
+1
source share

All Articles