Skip to content

Commit

Permalink
Merge pull request #191 from bastelfreak/bug
Browse files Browse the repository at this point in the history
handle stringified facterversion properly
  • Loading branch information
bastelfreak authored Jun 26, 2024
2 parents 84730e6 + edb710b commit e613291
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rspec-puppet-facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ def on_supported_os_implementation(opts = {})
# FacterDB may have newer versions of facter data for which it contains a subset of all possible
# facter data (see FacterDB 0.5.2 for Facter releases 3.8 and 3.9). In this situation we need to
# cycle through and downgrade Facter versions per platform type until we find matching Facter data.
facterversion_key = RSpec.configuration.facterdb_string_keys ? 'facterversion' : :facterversion
filter.each do |filter_spec|
versions = FacterDB.get_facts(filter_spec, symbolize_keys: !RSpec.configuration.facterdb_string_keys).to_h do |facts|
[Gem::Version.new(facts[:facterversion]), facts]
[Gem::Version.new(facts[facterversion_key]), facts]
end

version, facts = versions.select { |v, _f| strict_requirement =~ v }.max_by { |v, _f| v }
Expand Down

0 comments on commit e613291

Please sign in to comment.