class ParallelTests::RSpec::Runner

Public Class Methods

executable() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 13
def self.executable
  cmd = if File.file?("script/spec")
    "script/spec"
  elsif ParallelTests.bundler_enabled?
    cmd = (run("bundle show rspec") =~ %r{/rspec-1[^/]+$} ? "spec" : "rspec")
    "bundle exec #{cmd}"
  else
    %w[spec rspec].detect{|cmd| system "#{cmd} --version > /dev/null 2>&1" }
  end
  cmd or raise("Can't find executables rspec or spec")
end
run_tests(test_files, process_number, options) click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 6
def self.run_tests(test_files, process_number, options)
  exe = executable # expensive, so we cache
  version = (exe =~ /\brspec\b/ ? 2 : 1)
  cmd = "#{rspec_1_color if version == 1}#{exe} #{options[:test_options]} #{rspec_2_color if version == 2}#{spec_opts} #{test_files*' '}"
  execute_command(cmd, process_number, options)
end
runtime_log() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 25
def self.runtime_log
  'tmp/parallel_runtime_rspec.log'
end
test_file_name() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 29
def self.test_file_name
  "spec"
end
test_suffix() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 33
def self.test_suffix
  "_spec.rb"
end

Private Class Methods

rspec_1_color() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 44
def self.rspec_1_color
  'RSPEC_COLOR=1 ; export RSPEC_COLOR ;' if $stdout.tty?
end
rspec_2_color() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 48
def self.rspec_2_color
  '--color --tty ' if $stdout.tty?
end
run(cmd) click to toggle source

so it can be stubbed.…

# File lib/parallel_tests/rspec/runner.rb, line 40
def self.run(cmd)
  `#{cmd}`
end
spec_opts() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 52
def self.spec_opts
  options_file = ['.rspec_parallel', 'spec/parallel_spec.opts', 'spec/spec.opts'].detect{|f| File.file?(f) }
  return unless options_file
  "-O #{options_file}"
end