class ParallelTests::RSpec::Runner

Constants

DEV_NULL

Public Class Methods

command_with_seed(cmd, seed) click to toggle source

remove old seed and add new seed –seed 1234 –order rand –order rand:1234 –order random:1234

# File lib/parallel_tests/rspec/runner.rb, line 51
def command_with_seed(cmd, seed)
  clean = remove_command_arguments(cmd, '--seed', '--order')
  [*clean, '--seed', seed]
end
default_test_folder() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 28
def default_test_folder
  "spec"
end
determine_executable() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 14
def determine_executable
  if File.exist?("bin/rspec")
    ParallelTests.with_ruby_binary("bin/rspec")
  elsif ParallelTests.bundler_enabled?
    ["bundle", "exec", "rspec"]
  else
    ["rspec"]
  end
end
line_is_result?(line) click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 42
def line_is_result?(line)
  line =~ /\d+ examples?, \d+ failures?/
end
run_tests(test_files, process_number, num_processes, options) click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 9
def run_tests(test_files, process_number, num_processes, options)
  cmd = [*executable, *options[:test_options], *color, *spec_opts, *test_files]
  execute_command(cmd, process_number, num_processes, options)
end
runtime_log() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 24
def runtime_log
  "tmp/parallel_runtime_rspec.log"
end
summarize_results(results) click to toggle source

Summarize results from threads and colorize results based on failure and pending counts.

Calls superclass method
# File lib/parallel_tests/rspec/runner.rb, line 58
def summarize_results(results)
  text = super
  return text unless $stdout.tty?
  sums = sum_up_results(results)
  color =
    if sums['failure'] > 0
      31 # red
    elsif sums['pending'] > 0
      33 # yellow
    else
      32 # green
    end
  "\e[#{color}m#{text}\e[0m"
end
test_file_name() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 32
def test_file_name
  "spec"
end
test_suffix() click to toggle source

used to find all _spec.rb files supports also feature files used by rspec turnip extension

# File lib/parallel_tests/rspec/runner.rb, line 38
def test_suffix
  /(_spec\.rb|\.feature)$/
end

Private Class Methods

color() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 75
def color
  ['--color', '--tty'] if $stdout.tty?
end
spec_opts() click to toggle source
# File lib/parallel_tests/rspec/runner.rb, line 79
def spec_opts
  options_file = ['.rspec_parallel', 'spec/parallel_spec.opts', 'spec/spec.opts'].detect { |f| File.file?(f) }
  ["-O", options_file] if options_file
end