Class: CIRunner::Runners::RSpec
- 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
-
.match?(log) ⇒ Boolean
Whether this runner detects (and therefore can handle) Minitest from the log output.
Instance Method Summary collapse
-
#name ⇒ String
See Runners::Base#report.
- #start! ⇒ Object
Methods inherited from Base
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.
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
#name ⇒ String
Returns 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 = <<~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.("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 |