Skip to content

simple cov may not really show full coverage report #126

@bunnymatic

Description

@bunnymatic

In a recent project we kicked off with raygun

I turned on simple cov and because the default spec was broken into spec:without_features and spec:features, I think the coverage reports were getting clobbered.

I fixed it on my local project with new tasks like so (maybe not the best way...)

# in lib/tasks/cane.rake
begin
  require 'cane/rake_task'

  desc "Run cane to check quality metrics"
  Cane::RakeTask.new(:quality) do |cane|
    cane.abc_max = 10
    cane.add_threshold 'coverage/covered_percent', :>=, 98
    cane.no_style = true
    cane.abc_exclude = %w()
  cane.doc_exclude = %w(lib/templates/**/*)
  end

  task :default => :quality
rescue LoadError
  # warn "cane not available, quality task not provided."
end
# in lib/tasks/coverage.rake
namespace :spec do
  task :enable_coverage do
    ENV['COVERAGE'] = '1'
  end

  desc "Executes specs with code coverage reports"
  task coverage: :enable_coverage do
    Rake::Task[:'spec:all'].invoke
  end
end
# in lib/tasks/spec.rake
namespace :spec do
  desc "Run the code examples in spec/ except those in spec/features"
  RSpec::Core::RakeTask.new('without_features' => 'db:test:prepare') do |t|
    file_list = FileList['spec/**/*_spec.rb'].exclude('spec/features/**/*_spec.rb')

    t.pattern = file_list
  end
  RSpec::Core::RakeTask.new('all' => 'db:test:prepare') do |t|
    file_list = FileList['spec/**/*_spec.rb']
    t.pattern = file_list
  end

  desc 'Runs specs with coverage and cane checks'
  task cane: ['spec:enable_coverage', 'spec:coverage', 'quality']

end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions