Starting a rails project with rspec

Here is a step by step guide to creating a rails application with rspec instead of the standard test suite.

code following a `$` should be implemented in the command line.

‘…’ implies there is more code surrounding the code shown


$ rails new project_name -T

T skip all the test unit files

$ cd project_name

open up your new rails project and add the rspec-rails gem in the test and development group:

file: /Gemfile

group :development, :test do
 gem ‘rspec-rails’
end

now install your dependancies:

$ bundle

Generate spec files:

$ rails g rspec:install

If this command didn’t work you most likely got something like this:

Running via Spring preloader in process 2923
Could not find generator ‘rspec:install’. Maybe you meant ‘responders:install’, ‘devise:install’ or ‘serializer’
Run `rails generate — help` for more options.

The solution I found for this is to stop Spring and run the command again:

spring stop
rails g rspec:install

now that should create the files you need. Now when you generate models spec files are automatically created.

I do not know what implications this method has on your application but once I research more into spring I’ll come back and update this with what’s going in here.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.