rspec for facts with multiple resolutions

10 views
Skip to first unread message

Fabien Wernli

unread,
Nov 30, 2015, 9:02:41 AM11/30/15
to Puppet Users
Hi,

I'm trying to write rspec tests for facts with multiple resolutions.

I know I can stub facts, and thus test all resolutions by targeting them using the stubbed facts.
But how do I test a given resolution if the previous fails?
Or how do I test a given resolution when it was given an explicit weight and no confine statements?

Example:

<code>
Facter.add(:foo) do
  has_weight 100
  setcode do
    "bar"
  end
end

Facter.add(:foo) do
  has_weight 200
  setcode do
    nil
  end
end
</code>

This fact should return "bar", but how do I test it in rspec?
Reply all
Reply to author
Forward
0 new messages