Class: ParallelTests::RSpec::Runner

Inherits:
Test::Runner show all
Defined in:
lib/parallel_tests/rspec/runner.rb

Constant Summary collapse

DEV_NULL =
(WINDOWS ? "NUL" : "/dev/null")
NAME =
'RSpec'

Class Method Summary collapse

Methods inherited from Test::Runner

execute_command, execute_command_and_capture_output, find_results, line_is_result?, name, summarize_results, test_env_number, tests_in_groups, tests_with_size

Class Method Details

.determine_executableObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/parallel_tests/rspec/runner.rb', line 18

def determine_executable
  cmd = case
  when File.exist?("bin/rspec")
    WINDOWS ? "ruby bin/rspec" : "bin/rspec"
  when File.file?("script/spec")
    "script/spec"
  when ParallelTests.bundler_enabled?
    cmd = (run("bundle show rspec-core") =~ %r{Could not find gem.*} ? "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, num_processes, options) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/parallel_tests/rspec/runner.rb', line 10

def run_tests(test_files, process_number, num_processes, options)
  exe = executable # expensive, so we cache
  version = (exe =~ /\brspec\b/ ? 2 : 1)
  cmd = [exe, options[:test_options], (rspec_2_color if version == 2), spec_opts, *test_files].compact.join(" ")
  options = options.merge(:env => rspec_1_color) if version == 1
  execute_command(cmd, process_number, num_processes, options)
end

.runtime_logObject



34
35
36
# File 'lib/parallel_tests/rspec/runner.rb', line 34

def runtime_log
  'tmp/parallel_runtime_rspec.log'
end

.test_file_nameObject



38
39
40
# File 'lib/parallel_tests/rspec/runner.rb', line 38

def test_file_name
  "spec"
end

.test_suffixObject



42
43
44
# File 'lib/parallel_tests/rspec/runner.rb', line 42

def test_suffix
  /_spec\.rb$/
end