Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rspec-puppet-facts: Require 3.0.0 #125

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/voxpupuli/test/facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def add_facts_for_metadata(metadata)
metadata['dependencies'].each do |dependency|
case normalize_module_name(dependency['name'])
when 'camptocamp/systemd', 'puppet/systemd'
add_custom_fact :systemd, ->(_os, facts) { facts['service_provider'] == 'systemd' }
add_custom_fact :systemd, ->(_os, facts) do
(RSpec.configuration.facterdb_string_keys ? facts['service_provider'] : facts[:service_provider]) == 'systemd'
end
when 'puppetlabs/stdlib'
add_stdlib_facts
end
Expand All @@ -70,9 +72,8 @@ def add_stdlib_facts

# Rough conversion of grepping in the puppet source:
# grep defaultfor lib/puppet/provider/service/*.rb
add_custom_fact :service_provider, ->(_os, facts) do
os = RSpec.configuration.facterdb_string_keys ? facts['os'] : facts[:os]
case os['family'].downcase
add_custom_fact 'service_provider', ->(_os, facts) do
case facts[:os]['family'].downcase
when 'archlinux'
'systemd'
when 'darwin'
Expand All @@ -86,9 +87,9 @@ def add_stdlib_facts
when 'openbsd'
'openbsd'
when 'redhat'
os['release']['major'].to_i >= 7 ? 'systemd' : 'redhat'
facts[:os]['release']['major'].to_i >= 7 ? 'systemd' : 'redhat'
when 'suse'
os['release']['major'].to_i >= 12 ? 'systemd' : 'redhat'
facts[:os]['release']['major'].to_i >= 12 ? 'systemd' : 'redhat'
when 'windows'
'windows'
else
Expand Down
2 changes: 2 additions & 0 deletions lib/voxpupuli/test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# and 7.12+ and requires rspec-puppet 2.11.0+.
config.facter_implementation = 'rspec'

config.facterdb_string_keys = true

config.after(:suite) do
RSpec::Puppet::Coverage.report!
end
Expand Down
7 changes: 3 additions & 4 deletions spec/facts_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'spec_helper'
require 'voxpupuli/test/facts'

describe 'override_facts' do
let(:base_facts) do
Expand Down Expand Up @@ -129,26 +128,26 @@
]
end

it 'has systemd on Red Hat 7' do

Check failure on line 131 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.3 - Puppet ~> 8.0

add_facts_for_metadata with systemd and stdlib has systemd on Red Hat 7 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil

Check failure on line 131 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.3 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has systemd on Red Hat 7 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil

Check failure on line 131 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.2 - Puppet ~> 8.0

add_facts_for_metadata with systemd and stdlib has systemd on Red Hat 7 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass

Check failure on line 131 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.2 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has systemd on Red Hat 7 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass

Check failure on line 131 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.1 - Puppet ~> 8.0

add_facts_for_metadata with systemd and stdlib has systemd on Red Hat 7 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass case facts[:os]['family'].downcase ^^^^^^^^^^

Check failure on line 131 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.1 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has systemd on Red Hat 7 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass case facts[:os]['family'].downcase ^^^^^^^^^^

Check failure on line 131 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.0 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has systemd on Red Hat 7 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass

Check failure on line 131 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 2.7 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has systemd on Red Hat 7 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass
add_facts_for_metadata(metadata)
facts = RspecPuppetFacts.with_custom_facts('redhat-7-x86_64', {
os: { 'family' => 'RedHat', 'release' => { 'major' => '7' } }
'os' => { 'family' => 'RedHat', 'release' => { 'major' => '7' } }
})
expect(facts['systemd']).to be true
end

it 'has no systemd on Red Hat 6' do

Check failure on line 139 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.3 - Puppet ~> 8.0

add_facts_for_metadata with systemd and stdlib has no systemd on Red Hat 6 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil

Check failure on line 139 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.3 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has no systemd on Red Hat 6 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil

Check failure on line 139 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.2 - Puppet ~> 8.0

add_facts_for_metadata with systemd and stdlib has no systemd on Red Hat 6 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass

Check failure on line 139 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.2 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has no systemd on Red Hat 6 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass

Check failure on line 139 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.1 - Puppet ~> 8.0

add_facts_for_metadata with systemd and stdlib has no systemd on Red Hat 6 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass case facts[:os]['family'].downcase ^^^^^^^^^^

Check failure on line 139 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.1 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has no systemd on Red Hat 6 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass case facts[:os]['family'].downcase ^^^^^^^^^^

Check failure on line 139 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.0 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has no systemd on Red Hat 6 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass

Check failure on line 139 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 2.7 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has no systemd on Red Hat 6 Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass
add_facts_for_metadata(metadata)
facts = RspecPuppetFacts.with_custom_facts('redhat-6-x86_64', {
os: {'family' => 'RedHat', 'release' => { 'major' => '6' }}
'os' => {'family' => 'RedHat', 'release' => { 'major' => '6' }}
})
expect(facts['systemd']).to be false
end

it 'has no systemd on openbsd' do

Check failure on line 147 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.3 - Puppet ~> 8.0

add_facts_for_metadata with systemd and stdlib has no systemd on openbsd Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil

Check failure on line 147 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.3 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has no systemd on openbsd Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil

Check failure on line 147 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.2 - Puppet ~> 8.0

add_facts_for_metadata with systemd and stdlib has no systemd on openbsd Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass

Check failure on line 147 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.2 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has no systemd on openbsd Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass

Check failure on line 147 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.1 - Puppet ~> 8.0

add_facts_for_metadata with systemd and stdlib has no systemd on openbsd Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass case facts[:os]['family'].downcase ^^^^^^^^^^

Check failure on line 147 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.1 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has no systemd on openbsd Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass case facts[:os]['family'].downcase ^^^^^^^^^^

Check failure on line 147 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.0 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has no systemd on openbsd Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass

Check failure on line 147 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 2.7 - Puppet ~> 7.24

add_facts_for_metadata with systemd and stdlib has no systemd on openbsd Failure/Error: case facts[:os]['family'].downcase NoMethodError: undefined method `[]' for nil:NilClass
add_facts_for_metadata(metadata)
facts = RspecPuppetFacts.with_custom_facts('openbsd-6.4-x86_64', {
os: { 'family' => 'OpenBSD' }
'os' => { 'family' => 'OpenBSD' }
})
expect(facts['systemd']).to be false
end
Expand All @@ -162,7 +161,7 @@
]
end

it 'adds the systemd fact' do

Check failure on line 164 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.3 - Puppet ~> 8.0

add_facts_for_metadata with stdlib adds the systemd fact Failure/Error: add_custom_fact 'service_provider', ->(_os, facts) do case facts[:os]['family'].downcase when 'archlinux' 'systemd' when 'darwin' 'launchd' when 'debian' 'systemd' when 'freebsd' 'freebsd' RspecPuppetFacts received :register_custom_fact with unexpected arguments expected: (:service_provider, an_instance_of(Proc), {}) got: ("service_provider", #<Proc:0x00007fdf24a3b7a8 /home/runner/work/voxpupuli-test/voxpupuli-test/lib/voxpupuli/test/facts.rb:75 (lambda)>, {})

Check failure on line 164 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.3 - Puppet ~> 7.24

add_facts_for_metadata with stdlib adds the systemd fact Failure/Error: add_custom_fact 'service_provider', ->(_os, facts) do case facts[:os]['family'].downcase when 'archlinux' 'systemd' when 'darwin' 'launchd' when 'debian' 'systemd' when 'freebsd' 'freebsd' RspecPuppetFacts received :register_custom_fact with unexpected arguments expected: (:service_provider, an_instance_of(Proc), {}) got: ("service_provider", #<Proc:0x00007fc7c1075f18 /home/runner/work/voxpupuli-test/voxpupuli-test/lib/voxpupuli/test/facts.rb:75 (lambda)>, {})

Check failure on line 164 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.2 - Puppet ~> 8.0

add_facts_for_metadata with stdlib adds the systemd fact Failure/Error: add_custom_fact 'service_provider', ->(_os, facts) do case facts[:os]['family'].downcase when 'archlinux' 'systemd' when 'darwin' 'launchd' when 'debian' 'systemd' when 'freebsd' 'freebsd' RspecPuppetFacts received :register_custom_fact with unexpected arguments expected: (:service_provider, an_instance_of(Proc), {}) got: ("service_provider", #<Proc:0x00007f65cda7a960 /home/runner/work/voxpupuli-test/voxpupuli-test/lib/voxpupuli/test/facts.rb:75 (lambda)>, {})

Check failure on line 164 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.2 - Puppet ~> 7.24

add_facts_for_metadata with stdlib adds the systemd fact Failure/Error: add_custom_fact 'service_provider', ->(_os, facts) do case facts[:os]['family'].downcase when 'archlinux' 'systemd' when 'darwin' 'launchd' when 'debian' 'systemd' when 'freebsd' 'freebsd' RspecPuppetFacts received :register_custom_fact with unexpected arguments expected: (:service_provider, an_instance_of(Proc), {}) got: ("service_provider", #<Proc:0x00007f05270bedd8 /home/runner/work/voxpupuli-test/voxpupuli-test/lib/voxpupuli/test/facts.rb:75 (lambda)>, {})

Check failure on line 164 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.1 - Puppet ~> 8.0

add_facts_for_metadata with stdlib adds the systemd fact Failure/Error: add_custom_fact 'service_provider', ->(_os, facts) do case facts[:os]['family'].downcase when 'archlinux' 'systemd' when 'darwin' 'launchd' when 'debian' 'systemd' when 'freebsd' 'freebsd' RspecPuppetFacts received :register_custom_fact with unexpected arguments expected: (:service_provider, an_instance_of(Proc), {}) got: ("service_provider", #<Proc:0x00007f95c0704268 /home/runner/work/voxpupuli-test/voxpupuli-test/lib/voxpupuli/test/facts.rb:75 (lambda)>, {})

Check failure on line 164 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.1 - Puppet ~> 7.24

add_facts_for_metadata with stdlib adds the systemd fact Failure/Error: add_custom_fact 'service_provider', ->(_os, facts) do case facts[:os]['family'].downcase when 'archlinux' 'systemd' when 'darwin' 'launchd' when 'debian' 'systemd' when 'freebsd' 'freebsd' RspecPuppetFacts received :register_custom_fact with unexpected arguments expected: (:service_provider, an_instance_of(Proc), {}) got: ("service_provider", #<Proc:0x00007f3a25172378 /home/runner/work/voxpupuli-test/voxpupuli-test/lib/voxpupuli/test/facts.rb:75 (lambda)>, {})

Check failure on line 164 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 3.0 - Puppet ~> 7.24

add_facts_for_metadata with stdlib adds the systemd fact Failure/Error: add_custom_fact 'service_provider', ->(_os, facts) do case facts[:os]['family'].downcase when 'archlinux' 'systemd' when 'darwin' 'launchd' when 'debian' 'systemd' when 'freebsd' 'freebsd' RspecPuppetFacts received :register_custom_fact with unexpected arguments expected: (:service_provider, an_instance_of(Proc), {}) got: ("service_provider", #<Proc:0x000055a14b4c6138 /home/runner/work/voxpupuli-test/voxpupuli-test/lib/voxpupuli/test/facts.rb:75 (lambda)>, {})

Check failure on line 164 in spec/facts_spec.rb

View workflow job for this annotation

GitHub Actions / Ruby 2.7 - Puppet ~> 7.24

add_facts_for_metadata with stdlib adds the systemd fact Failure/Error: add_custom_fact 'service_provider', ->(_os, facts) do case facts[:os]['family'].downcase when 'archlinux' 'systemd' when 'darwin' 'launchd' when 'debian' 'systemd' when 'freebsd' 'freebsd' RspecPuppetFacts received :register_custom_fact with unexpected arguments expected: (:service_provider, an_instance_of(Proc), {}) got: ("service_provider", #<Proc:0x0000561c2facc780 /home/runner/work/voxpupuli-test/voxpupuli-test/lib/voxpupuli/test/facts.rb:75 (lambda)>, {})
expect(RspecPuppetFacts).to receive(:register_custom_fact).with(:puppet_environmentpath, '/etc/puppetlabs/code/environments', {})
expect(RspecPuppetFacts).to receive(:register_custom_fact).with(:puppet_vardir, '/opt/puppetlabs/puppet/cache', {})
expect(RspecPuppetFacts).to receive(:register_custom_fact).with(:root_home, '/root', {})
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
end

require 'rspec/core'
require 'voxpupuli/test/spec_helper'
2 changes: 1 addition & 1 deletion voxpupuli-test.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |s|
# 3.0.0 and later require Ruby 2.7
s.add_runtime_dependency 'puppet-strings', '~> 4.0'
s.add_runtime_dependency 'rspec-puppet', '~> 4.0'
s.add_runtime_dependency 'rspec-puppet-facts', '~> 2.0', '>= 2.0.5'
s.add_runtime_dependency 'rspec-puppet-facts', '~> 3.0'
s.add_runtime_dependency 'rspec-puppet-utils', '~> 3.4'

# Rubocop
Expand Down
Loading