class Guard::RSpec::RSpecProcess
Attributes
command[R]
exit_code[R]
formatter_tmp_file[R]
results[R]
Public Class Methods
new(command, formatter_tmp_file)
click to toggle source
# File lib/guard/rspec/rspec_process.rb, line 11 def initialize(command, formatter_tmp_file) @command = command @formatter_tmp_file = formatter_tmp_file @results = nil @exit_code = _run @results = _read_results end
Public Instance Methods
all_green?()
click to toggle source
# File lib/guard/rspec/rspec_process.rb, line 20 def all_green? exit_code.zero? end
Private Instance Methods
_read_results()
click to toggle source
# File lib/guard/rspec/rspec_process.rb, line 55 def _read_results Results.new(formatter_tmp_file) rescue Errno::ENOENT msg = "Guard::RSpec cannot open results file: %s. This is likely a bug" "so please report this at" " http://github.com/guard/guard-rspec/issues/new along with as much" "information as possible to reproduce this issue." Compat::UI.error(format(msg, formatter_tmp_file.inspect)) raise ensure File.delete(formatter_tmp_file) if File.exist?(formatter_tmp_file) end
_really_run()
click to toggle source
# File lib/guard/rspec/rspec_process.rb, line 41 def _really_run env = { "GUARD_RSPEC_RESULTS_FILE" => formatter_tmp_file } _warn_unless_absolute_path(formatter_tmp_file) Compat::UI.debug("Guard::RSpec: results file: #{formatter_tmp_file}") pid = Kernel.spawn(env, command) # use spawn to stub in JRuby result = ::Process.wait2(pid) result.last.exitstatus rescue Errno::ENOENT => ex raise Failure, "Failed: #{command.inspect} (#{ex})" end
_run()
click to toggle source
# File lib/guard/rspec/rspec_process.rb, line 26 def _run _without_bundler_env do exit_code = _really_run msg = "Guard::RSpec: RSpec command %s exited with: %s" Compat::UI.debug(format(msg, command, exit_code.inspect)) unless [0, Command::FAILURE_EXIT_CODE].include?(exit_code) msg = "Failed: %s (exit code: %d)" raise Failure, format(msg, command.inspect, exit_code) end exit_code end end
_warn_unless_absolute_path(formatter_tmp_file)
click to toggle source
# File lib/guard/rspec/rspec_process.rb, line 76 def _warn_unless_absolute_path(formatter_tmp_file) return if Pathname(formatter_tmp_file).absolute? msg = "Guard::RSpec: The results file %s is not an absolute path." " Please provide an absolute path to avoid issues." Compat::UI.warning(format(msg, formatter_tmp_file.inspect)) end
_without_bundler_env() { || ... }
click to toggle source
# File lib/guard/rspec/rspec_process.rb, line 68 def _without_bundler_env if defined?(::Bundler) ::Bundler.with_clean_env { yield } else yield end end