class ChefSpec::Stubs::Stub

Attributes

value[R]

Public Instance Methods

and_raise(exception) click to toggle source
# File lib/chefspec/stubs/stub.rb, line 11
def and_raise(exception)
  @block = Proc.new { raise exception }
  self
end
and_return(value) click to toggle source
# File lib/chefspec/stubs/stub.rb, line 6
def and_return(value)
  @value = value
  self
end
result() click to toggle source
# File lib/chefspec/stubs/stub.rb, line 16
def result
  if @block
    recursively_mashify(@block.call)
  else
    recursively_mashify(@value)
  end
end

Private Instance Methods

recursively_mashify(thing) click to toggle source
# File lib/chefspec/stubs/stub.rb, line 26
def recursively_mashify(thing)
  case thing
  when Array
    thing.collect { |item| recursively_mashify(item) }
  when Hash
    Mash.from_hash(thing)
  else
    thing
  end
end