Class: Fauxhai::Mocker

Inherits:
Object
  • Object
show all
Defined in:
lib/fauxhai/mocker.rb

Constant Summary collapse

RAW_BASE =

The base URL for the GitHub project (raw)

'https://raw.github.com/customink/fauxhai/master'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|@data| ... } ⇒ Mocker

Create a new Ohai Mock with fauxhai.

Parameters:

  • options (Hash) (defaults to: {})

    the options for the mocker

Options Hash (options):

  • :platform (String)

    the platform to mock

  • :version (String)

    the version of the platform to mock

  • :path (String)

    the path to a local JSON file

Yields:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fauxhai/mocker.rb', line 23

def initialize(options = {}, &override_attributes)
  @options = options

  @data = fauxhai_data
  yield(@data) if block_given?

  if defined?(::ChefSpec) && ::ChefSpec::VERSION <= '0.9.0'
    data = @data
    ::ChefSpec::ChefRunner.send :define_method, :fake_ohai do |ohai|
      data.each_pair do |attribute, value|
        ohai[attribute] = value
      end
    end
  end

  @data
end

Instance Attribute Details

#dataHash (readonly)

Returns The raw ohai data for the given Mock.

Returns:

  • (Hash)

    The raw ohai data for the given Mock



11
12
13
# File 'lib/fauxhai/mocker.rb', line 11

def data
  @data
end