Class: RSpec::Multicore::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/multicore/configuration.rb

Overview

Resolves the worker count from the Ruby API and RSPEC_MULTICORE.

Constant Summary collapse

ENABLED_VALUES =
%w[true on auto].freeze
DISABLED_VALUES =
%w[0 false off].freeze

Instance Method Summary collapse

Instance Method Details

#workersObject



13
14
15
16
17
18
19
20
# File 'lib/rspec/multicore/configuration.rb', line 13

def workers
  setting = env_value
  case setting
  when :disabled then 0
  when Integer then setting
  else @workers || Etc.nprocessors
  end
end

#workers=(value) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/rspec/multicore/configuration.rb', line 22

def workers=(value)
  unless value.nil? || (value.is_a?(Integer) && value.positive?)
    raise ArgumentError, "workers must be a positive integer or nil"
  end

  @workers = value
end