How do I globally configure RSpec to keep the '--color' and '--format specdoc' options turned on

前端 未结 6 822
日久生厌
日久生厌 2020-12-22 17:42

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 rspe

6条回答
  •  离开以前
    2020-12-22 18:00

    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 -

    Rspec.configure do |config|
      config.tty = $stdout.tty?
    end
    
    1. calling the 'rspec' binary directly - or as 'bundle exec rspec' and checking $stdout.tty? will return true.
    2. invoking the 'rake spec' task - or as 'bundle exec rake spec' - Rake will invoke rspec in a separate process, and $stdout.tty? will return false.

    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.

提交回复
热议问题