Runners
Standard spec command
script/spec path/to/directory/with/specs script/spec path/to/individual_spec.rb
Run specs fast with −−drb (recommended)
Loading the entire Rails environment every time a spec is executed is quite slow.
To speed things up, Spec::Rails installs a daemon script that loads the local Rails app
and listens for incoming connections via DRb.
Open up a separate shell and start the spec server:
script/spec_server
Now you can run specs with the −−drb flag.
If you’re using Rake you should add −−drb to the spec/spec.opts file.
Note that there are some classes and modules that, by default, won’t get reloaded
by Rails, which means they won’t be reloaded by spec_server. There are a number
of strategies available for coercing Rails to reload files every time in a given
environment. See the Rails documentation for more information.
Running specs with Rake
Note that the rake tasks don’t use the fast rails_spec command – it uses the
standard spec. Also note that it is pre-configured to run any file that ends
in “_spec”, so you’ll have to follow that convention.
Note that you can configure the options passed to RSpec by editing the spec/spec.opts file.
All specs (excluding plugins) can be run with…
rake spec rake spec:app
All specs including plugins can be run with…
rake spec:all
You can also isolate Model, Controller, View, Helper or Plugin specs with…
rake spec:models rake spec:controllers rake spec:views rake spec:helpers rake spec:plugins
To see all the RSpec related tasks, run
rake --tasks spec