Class: TestBoosters::Boosters::Rspec

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

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

#initializeRspec

Returns a new instance of Rspec.



4
5
6
# File 'lib/test_boosters/boosters/rspec.rb', line 4

def initialize
  super(file_pattern, exclude_pattern, split_configuration_path, command)
end

Instance Method Details

#after_jobObject



16
17
18
# File 'lib/test_boosters/boosters/rspec.rb', line 16

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

#commandObject



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

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

#display_headerObject



8
9
10
11
12
13
14
# File 'lib/test_boosters/boosters/rspec.rb', line 8

def display_header
  super

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

#exclude_patternObject



48
49
50
# File 'lib/test_boosters/boosters/rspec.rb', line 48

def exclude_pattern
  ENV["TEST_BOOSTERS_RSPEC_TEST_EXCLUDE_PATTERN"]
end

#file_patternObject



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

def file_pattern
  ENV["TEST_BOOSTERS_RSPEC_TEST_FILE_PATTERN"] || "spec/**/*_spec.rb"
end

#formatter_pathObject



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

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

#report_pathObject



32
33
34
# File 'lib/test_boosters/boosters/rspec.rb', line 32

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

#rspec_optionsObject



24
25
26
27
28
29
30
# File 'lib/test_boosters/boosters/rspec.rb', line 24

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



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

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