From: tphoney Date: Tue, 19 Feb 2019 11:07:26 +0000 (+0000) Subject: (MODULES-3958) enable rspec-mock and code coverage X-Git-Tag: 1.15.2~10^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f8f81bcaacabb14a912c3fac8e5c7d053a1a357b;p=puppet-modules%2Fpuppetlabs-firewall.git (MODULES-3958) enable rspec-mock and code coverage --- diff --git a/.sync.yml b/.sync.yml index c924e7c..88a180d 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,4 +1,7 @@ --- +.gitlab-ci.yml: + unmanaged: true + .travis.yml: bundle_args: --without system_tests docker_sets: @@ -10,6 +13,9 @@ branches: - release +appveyor.yml: + delete: true + Gemfile: optional: ':development': @@ -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 diff --git a/metadata.json b/metadata.json index 38d9132..830e63c 100644 --- a/metadata.json +++ b/metadata.json @@ -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" -} +} \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0d5efc0..149ff03 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,7 @@ +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' @@ -34,6 +38,7 @@ RSpec.configure do |c| end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do + RSpec::Puppet::Coverage.report!(0) end end diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb index 4abf9f9..d2346d3 100644 --- a/spec/spec_helper_local.rb +++ b/spec/spec_helper_local.rb @@ -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