9

I'm using Ruby 2.2.0p0, and Rails 4.2.0. The Rails application is currently defaulting to using minitest, even though there's no testing gems mentioned in the Gemfile. For example, I have rake test in my rake tasks, and a test folder.

I can see how to install RSpec-rails. But what, if anything, do I need to do to uninstall minitest?

The only thing the RSpec-Rails README has is

Once installed, RSpec will generate spec files instead of Test::Unit test files when commands like rails generate model and rails generate controller are used.

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
  • minitest is the default if you have no others installed. Install one of the others and you should be good to go. Note that some of the others actually use test::unit under the covers, though - they're just a different DSL on top of it. – Taryn East Jul 27 '15 at 00:00
  • Minitest is part of ruby's core http://ruby-doc.org/stdlib-2.0.0/libdoc/minitest/rdoc/MiniTest.html – Orlando Jul 27 '15 at 01:59

1 Answers1

11

It seems to me that in your case it not necessary to uninstall minitest, just add rspec to your Gemfile and start using it. However I recommend you to make RSpec as your default test framework. Just add to config/application.rb next line:

config.generators.test_framework :rspec

That's it. Now Rails knows that you use RSpec and when you use Rails generators, it will add appropriate RSpec templete files, not Minitest ones. If you have test folder in your application (it's used by Minitest and Test::Unit) you can delete it now.

Tetiana Chupryna
  • 1,044
  • 1
  • 11
  • 28
  • Don't forget `config.generators.integration_tool :rspec`! Otherwise, generators will still create `test_unit` integration tests. – Ryan Lue Dec 05 '19 at 16:22
  • 2
    And as of RSpec 4.0, [both of these config options will be provided out-of-the-box](https://github.com/rspec/rspec-rails/blob/be3ae66f25863e05336d7fb54b363a833179aa4c/lib/rspec-rails.rb#L20-L21). – Ryan Lue Dec 06 '19 at 05:55