Class: BoltSpec::Plans::ActionDouble

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt_spec/plans/action_stubs.rb

Overview

Nothing in the ActionDouble is ‘public’

Instance Method Summary collapse

Constructor Details

#initialize(action_stub) ⇒ ActionDouble

Returns a new instance of ActionDouble.



11
12
13
14
# File 'lib/bolt_spec/plans/action_stubs.rb', line 11

def initialize(action_stub)
  @stubs = []
  @action_stub = action_stub
end

Instance Method Details

#add_stub(inventory = nil) ⇒ Object



27
28
29
30
31
# File 'lib/bolt_spec/plans/action_stubs.rb', line 27

def add_stub(inventory = nil)
  stub = Plans.const_get(@action_stub).new(false, inventory)
  @stubs.unshift stub
  stub
end

#assert_called(object) ⇒ Object



23
24
25
# File 'lib/bolt_spec/plans/action_stubs.rb', line 23

def assert_called(object)
  @stubs.each { |s| s.assert_called(object) }
end

#process(*args) ⇒ Object



16
17
18
19
20
21
# File 'lib/bolt_spec/plans/action_stubs.rb', line 16

def process(*args)
  matches = @stubs.select { |s| s.matches(*args) }
  unless matches.empty?
    matches[0].call(*args)
  end
end