Class: RspecStarter::Command
- Inherits:
-
RspecStarterStep
- Object
- RspecStarterStep
- RspecStarter::Command
- Defined in:
- lib/rspec_starter/command.rb
Overview
Commands are steps that execute shell scripts or shell commands. They can be created using the command method inside the RspecStarter.start block. Commands execute quietly unless you specifically set ‘quiet: false’.
RspecStarter.start do
command "echo 'Done'"
command "echo 'This command shows the echo'", quiet: false
end
Instance Attribute Summary collapse
-
#status ⇒ Object
Returns the value of attribute status.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Attributes inherited from RspecStarterStep
#exit_status, #id, #name, #options, #quiet, #run_time, #runner, #successful
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(id, runner, command_string, options) ⇒ Command
constructor
A new instance of Command.
- #print_starting_message ⇒ Object
Methods inherited from RspecStarterStep
default_stop_on_problem, #failed?, #helpers, provide_options_to, #quiet?, register_options, #run, #should_skip?, #stop_on_problem?, #verbose?
Constructor Details
#initialize(id, runner, command_string, options) ⇒ Command
Returns a new instance of Command.
13 14 15 16 |
# File 'lib/rspec_starter/command.rb', line 13 def initialize(id, runner, command_string, ) super(id, runner, ) @command_string = command_string end |
Instance Attribute Details
#status ⇒ Object
Returns the value of attribute status.
11 12 13 |
# File 'lib/rspec_starter/command.rb', line 11 def status @status end |
#stderr ⇒ Object
Returns the value of attribute stderr.
11 12 13 |
# File 'lib/rspec_starter/command.rb', line 11 def stderr @stderr end |
#stdout ⇒ Object
Returns the value of attribute stdout.
11 12 13 |
# File 'lib/rspec_starter/command.rb', line 11 def stdout @stdout end |
Class Method Details
.default_quiet ⇒ Object
18 19 20 |
# File 'lib/rspec_starter/command.rb', line 18 def self.default_quiet true end |
Instance Method Details
#execute ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rspec_starter/command.rb', line 26 def execute if quiet? @stdout, @stderr, @status = Open3.capture3(@command_string) else @verbose_command_passed = system(@command_string) @status = $CHILD_STATUS print "Executed #{colored_command_string} -" end problem(exit_status: @status.exitstatus) if command_failed? end |
#print_starting_message ⇒ Object
22 23 24 |
# File 'lib/rspec_starter/command.rb', line 22 def print "Executing #{colored_command_string} ..." + (quiet? ? "" : "\n") end |