Sha256: 60b75d37ba2f77cb6e7a9c3f66a459be993741b1ee913d4f05db5e076082f6e9
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
require "guard/rspec/command" module Guard class RSpec < Plugin class RSpecProcess class Failure < RuntimeError end attr_reader :results def initialize(command, formatter_tmp_file) @command = command @formatter_tmp_file = formatter_tmp_file @results = nil @exit_code = _run @results = _read_results end def all_green? exit_code.zero? end private def _run _without_bundler_env do exit_code = _really_run unless [0, Command::FAILURE_EXIT_CODE].include?(exit_code) fail Failure, "Failed: #{command.inspect} (exit code: #{exit_code})" end exit_code end end def _really_run env = { "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 fail Failure, "Failed: #{command.inspect} (#{ex})" end def _read_results Results.new(formatter_tmp_file) ensure File.delete(formatter_tmp_file) if File.exist?(formatter_tmp_file) end def _without_bundler_env if defined?(::Bundler) ::Bundler.with_clean_env { yield } else yield end end attr_reader :command attr_reader :exit_code attr_reader :formatter_tmp_file end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
guard-rspec-4.6.5 | lib/guard/rspec/rspec_process.rb |