Class: PuppetUnitTests::FakeFacter
- Inherits:
-
Object
- Object
- PuppetUnitTests::FakeFacter
- Defined in:
- lib/puppet_unit_tests/fake_facter.rb
Overview
Pretend to be Facter just for tests.
Instance Method Summary collapse
- #add(name, _opts = {}, &block) ⇒ Object
- #clear ⇒ Object
- #debugging(arg) ⇒ Object
-
#initialize ⇒ FakeFacter
constructor
A new instance of FakeFacter.
- #reset ⇒ Object
- #search(*paths) ⇒ Object
- #setup_logging ⇒ Object
- #to_hash ⇒ Object
- #value(fact_name) ⇒ Object
Constructor Details
#initialize ⇒ FakeFacter
Returns a new instance of FakeFacter.
6 7 8 |
# File 'lib/puppet_unit_tests/fake_facter.rb', line 6 def initialize @facts = {} end |
Instance Method Details
#add(name, _opts = {}, &block) ⇒ Object
24 25 26 27 28 |
# File 'lib/puppet_unit_tests/fake_facter.rb', line 24 def add(name, _opts = {}, &block) raise "Facter.add expects a block" unless block @facts[name.to_s] = block.call end |
#clear ⇒ Object
16 17 18 |
# File 'lib/puppet_unit_tests/fake_facter.rb', line 16 def clear @facts.clear end |
#debugging(arg) ⇒ Object
30 |
# File 'lib/puppet_unit_tests/fake_facter.rb', line 30 def debugging(arg); end |
#reset ⇒ Object
32 |
# File 'lib/puppet_unit_tests/fake_facter.rb', line 32 def reset; end |
#search(*paths) ⇒ Object
34 |
# File 'lib/puppet_unit_tests/fake_facter.rb', line 34 def search(*paths); end |
#setup_logging ⇒ Object
36 |
# File 'lib/puppet_unit_tests/fake_facter.rb', line 36 def setup_logging; end |
#to_hash ⇒ Object
20 21 22 |
# File 'lib/puppet_unit_tests/fake_facter.rb', line 20 def to_hash @facts end |
#value(fact_name) ⇒ Object
10 11 12 13 14 |
# File 'lib/puppet_unit_tests/fake_facter.rb', line 10 def value(fact_name) @facts.dig(*fact_name.to_s.split(".")) rescue TypeError nil end |