Class: RSpec::Puppet::FacterTestImpl

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeFacterTestImpl

Returns a new instance of FacterTestImpl.



6
7
8
# File 'lib/rspec-puppet/facter_impl.rb', line 6

def initialize
  @facts = {}
end

Instance Method Details

#add(name, options = {}, &block) ⇒ Object



22
23
24
25
# File 'lib/rspec-puppet/facter_impl.rb', line 22

def add(name, options = {}, &block)
  raise 'Facter.add expects a block' unless block_given?
  @facts[name.to_s] = instance_eval(&block)
end

#clearObject



14
15
16
# File 'lib/rspec-puppet/facter_impl.rb', line 14

def clear
  @facts.clear
end

#debugging(arg) ⇒ Object

noop methods



28
# File 'lib/rspec-puppet/facter_impl.rb', line 28

def debugging(arg); end

#resetObject



30
# File 'lib/rspec-puppet/facter_impl.rb', line 30

def reset; end

#search(*paths) ⇒ Object



32
# File 'lib/rspec-puppet/facter_impl.rb', line 32

def search(*paths); end

#setup_loggingObject



34
# File 'lib/rspec-puppet/facter_impl.rb', line 34

def setup_logging; end

#to_hashObject



18
19
20
# File 'lib/rspec-puppet/facter_impl.rb', line 18

def to_hash
  @facts
end

#value(fact_name) ⇒ Object



10
11
12
# File 'lib/rspec-puppet/facter_impl.rb', line 10

def value(fact_name)
  @facts[fact_name.to_s]
end