Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference b/w minitest-rails and minitest-spec-rails?

Looking into using Minitest for an existing Rails 3.2. I'm trying to understand the difference between minitest-rails and minitest-spec-rails.

like image 384
ckarbass Avatar asked Jun 16 '12 19:06

ckarbass


People also ask

Why does Rails use Minitest?

It's small, fast, and it aims to make tests clean and readable. Minitest is the default testing suite used with Rails, so no further setup is required to get it to work. Along with RSpec, it is one of the two most commonly used testing suites used in Ruby.

Is Minitest included with Ruby?

What is Minitest? Minitest is a testing tool for Ruby that provides a complete suite of testing facilities. It also supports behaviour-driven development, mocking and benchmarking.

How do you run a Minitest in rails?

To run a Minitest test, the only setup you really need is to require the autorun file at the beginning of a test file: require 'minitest/autorun' . This is good if you'd like to keep the code small. A better way to get started with Minitest is to have Bundler create a template project for you.

What are fixtures in rails?

Fixtures are data that you can feed into your unit testing. They are automatically created whenever rails generates the corresponding tests for your controllers and models. They are only used for your tests and cannot actually be accessed when running the application.


1 Answers

The main differences between minitest-spec-rails and minitest-rails is the scope of the problems they solve.

minitest-spec-rails

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

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

like image 68
blowmage Avatar answered Sep 18 '22 18:09

blowmage