Class: Flatware::RSpec::JobBuilder

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/flatware/rspec/job_builder.rb

Overview

groups spec files into one job per worker. reads from persisted example statuses, if available, and attempts to ballence the jobs accordingly.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, workers:) ⇒ JobBuilder

Returns a new instance of JobBuilder.



20
21
22
23
24
25
26
27
28
# File 'lib/flatware/rspec/job_builder.rb', line 20

def initialize(args, workers:)
  @args = args
  @workers = workers

  @configuration = ::RSpec.configuration
  configuration.define_singleton_method(:command) { 'rspec' }

  ::RSpec::Core::ConfigurationOptions.new(args).configure(@configuration)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



12
13
14
# File 'lib/flatware/rspec/job_builder.rb', line 12

def args
  @args
end

#configurationObject (readonly)

Returns the value of attribute configuration.



12
13
14
# File 'lib/flatware/rspec/job_builder.rb', line 12

def configuration
  @configuration
end

#workersObject (readonly)

Returns the value of attribute workers.



12
13
14
# File 'lib/flatware/rspec/job_builder.rb', line 12

def workers
  @workers
end

Instance Method Details

#jobsObject



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

def jobs
  timed_files, untimed_files = timed_and_untimed_files(
    sum_seconds(load_persisted_example_statuses)
  )

  balance_jobs(
    bucket_count: [files_to_run.size, workers].min,
    timed_files: timed_files,
    untimed_files: untimed_files
  )
end