How do I set global configuration for RSpec in Ubuntu.
Specifically so, --color and --format specdoc stay turned on, across all my projects (ie every time I run rspec anywhere).
How do I set global configuration for RSpec in Ubuntu.
Specifically so, --color and --format specdoc stay turned on, across all my projects (ie every time I run rspec anywhere).
If you use rake to run rspec tests then you can edit spec/spec.opts
http://rspec.info/rails/runners.html
As you can see in the docs here, the intended use is creating
~/.rspec
and in it putting your options, such as--color
.To quickly create an
~/.rspec
file with the--color
option, just run:One can also use a
spec_helper.rb
file in all projects. The file should include the following:Any example file must require the helper to be able to use that options.
One thing to be aware of is the impact of the different ways of running RSpec.
I was trying to turn on the option with the following code in spec/spec_helper.rb -
In the end I used the ~/.rspec option, with just --tty as its contents. Works well for me and keeps our CI server output clean.
Or simply add
alias spec=spec --color --format specdoc
to your ~/.bashrc file like me.In your
spec_helper.rb
file, include the following option:You then must require in each
*_spec.rb
file that should use that option.