Class: RSpec::Puppet::FacterTestImpl
- Inherits:
-
Object
- Object
- RSpec::Puppet::FacterTestImpl
- Defined in:
- lib/rspec-puppet/facter_impl.rb
Overview
Implements a simple hash-based version of Facter to be used in module tests that use rspec-puppet.
Instance Method Summary collapse
- #add(name, _options = {}, &block) ⇒ Object
- #clear ⇒ Object
-
#debugging(arg) ⇒ Object
noop methods.
-
#initialize ⇒ FacterTestImpl
constructor
A new instance of FacterTestImpl.
- #reset ⇒ Object
- #search(*paths) ⇒ Object
- #setup_logging ⇒ Object
- #to_hash ⇒ Object
- #value(fact_name) ⇒ Object
Constructor Details
#initialize ⇒ FacterTestImpl
Returns a new instance of FacterTestImpl.
7 8 9 |
# File 'lib/rspec-puppet/facter_impl.rb', line 7 def initialize @facts = {} end |
Instance Method Details
#add(name, _options = {}, &block) ⇒ Object
25 26 27 28 29 |
# File 'lib/rspec-puppet/facter_impl.rb', line 25 def add(name, = {}, &block) raise 'Facter.add expects a block' unless block @facts[name.to_s] = instance_eval(&block) end |
#clear ⇒ Object
17 18 19 |
# File 'lib/rspec-puppet/facter_impl.rb', line 17 def clear @facts.clear end |
#debugging(arg) ⇒ Object
noop methods
32 |
# File 'lib/rspec-puppet/facter_impl.rb', line 32 def debugging(arg); end |
#reset ⇒ Object
34 |
# File 'lib/rspec-puppet/facter_impl.rb', line 34 def reset; end |
#search(*paths) ⇒ Object
36 |
# File 'lib/rspec-puppet/facter_impl.rb', line 36 def search(*paths); end |
#setup_logging ⇒ Object
38 |
# File 'lib/rspec-puppet/facter_impl.rb', line 38 def setup_logging; end |
#to_hash ⇒ Object
21 22 23 |
# File 'lib/rspec-puppet/facter_impl.rb', line 21 def to_hash @facts end |
#value(fact_name) ⇒ Object
11 12 13 14 15 |
# File 'lib/rspec-puppet/facter_impl.rb', line 11 def value(fact_name) @facts.dig(*fact_name.to_s.split('.')) rescue TypeError nil end |