Class: BoltSpec::Plans::MockExecutor
- Inherits:
-
Object
- Object
- BoltSpec::Plans::MockExecutor
- Defined in:
- lib/bolt_spec/plans/mock_executor.rb
Overview
Nothing on the executor is ‘public’
Instance Attribute Summary collapse
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#noop ⇒ Object
readonly
Returns the value of attribute noop.
Instance Method Summary collapse
- #assert_call_expectations ⇒ Object
-
#initialize ⇒ MockExecutor
constructor
A new instance of MockExecutor.
- #log_plan(_plan_name) ⇒ Object
- #report_bundled_content(_mode, _name) ⇒ Object
- #report_function_call(_function) ⇒ Object
- #run_task(targets, task, arguments, options) ⇒ Object
- #stub_task(task_name) ⇒ Object
Constructor Details
#initialize ⇒ MockExecutor
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_message ⇒ Object (readonly)
Returns the value of attribute error_message.
179 180 181 |
# File 'lib/bolt_spec/plans/mock_executor.rb', line 179 def @error_message end |
#noop ⇒ Object (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_expectations ⇒ Object
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, ) result = nil if (doub = @task_doubles[task.name] || @task_doubles[:default]) result = doub.process(targets, task.name, arguments, ) end unless result targets = targets.map(&:name) params = arguments.merge() @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 |