Skip to content

Commit

Permalink
Use facter 3 facts during tests
Browse files Browse the repository at this point in the history
By default, rspec-puppet-facts uses the facterdb facts that match the
version of the facter gem installed.  Starting with facter 3, facter
was no longer shipped as a gem (it was rewritten in C++).

This commit sets `facterversion` to `3.0.0` so that tests run with
more modern (structured) facts stubbed.

Puppet has been shipping facter 3 since puppet 4.2.0.  This module
supports puppet >= 4.6.1, (and puppet 4 is EOL at the end of 2018).

puppet-extlib's `ip_to_cron` function (used in
puppet::agent::service::cron) has recently moved to using the
`networking` structured fact not available in facter 2.
  • Loading branch information
alexjfisher authored and ekohl committed Sep 27, 2018
1 parent 73f7fe6 commit 07b9c7c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion spec/classes/puppet_agent_service_cron_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'deep_merge'

describe 'puppet::agent::service::cron' do
on_os_under_test.each do |os, facts|
Expand All @@ -12,7 +13,7 @@
end

let :facts do
facts.merge(ipaddress: '192.0.2.100')
facts.deep_merge(networking: { ip: '192.0.2.100' })
end

describe 'when runmode is not cron' do
Expand Down
3 changes: 2 additions & 1 deletion spec/classes/puppet_agent_service_systemd_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'deep_merge'

describe 'puppet::agent::service::systemd' do
on_os_under_test.each do |os, facts|
Expand All @@ -15,7 +16,7 @@
end

let :facts do
facts.merge(ipaddress: '192.0.2.100')
facts.deep_merge(networking: { ip: '192.0.2.100' })
end

describe 'when runmode is not systemd' do
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def exclude_test_os

# Use the above environment variables to limit the platforms under test
def on_os_under_test
on_supported_os.reject do |os, facts|
on_supported_os(facterversion: '3.0.0').reject do |os, facts|
(only_test_os() && !only_test_os.include?(os)) ||
(exclude_test_os() && exclude_test_os.include?(os))
end
Expand Down

0 comments on commit 07b9c7c

Please sign in to comment.