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?
The following should work:
at command line:
in Gemfile:
at command line:
I'm a new developer and I just made a rails flag (-rspec) to address OP's problem. It gets rid of Test::Unit and inserts the rails-rspec gem with a bash script. The script can be modified to help linux developers by automatically adding therubyracer gem or create custom flags and gemsets. (maybe specifically going to that gem line and deleting the comment)
Here's the gist && I hope this helps someone out there. https://gist.github.com/MTen/8310116
Once you created your rails application with:
Add the RSpec gem to your Gemfile in the following way:
In Command line write:
Now you need to install RSpec by running:
This will generate the following files:
I strongly recommended to read through all spec_helper and rails_helper comments to get a good understanding of what each option does.
Once everything is set you can run all your tests with:
You can read more about the recommended spec_helper and rails_helper configurations on https://kolosek.com/rails-rspec-setup.
Create your new rails application as:
Or remove your
test
directory from your existing application:Make an entry in your Gemfile:
From the command line install the gem
From the command line install rspec into your application:
Now your rails application uses RSpec instead of test-unit.