Skip to content

Commit b3dd77c

Browse files
author
Helen
authored
Merge pull request puppetlabs#79 from tphoney/MODULES-3958
(MODULES-3958) enable rspec-mock and code coverage
2 parents 68deba9 + 498b868 commit b3dd77c

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

.sync.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
---
2+
.gitlab-ci.yml:
3+
unmanaged: true
4+
25
.travis.yml:
36
docker_sets:
47
- set: docker/centos-7
@@ -38,9 +41,6 @@ Gemfile:
3841
version: '~> 1.3'
3942
condition: ENV['GEM_BOLT']
4043

41-
.gitlab-ci.yml:
42-
unmanaged: true
43-
4444
Rakefile:
4545
extras: |
4646
# The beaker task requires the test fixtures created by the spec_prep task
@@ -51,3 +51,7 @@ Rakefile:
5151
spec_prep = Rake::Task['spec_prep']
5252
beaker_task.enhance(beaker_task.prerequisite_tasks << spec_prep)
5353
end
54+
55+
spec/spec_helper.rb:
56+
mock_with: ':rspec'
57+
coverage_report: true

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@
6767
"description": "Tasks that manipulate a service",
6868
"pdk-version": "1.9.0",
6969
"template-url": "https://github.com/puppetlabs/pdk-templates/",
70-
"template-ref": "1.9.0-0-g7281db5"
70+
"template-ref": "heads/master-0-g615413e"
7171
}

spec/spec_helper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
RSpec.configure do |c|
2+
c.mock_with :rspec
3+
end
4+
15
require 'puppetlabs_spec_helper/module_spec_helper'
26
require 'rspec-puppet-facts'
37

@@ -34,6 +38,7 @@
3438
end
3539
c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
3640
c.after(:suite) do
41+
RSpec::Puppet::Coverage.report!(0)
3742
end
3843
end
3944

spec/spec_helper_local.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 '/spec'
15+
16+
# do not track vendored files
17+
add_filter '/vendor'
18+
add_filter '/.vendor'
19+
20+
# do not track gitignored files
21+
# this adds about 4 seconds to the coverage check
22+
# this could definitely be optimized
23+
add_filter do |f|
24+
# system returns true if exit status is 0, which with git-check-ignore means file is ignored
25+
system("git check-ignore --quiet #{f.filename}")
26+
end
27+
end
28+
end

0 commit comments

Comments
 (0)