Class: RSpec::ShellCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/shell_command.rb,
lib/rspec/shell_command/dsl.rb,
lib/rspec/shell_command/version.rb,
lib/rspec/shell_command/matchers.rb,
lib/rspec/shell_command/matchers/base.rb,
lib/rspec/shell_command/matchers/output.rb,
lib/rspec/shell_command/matchers/success.rb,
lib/rspec/shell_command/matchers/exit_with.rb

Overview

Wrapper of external command

Author:

Defined Under Namespace

Modules: DSL, Matchers

Constant Summary collapse

VERSION =
'0.1.0'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd) ⇒ ShellCommand

Returns a new instance of ShellCommand.

Parameters:

  • wrapped (String)

    command string



28
29
30
31
# File 'lib/rspec/shell_command.rb', line 28

def initialize(cmd)
  @cmd = cmd.to_s
  @stdout = @stderr = @status = nil
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



23
24
25
# File 'lib/rspec/shell_command.rb', line 23

def status
  @status
end

#stderrObject (readonly)

Returns the value of attribute stderr.



18
19
20
# File 'lib/rspec/shell_command.rb', line 18

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



13
14
15
# File 'lib/rspec/shell_command.rb', line 13

def stdout
  @stdout
end

Instance Method Details

#executeObject



33
34
35
36
# File 'lib/rspec/shell_command.rb', line 33

def execute
  execute! unless executed?
  self
end

#execute!Object



38
39
40
41
# File 'lib/rspec/shell_command.rb', line 38

def execute!
  @stdout, @stderr, @status = Open3.capture3(@cmd)
  self
end

#executed?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/rspec/shell_command.rb', line 43

def executed?
  !@status.nil?
end