Class: TestBoosters::Boosters::Rspec

Inherits:
Base
  • Object
show all
Defined in:
lib/test_boosters/boosters/rspec.rb

Constant Summary collapse

FILE_PATTERN =
"spec/**/*_spec.rb".freeze

Instance Method Summary collapse

Methods inherited from Base

#before_job, #distribution, #job_count, #job_index, #run

Constructor Details

#initializeRspec

Returns a new instance of Rspec.



7
8
9
# File 'lib/test_boosters/boosters/rspec.rb', line 7

def initialize
  super(FILE_PATTERN, split_configuration_path, command)
end

Instance Method Details

#after_jobObject



19
20
21
# File 'lib/test_boosters/boosters/rspec.rb', line 19

def after_job
  TestBoosters::InsightsUploader.upload("rspec", report_path)
end

#commandObject



23
24
25
# File 'lib/test_boosters/boosters/rspec.rb', line 23

def command
  @command ||= "bundle exec rspec #{rspec_options}"
end

#display_headerObject



11
12
13
14
15
16
17
# File 'lib/test_boosters/boosters/rspec.rb', line 11

def display_header
  super

  TestBoosters::ProjectInfo.display_ruby_version
  TestBoosters::ProjectInfo.display_bundler_version
  TestBoosters::ProjectInfo.display_rspec_version
end

#formatter_pathObject



43
44
45
# File 'lib/test_boosters/boosters/rspec.rb', line 43

def formatter_path
  @formatter_path ||= File.join(::TestBoosters::ROOT_PATH, "rspec_formatters/semaphore_rspec3_json_formatter.rb")
end

#report_pathObject



35
36
37
# File 'lib/test_boosters/boosters/rspec.rb', line 35

def report_path
  @report_path ||= ENV["REPORT_PATH"] || "#{ENV["HOME"]}/rspec_report.json"
end

#rspec_optionsObject



27
28
29
30
31
32
33
# File 'lib/test_boosters/boosters/rspec.rb', line 27

def rspec_options
  @rspec_options ||= begin
    output_formatter = ENV.fetch("TB_RSPEC_FORMATTER", "documentation")
    # rubocop:disable LineLength
    "#{ENV["TB_RSPEC_OPTIONS"]} --format #{output_formatter} --require #{formatter_path} --format SemaphoreFormatter --out #{report_path}"
  end
end

#split_configuration_pathObject



39
40
41
# File 'lib/test_boosters/boosters/rspec.rb', line 39

def split_configuration_path
  ENV["RSPEC_SPLIT_CONFIGURATION_PATH"] || "#{ENV["HOME"]}/rspec_split_configuration.json"
end