Class: CIRunner::Runners::RSpec

Inherits:
Base
  • Object
show all
Defined in:
lib/ci_runner/runners/rspec.rb

Constant Summary collapse

SEED_REGEX =
/Randomized with seed[[:blank:]]*(\d+)/
BUFFER_STARTS =
/(Finished in|Failed examples)/

Instance Attribute Summary

Attributes inherited from Base

#failures, #gemfile, #ruby_version, #seed

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #parse!, #report

Constructor Details

This class inherits a constructor from CIRunner::Runners::Base

Class Method Details

.match?(log) ⇒ Boolean

Returns Whether this runner detects (and therefore can handle) Minitest from the log output.

Parameters:

  • ci_log (String)

    The CI log output

Returns:

  • (Boolean)

    Whether this runner detects (and therefore can handle) Minitest from the log output.



14
15
16
17
18
19
# File 'lib/ci_runner/runners/rspec.rb', line 14

def self.match?(log)
  command = /bundle exec rspec/
  summary = /Failed examples:/

  Regexp.union(command, summary).match?(log)
end

Instance Method Details

#nameString

Returns See Runners::Base#report.

Returns:

  • (String)

    See Runners::Base#report



22
23
24
# File 'lib/ci_runner/runners/rspec.rb', line 22

def name
  "RSpec"
end

#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 = "    require 'rspec/core/rake_task'\n\n    RSpec::Core::RakeTask.new('__ci_runner_test') do |task|\n      task.pattern = \#{failures.map(&:path)}\n      task.rspec_opts = \"\#{flags}\"\n      task.verbose = false\n    end\n\n    Rake::Task[:__ci_runner_test].invoke\n  EOM\n\n  dir = Dir.mktmpdir\n  rakefile_path = File.expand_path(\"Rakefile\", dir)\n\n  File.write(rakefile_path, code)\n\n  env = {}\n  env[\"RUBY\"] = ruby_path.to_s if ruby_path&.exist?\n  env[\"BUNDLE_GEMFILE\"] = gemfile_path.to_s if gemfile_path&.exist?\n\n  execute_within_frame(env, \"bundle exec ruby \#{rakefile_path}\")\nend\n"