How can I tell Rails to use RSpec instead of test-unit when creating a new Rails app?

aarona picture aarona · Jul 18, 2011 · Viewed 42.8k times · Source

I have test-unit installed and rspec installed (along with -core, -expectations, -mocks and -rails version 2.6.x). When I run the command rails new foo, it uses test-unit to generate the test stub files instead of rspec.

Is there an option where I can tell rails to use rspec to generate the tests instead?

Answer

Zabba picture Zabba · Jul 18, 2011

The following should work:

at command line:

rails new MYAPP -T # The -T option tells rails not to include Test::Unit

in Gemfile:

gem 'rspec-rails'

at command line:

bundle install
rails g rspec:install