Class: ParallelTests::RSpec::Runner

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

Constant Summary

Constants inherited from Test::Runner

Test::Runner::RuntimeLogTooSmallError

Class Method Summary collapse

Methods inherited from Test::Runner

execute_command, execute_command_and_capture_output, find_results, print_command, test_env_number, tests_in_groups, tests_with_size

Class Method Details

.build_test_command(file_list, options) ⇒ Object



44
45
46
# File 'lib/parallel_tests/rspec/runner.rb', line 44

def build_test_command(file_list, options)
  [*executable, *options[:test_options], *color, *spec_opts, *file_list]
end

.command_with_seed(cmd, seed) ⇒ Object

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



53
54
55
56
# File 'lib/parallel_tests/rspec/runner.rb', line 53

def command_with_seed(cmd, seed)
  clean = remove_command_arguments(cmd, '--seed', '--order')
  [*clean, '--seed', seed]
end

.default_test_folderObject



26
27
28
# File 'lib/parallel_tests/rspec/runner.rb', line 26

def default_test_folder
  "spec"
end

.determine_executableObject



12
13
14
15
16
17
18
19
20
# File 'lib/parallel_tests/rspec/runner.rb', line 12

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) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/parallel_tests/rspec/runner.rb', line 40

def line_is_result?(line)
  line =~ /\d+ examples?, \d+ failures?/
end

.run_tests(test_files, process_number, num_processes, options) ⇒ Object



8
9
10
# File 'lib/parallel_tests/rspec/runner.rb', line 8

def run_tests(test_files, process_number, num_processes, options)
  execute_command(build_command(test_files, options), process_number, num_processes, options)
end

.runtime_logObject



22
23
24
# File 'lib/parallel_tests/rspec/runner.rb', line 22

def runtime_log
  "tmp/parallel_runtime_rspec.log"
end

.summarize_results(results) ⇒ Object

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



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/parallel_tests/rspec/runner.rb', line 60

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_nameObject



30
31
32
# File 'lib/parallel_tests/rspec/runner.rb', line 30

def test_file_name
  "spec"
end

.test_suffixObject

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



36
37
38
# File 'lib/parallel_tests/rspec/runner.rb', line 36

def test_suffix
  /(_spec\.rb|\.feature)$/
end