Disabling code coverage for guard spec runs

I ultimately found this solution:

  1. Add an environment variable in your Guardfile:

    guard :rspec, env: { 'NO_COVERAGE' => 'true' }

  2. Check for it from the spec helper:

    SimpleCov.start :rails unless ENV["NO_COVERAGE"]


In your spec helper:

unless ARGV.any? {|e| e =~ /guard-rspec/ }
  SimpleCov.start
end

The idea here is that guard-rspec invokes rspec with a special guard-rspec formatter. Looking for that on the command line given gives you the hint that it was invoked from Guard, so you can just skip SimpleCov if that's there.