Class: Lino::Executors::Mock
- Inherits:
-
Object
- Object
- Lino::Executors::Mock
- Defined in:
- lib/lino/executors/mock.rb
Defined Under Namespace
Classes: Execution
Instance Attribute Summary collapse
-
#executions ⇒ Object
readonly
Returns the value of attribute executions.
-
#exit_code ⇒ Object
Returns the value of attribute exit_code.
-
#stderr_contents ⇒ Object
readonly
Returns the value of attribute stderr_contents.
-
#stdout_contents ⇒ Object
readonly
Returns the value of attribute stdout_contents.
Instance Method Summary collapse
- #execute(command_line, opts = {}) ⇒ Object
- #fail_all_executions ⇒ Object
-
#initialize ⇒ Mock
constructor
A new instance of Mock.
- #reset ⇒ Object
- #write_to_stderr(contents) ⇒ Object
- #write_to_stdout(contents) ⇒ Object
Constructor Details
#initialize ⇒ Mock
Returns a new instance of Mock.
9 10 11 |
# File 'lib/lino/executors/mock.rb', line 9 def initialize reset end |
Instance Attribute Details
#executions ⇒ Object (readonly)
Returns the value of attribute executions.
6 7 8 |
# File 'lib/lino/executors/mock.rb', line 6 def executions @executions end |
#exit_code ⇒ Object
Returns the value of attribute exit_code.
7 8 9 |
# File 'lib/lino/executors/mock.rb', line 7 def exit_code @exit_code end |
#stderr_contents ⇒ Object (readonly)
Returns the value of attribute stderr_contents.
6 7 8 |
# File 'lib/lino/executors/mock.rb', line 6 def stderr_contents @stderr_contents end |
#stdout_contents ⇒ Object (readonly)
Returns the value of attribute stdout_contents.
6 7 8 |
# File 'lib/lino/executors/mock.rb', line 6 def stdout_contents @stdout_contents end |
Instance Method Details
#execute(command_line, opts = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lino/executors/mock.rb', line 13 def execute(command_line, opts = {}) execution = Execution.new(command_line:, opts:, exit_code: @exit_code) execution = process_streams(execution, opts) @executions << execution return if @exit_code.zero? raise Lino::Errors::ExecutionError.new( command_line.string, @exit_code ) end |
#fail_all_executions ⇒ Object
26 27 28 |
# File 'lib/lino/executors/mock.rb', line 26 def fail_all_executions self.exit_code = 1 end |
#reset ⇒ Object
38 39 40 41 42 43 |
# File 'lib/lino/executors/mock.rb', line 38 def reset @executions = [] @exit_code = 0 @stdout_contents = nil @stderr_contents = nil end |
#write_to_stderr(contents) ⇒ Object
34 35 36 |
# File 'lib/lino/executors/mock.rb', line 34 def write_to_stderr(contents) @stderr_contents = contents end |
#write_to_stdout(contents) ⇒ Object
30 31 32 |
# File 'lib/lino/executors/mock.rb', line 30 def write_to_stdout(contents) @stdout_contents = contents end |