Skip to content

Commit 9e55ce3

Browse files
authored
Merge pull request #193 from DavidS/maint-test-fixes
(maint) test fixes
2 parents 9922bc6 + 8348d02 commit 9e55ce3

File tree

4 files changed

+15
-42
lines changed

4 files changed

+15
-42
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/puppet/resource_api_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ def set(_context, _changes, noop: false); end
17821782
context 'with a `simple_get_filter` provider', agent_test: true do
17831783
let(:definition) do
17841784
{
1785-
name: 'test_simple_get_filter',
1785+
name: 'test_simple_get_filter_2',
17861786
features: ['simple_get_filter'],
17871787
attributes: {
17881788
ensure: {
@@ -1796,7 +1796,7 @@ def set(_context, _changes, noop: false); end
17961796
},
17971797
}
17981798
end
1799-
let(:type) { Puppet::Type.type(:test_simple_get_filter) }
1799+
let(:type) { Puppet::Type.type(:test_simple_get_filter_2) }
18001800
let(:provider_class) do
18011801
Class.new do
18021802
def get(_context, _names = nil)
@@ -1806,11 +1806,11 @@ def get(_context, _names = nil)
18061806
def set(_context, changes) end
18071807
end
18081808
end
1809-
let(:provider) { instance_double('Puppet::Provider::TestSimpleGetFilter::TestSimpleGetFilter', 'provider') }
1809+
let(:provider) { instance_double('Puppet::Provider::TestSimpleGetFilter2::TestSimpleGetFilter2', 'provider') }
18101810

18111811
before(:each) do
1812-
stub_const('Puppet::Provider::TestSimpleGetFilter', Module.new)
1813-
stub_const('Puppet::Provider::TestSimpleGetFilter::TestSimpleGetFilter', provider_class)
1812+
stub_const('Puppet::Provider::TestSimpleGetFilter2', Module.new)
1813+
stub_const('Puppet::Provider::TestSimpleGetFilter2::TestSimpleGetFilter2', provider_class)
18141814
allow(provider_class).to receive(:new).and_return(provider)
18151815
end
18161816

@@ -1823,7 +1823,7 @@ def set(_context, changes) end
18231823

18241824
context 'with the type registered' do
18251825
it 'is seen as a supported feature' do
1826-
expect(Puppet).not_to receive(:warning).with(%r{Unknown feature detected:.*simple_test_filter})
1826+
expect(Puppet).not_to receive(:warning).with(%r{Unknown feature detected:.*simple_test_filter_2})
18271827
expect { described_class.register_type(definition) }.not_to raise_error
18281828
end
18291829

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' if ENV['SIMPLECOV'] == 'yes'

0 commit comments

Comments
 (0)