Skip to content

Commit 983541d

Browse files
committed
(maint) use puppetlabs_spec_helper coverage config
1 parent 574ef57 commit 983541d

File tree

3 files changed

+9
-36
lines changed

3 files changed

+9
-36
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ branches:
1414
matrix:
1515
include:
1616
- rvm: 2.4.3
17-
env: PUPPET_GEM_VERSION='~> 5' COVERAGE=yes # 5.5
18-
- env: RVM="jruby-1.7.26" PUPPET_GEM_VERSION='~> 5' JRUBY_OPTS="--debug" COVERAGE=yes
17+
env: PUPPET_GEM_VERSION='~> 5' SIMPLECOV=yes # 5.5
18+
- env: RVM="jruby-1.7.26" PUPPET_GEM_VERSION='~> 5' JRUBY_OPTS="--debug" SIMPLECOV=yes
1919
before_cache: pushd ~/.rvm && rm -rf archives rubies/ruby-2.2.7 rubies/ruby-2.3.4 && popd
2020
cache:
2121
bundler: true
@@ -45,7 +45,7 @@ matrix:
4545
- rvm: 2.4.1
4646
env: PUPPET_GEM_VERSION='~> 5.0.0'
4747
- rvm: 2.1.9
48-
env: PUPPET_GEM_VERSION='~> 4' COVERAGE=yes # 4.10
48+
env: PUPPET_GEM_VERSION='~> 4' SIMPLECOV=yes # 4.10
4949
- rvm: 2.1.9
5050
env: PUPPET_GEM_VERSION='~> 4.9.0'
5151
- rvm: 2.1.9

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ end
2727
namespace :spec do
2828
desc 'Run RSpec code examples with coverage collection'
2929
task :coverage do
30-
ENV['COVERAGE'] = 'yes'
30+
ENV['SIMPLECOV'] = 'yes'
3131
Rake::Task['spec'].execute
3232
end
3333
end

spec/spec_helper.rb

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,4 @@
1-
if ENV['COVERAGE'] == 'yes'
2-
require 'simplecov'
3-
require 'simplecov-console'
4-
require 'codecov'
5-
6-
SimpleCov.formatters = [
7-
SimpleCov::Formatter::HTMLFormatter,
8-
SimpleCov::Formatter::Console,
9-
SimpleCov::Formatter::Codecov,
10-
]
11-
SimpleCov.start do
12-
track_files 'lib/**/*.rb'
13-
14-
add_filter 'lib/puppet/resource_api/version.rb'
15-
16-
add_filter '/spec'
17-
18-
# do not track vendored files
19-
add_filter '/vendor'
20-
add_filter '/.vendor'
21-
22-
# do not track gitignored files
23-
# this adds about 4 seconds to the coverage check
24-
# this could definitely be optimized
25-
add_filter do |f|
26-
# system returns true if exit status is 0, which with git-check-ignore means file is ignored
27-
system("git check-ignore --quiet #{f.filename}")
28-
end
29-
end
30-
end
31-
321
require 'bundler/setup'
33-
require 'puppet/resource_api'
342

353
RSpec.configure do |config|
364
# Enable flags like --only-failures and --next-failure
@@ -47,4 +15,9 @@
4715
config.mock_with :rspec
4816
end
4917

18+
# load puppet spec support and coverage setup before loading our code
5019
require 'puppetlabs_spec_helper/module_spec_helper'
20+
require 'puppet/resource_api'
21+
22+
# exclude the `version.rb` which already gets loaded by bundler via the gemspec, and doesn't need coverage testing anyways.
23+
SimpleCov.add_filter 'lib/puppet/resource_api/version.rb'

0 commit comments

Comments
 (0)