Class: Tomo::Testing::MockPluginTester
- Inherits:
-
Object
- Object
- Tomo::Testing::MockPluginTester
- Includes:
- LogCapturing
- Defined in:
- lib/tomo/testing/mock_plugin_tester.rb
Instance Method Summary collapse
- #call_helper(helper, *args, **kwargs) ⇒ Object
- #executed_script ⇒ Object
- #executed_scripts ⇒ Object
-
#initialize(*plugin_names, settings: {}, release: {}) ⇒ MockPluginTester
constructor
A new instance of MockPluginTester.
- #mock_script_result(script = /.*/) ⇒ Object
- #run_task(task, *args) ⇒ Object
Methods included from LogCapturing
Constructor Details
#initialize(*plugin_names, settings: {}, release: {}) ⇒ MockPluginTester
Returns a new instance of MockPluginTester.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/tomo/testing/mock_plugin_tester.rb', line 8 def initialize(*plugin_names, settings: {}, release: {}) @host = Host.parse("testing@host") @host.release.merge!(release) config = Configuration.new config.hosts << @host config.plugins.push(*plugin_names, "testing") config.settings[:application] = "testing" config.settings.merge!(settings) @runtime = config.build_runtime end |
Instance Method Details
#call_helper(helper, *args, **kwargs) ⇒ Object
19 20 21 22 |
# File 'lib/tomo/testing/mock_plugin_tester.rb', line 19 def call_helper(helper, *args, **kwargs) run_task("testing:call_helper", helper, args, kwargs) host.helper_values.pop end |
#executed_script ⇒ Object
31 32 33 34 35 |
# File 'lib/tomo/testing/mock_plugin_tester.rb', line 31 def executed_script return executed_scripts.first unless executed_scripts.length > 1 raise "Expected one executed script, got multiple: #{executed_scripts}" end |
#executed_scripts ⇒ Object
37 38 39 |
# File 'lib/tomo/testing/mock_plugin_tester.rb', line 37 def executed_scripts host.scripts.map(&:to_s) end |
#mock_script_result(script = /.*/) ⇒ Object
41 42 43 44 |
# File 'lib/tomo/testing/mock_plugin_tester.rb', line 41 def mock_script_result(script=/.*/, **) host.mock(script, **) self end |
#run_task(task, *args) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/tomo/testing/mock_plugin_tester.rb', line 24 def run_task(task, *args) capturing_logger_output do runtime.run!(task, *args, privileged: false) nil end end |