Class: CliTest::Execution

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cli-test/execution.rb

Overview

Encapsulates the execution results from the command

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdout, stderr, status) ⇒ CliTest::Execution

creates an object of type CliTest::Execution

Parameters:

  • stdout (String)

    the stdout of the execution

  • stderr (String)

    the stderr of the execution

  • status (Process::Status)

    the status of the execution



23
24
25
26
27
# File 'lib/cli-test/execution.rb', line 23

def initialize(stdout, stderr, status)
  @stdout = stdout
  @stderr = stderr
  @status = status
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



15
# File 'lib/cli-test/execution.rb', line 15

attr_reader :stdout, :stderr, :status

#stderrString (readonly)

Returns the stderr from the execution.

Returns:

  • (String)

    the stderr from the execution



15
# File 'lib/cli-test/execution.rb', line 15

attr_reader :stdout, :stderr, :status

#stdoutString (readonly)

Returns the stdout from the execution.

Returns:

  • (String)

    the stdout from the execution



15
16
17
# File 'lib/cli-test/execution.rb', line 15

def stdout
  @stdout
end

Instance Method Details

#outputString

returns the stdout and stderr combined with a newline (\n) separator.

Returns:

  • (String)

    the combined stdout and stderr of the execution



41
42
43
# File 'lib/cli-test/execution.rb', line 41

def output
  @stdout + "\n" + @stderr
end

#successful?Boolean

returns true if the status code for the execution is is zero

Returns:

  • (Boolean)

    whether the execution was successful



33
34
35
# File 'lib/cli-test/execution.rb', line 33

def successful?
  @status.success?
end