Method: CIRunner::Runners::RSpec#start!

Defined in:
lib/ci_runner/runners/rspec.rb

#start!Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ci_runner/runners/rspec.rb', line 26

def start!
  super

  flags = failures.map { |failure| "--example '#{failure.test_name}'" }.join(" ")
  flags << " --seed #{seed}" if seed

  code = <<~EOM
    require 'rspec/core/rake_task'

    RSpec::Core::RakeTask.new('__ci_runner_test') do |task|
      task.pattern = #{failures.map(&:path)}
      task.rspec_opts = "#{flags}"
      task.verbose = false
    end

    Rake::Task[:__ci_runner_test].invoke
  EOM

  dir = Dir.mktmpdir
  rakefile_path = File.expand_path("Rakefile", dir)

  File.write(rakefile_path, code)

  env = {}
  env["RUBY"] = ruby_path.to_s if ruby_path&.exist?
  env["BUNDLE_GEMFILE"] = gemfile_path.to_s if gemfile_path&.exist?

  execute_within_frame(env, "bundle exec ruby #{rakefile_path}")
end