Skip to content

Commit

Permalink
Make version fallback testing independent of installed facter gem
Browse files Browse the repository at this point in the history
This is entirely rspec-puppet-facts code, and should not depend on
facter, or FacterDB
  • Loading branch information
DavidS committed Jul 25, 2017
1 parent 2c983a4 commit 579eb66
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions spec/rspec_puppet_facts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@
end

context 'Without a custom facterversion in the options hash' do
before(:each) do
allow(Facter).to receive(:version).and_return('2.4.5')
end
subject do
on_supported_os(
supported_os: [
Expand All @@ -381,31 +384,33 @@
end

it 'returns facts from the loaded facter version' do
major, minor = Facter.version.split('.')
is_expected.to match(
'centos-7-x86_64' => include(
facterversion: /\A#{major}\.[0-#{minor}]\./
facterversion: /\A2\.4\./
)
)
end
end

context 'With a version that is above the current gem' do
before(:each) do
allow(Facter).to receive(:version).and_return('2.4.5')
end

subject do
major, minor = Facter.version.split('.')
on_supported_os(
supported_os: [
{ 'operatingsystem' => 'CentOS', 'operatingsystemrelease' => %w[7] }
],
facterversion: "#{major}.#{minor.to_i + 100}"
facterversion: "2.5"
)
end

it 'returns facts from a facter version matching future and below' do
major, minor = Facter.version.split('.')
is_expected.to match(
'centos-7-x86_64' => include(
facterversion: /\A#{major}\.[0-#{minor.to_i + 100}]\./
facterversion: /\A2\.4\./
)
)
end
Expand Down

0 comments on commit 579eb66

Please sign in to comment.