2

I have the following code at the top of spec/spec_helper.rb and features/support/env.rb (SimpleCov merging RSpec & Cucumber coverage results):

require 'simplecov'

I also have the following code in a .simplecov file in the project root:

SimpleCov.start 'rails'

However, for some reason, lib/tasks/cucumber.rake is included in the coverage...

enter image description here

Any ideas?

r123454321
  • 3,323
  • 11
  • 44
  • 63
  • In spec folder there is file rcov.opts, in this file we have –exclude option. We can append our path of files to this. for example i want to exclude helpers , sweepers folders, so just add/modify –exclude “helpers/*,app/sweepers/*”. In RSpec-1, the rake task would read in rcov options from an rcov.opts file. This is ignored by RSpec-2. RCov options are now set directly on the Rake task: RSpec::Core::RakeTask.new(:rcov) do |t| t.rcov_opts = %q[--exclude "spec/,gems/,features/*"] end – Kanti Mar 13 '15 at 08:28

2 Answers2

0

In spec folder there is file rcov.opts, in this file we have –exclude option.

We can append our path of files to this. for example i want to exclude helpers , sweepers folders, so just add/modify

–exclude “helpers/*,app/sweepers/*”. 

In RSpec-1, the rake task would read in rcov options from an rcov.opts file.

This is ignored by RSpec-2. RCov options are now set directly on the Rake task:

RSpec::Core::RakeTask.new(:rcov) do |t| 
    t.rcov_opts = %q[--exclude "spec/,gems/,features/*"] 
end
Kanti
  • 1,062
  • 1
  • 10
  • 27
0

I haven't used SimpleCov with RSpec before, but typically I would handle this type of scenario by adding a filter to SimpleCov after calling start. In your case it might mean changing the start call in .simplecov from

SimpleCov.start "rails"

to

SimpleCov.start("rails") do
  add_filter "lib/tasks/cucumber.rake"
end

Hope this helps!

tdg5
  • 1,131
  • 7
  • 6