Skip to content

Commit

Permalink
(MODULES-3958) enable rspec-mock and code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
tphoney committed Feb 19, 2019
1 parent a941aaa commit f8f81bc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
14 changes: 9 additions & 5 deletions .sync.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---
.gitlab-ci.yml:
unmanaged: true

.travis.yml:
bundle_args: --without system_tests
docker_sets:
Expand All @@ -10,6 +13,9 @@
branches:
- release

appveyor.yml:
delete: true

Gemfile:
optional:
':development':
Expand All @@ -27,8 +33,6 @@ Gemfile:
- mingw
- x64_mingw

appveyor.yml:
delete: true

.gitlab-ci.yml:
unmanaged: true
spec/spec_helper.rb:
mock_with: ':rspec'
coverage_report: true
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@
}
],
"template-url": "https://github.com/puppetlabs/pdk-templates/",
"template-ref": "1.9.0-0-g7281db5",
"template-ref": "heads/master-0-g615413e",
"pdk-version": "1.9.0"
}
}
5 changes: 5 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
RSpec.configure do |c|
c.mock_with :rspec
end

require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'

Expand Down Expand Up @@ -34,6 +38,7 @@
end
c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
c.after(:suite) do
RSpec::Puppet::Coverage.report!(0)
end
end

Expand Down
29 changes: 27 additions & 2 deletions spec/spec_helper_local.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
RSpec.configure do |config|
config.mock_with :rspec
if ENV['COVERAGE'] == 'yes'
require 'simplecov'
require 'simplecov-console'
require 'codecov'

SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::Console,
SimpleCov::Formatter::Codecov,
]
SimpleCov.start do
track_files 'lib/**/*.rb'

add_filter '/spec'

# do not track vendored files
add_filter '/vendor'
add_filter '/.vendor'

# do not track gitignored files
# this adds about 4 seconds to the coverage check
# this could definitely be optimized
add_filter do |f|
# system returns true if exit status is 0, which with git-check-ignore means file is ignored
system("git check-ignore --quiet #{f.filename}")
end
end
end

def with_debian_facts
Expand Down

0 comments on commit f8f81bc

Please sign in to comment.