Class: TestBoosters::Rspec::Thread

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(files_from_split_configuration, leftover_files) ⇒ Thread

Returns a new instance of Thread.



8
9
10
11
# File 'lib/test_boosters/rspec/thread.rb', line 8

def initialize(files_from_split_configuration, leftover_files)
  @files_from_split_configuration = files_from_split_configuration
  @leftover_files = leftover_files
end

Instance Attribute Details

#files_from_split_configurationObject (readonly)

Returns the value of attribute files_from_split_configuration.



5
6
7
# File 'lib/test_boosters/rspec/thread.rb', line 5

def files_from_split_configuration
  @files_from_split_configuration
end

#leftover_filesObject (readonly)

Returns the value of attribute leftover_files.



6
7
8
# File 'lib/test_boosters/rspec/thread.rb', line 6

def leftover_files
  @leftover_files
end

Instance Method Details

#all_filesObject



51
52
53
# File 'lib/test_boosters/rspec/thread.rb', line 51

def all_files
  @all_files ||= files_from_split_configuration + leftover_files
end

#display_thread_infoObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/test_boosters/rspec/thread.rb', line 30

def display_thread_info
  TestBoosters::Shell.display_files(
    "Known specs for this thread",
    files_from_split_configuration)

  TestBoosters::Shell.display_files(
    "Leftover specs for this thread",
    leftover_files)

  puts "RSpec options: #{rspec_options}"
end

#report_pathObject



63
64
65
# File 'lib/test_boosters/rspec/thread.rb', line 63

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

#rspec_commandObject



59
60
61
# File 'lib/test_boosters/rspec/thread.rb', line 59

def rspec_command
  "bundle exec rspec #{rspec_options} #{all_files.join(" ")}"
end

#rspec_optionsObject



55
56
57
# File 'lib/test_boosters/rspec/thread.rb', line 55

def rspec_options
  "#{ENV["TB_RSPEC_OPTIONS"]} --format documentation --format json --out #{report_path}"
end

#runObject

:reek:TooManyStatements { max_statements: 10 }



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/test_boosters/rspec/thread.rb', line 14

def run
  if all_files.empty?
    puts("No files to run in this thread!")

    return 0
  end

  display_thread_info

  exit_status = run_rspec

  upload_report

  exit_status
end

#run_rspecObject



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

def run_rspec
  TestBoosters::Shell.display_title("Running RSpec")
  TestBoosters::Shell.execute(rspec_command)
end

#upload_reportObject



47
48
49
# File 'lib/test_boosters/rspec/thread.rb', line 47

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