Class: ChefSpec::Stubs::Stub

Inherits:
Object
  • Object
show all
Defined in:
lib/chefspec/stubs/stub.rb

Direct Known Subclasses

CommandStub, DataBagItemStub, DataBagStub, SearchStub

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value


4
5
6
# File 'lib/chefspec/stubs/stub.rb', line 4

def value
  @value
end

Instance Method Details

#and_raise(exception) ⇒ Object


11
12
13
14
# File 'lib/chefspec/stubs/stub.rb', line 11

def and_raise(exception)
  @block = Proc.new { raise exception }
  self
end

#and_return(value) ⇒ Object


6
7
8
9
# File 'lib/chefspec/stubs/stub.rb', line 6

def and_return(value)
  @value = value
  self
end

#resultObject


16
17
18
19
20
21
22
# File 'lib/chefspec/stubs/stub.rb', line 16

def result
  if @block
    recursively_mashify(@block.call)
  else
    recursively_mashify(@value)
  end
end