Class: BoltSpec::Plans::TaskDouble

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

Overview

Nothing in the TaskDouble is ‘public’

Instance Method Summary collapse

Constructor Details

#initializeTaskDouble

Returns a new instance of TaskDouble.



14
15
16
# File 'lib/bolt_spec/plans/mock_executor.rb', line 14

def initialize
  @stubs = []
end

Instance Method Details

#add_stubObject



31
32
33
34
35
# File 'lib/bolt_spec/plans/mock_executor.rb', line 31

def add_stub
  stub = TaskStub.new
  @stubs.unshift stub
  stub
end

#assert_called(taskname) ⇒ Object



27
28
29
# File 'lib/bolt_spec/plans/mock_executor.rb', line 27

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

#process(targets, task, arguments, options) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/bolt_spec/plans/mock_executor.rb', line 18

def process(targets, task, arguments, options)
  # TODO: should we bother matching at all? or just call each
  # stub until one works?
  matches = @stubs.select { |s| s.matches(targets, task, arguments, options) }
  unless matches.empty?
    matches[0].call(targets, task, arguments, options)
  end
end