Class: BoltSpec::Plans::MockExecutor

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

Overview

Nothing on the executor is ‘public’

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMockExecutor

Returns a new instance of MockExecutor.



181
182
183
184
185
186
# File 'lib/bolt_spec/plans/mock_executor.rb', line 181

def initialize
  @noop = false
  @task_doubles = {}
  @allow_any_task = true
  @error_message = nil
end

Instance Attribute Details

#error_messageObject (readonly)

Returns the value of attribute error_message.



179
180
181
# File 'lib/bolt_spec/plans/mock_executor.rb', line 179

def error_message
  @error_message
end

#noopObject (readonly)

Returns the value of attribute noop.



179
180
181
# File 'lib/bolt_spec/plans/mock_executor.rb', line 179

def noop
  @noop
end

Instance Method Details

#assert_call_expectationsObject



202
203
204
205
206
# File 'lib/bolt_spec/plans/mock_executor.rb', line 202

def assert_call_expectations
  @task_doubles.map do |taskname, doub|
    doub.assert_called(taskname)
  end
end

#log_plan(_plan_name) ⇒ Object



212
213
214
# File 'lib/bolt_spec/plans/mock_executor.rb', line 212

def log_plan(_plan_name)
  yield
end

#report_bundled_content(_mode, _name) ⇒ Object



218
# File 'lib/bolt_spec/plans/mock_executor.rb', line 218

def report_bundled_content(_mode, _name); end

#report_function_call(_function) ⇒ Object



216
# File 'lib/bolt_spec/plans/mock_executor.rb', line 216

def report_function_call(_function); end

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



188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/bolt_spec/plans/mock_executor.rb', line 188

def run_task(targets, task, arguments, options)
  result = nil
  if (doub = @task_doubles[task.name] || @task_doubles[:default])
    result = doub.process(targets, task.name, arguments, options)
  end
  unless result
    targets = targets.map(&:name)
    params = arguments.merge(options)
    @error_message = "Unexpected call to 'run_task(#{task.name}, #{targets}, #{params})'"
    raise UnexpectedInvocation, @error_message
  end
  result
end

#stub_task(task_name) ⇒ Object



208
209
210
# File 'lib/bolt_spec/plans/mock_executor.rb', line 208

def stub_task(task_name)
  @task_doubles[task_name] ||= TaskDouble.new
end