Class: RSpec::ShellCommand
- Inherits:
-
Object
- Object
- RSpec::ShellCommand
- 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
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.1.0'.freeze
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #execute ⇒ Object
- #execute! ⇒ Object
- #executed? ⇒ Boolean
-
#initialize(cmd) ⇒ ShellCommand
constructor
A new instance of ShellCommand.
Constructor Details
#initialize(cmd) ⇒ ShellCommand
Returns a new instance of ShellCommand.
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
#status ⇒ Object (readonly)
Returns the value of attribute status.
23 24 25 |
# File 'lib/rspec/shell_command.rb', line 23 def status @status end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
18 19 20 |
# File 'lib/rspec/shell_command.rb', line 18 def stderr @stderr end |
#stdout ⇒ Object (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
#execute ⇒ Object
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
43 44 45 |
# File 'lib/rspec/shell_command.rb', line 43 def executed? !@status.nil? end |