Class: RSpec::Core::Ordering::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/core/ordering.rb

Overview

Stores the different ordering strategies.

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Registry

Returns a new instance of Registry



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/rspec/core/ordering.rb', line 76

def initialize(configuration)
  @configuration = configuration
  @strategies    = {}

  register(:random,  Random.new(configuration))

  identity = Identity.new
  register(:defined, identity)

  # The default global ordering is --defined.
  register(:global, identity)
end

Instance Method Details

#fetch(name, &fallback) ⇒ Object



89
90
91
# File 'lib/rspec/core/ordering.rb', line 89

def fetch(name, &fallback)
  @strategies.fetch(name, &fallback)
end

#register(sym, strategy) ⇒ Object



93
94
95
# File 'lib/rspec/core/ordering.rb', line 93

def register(sym, strategy)
  @strategies[sym] = strategy
end

#used_random_seed?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/rspec/core/ordering.rb', line 97

def used_random_seed?
  @strategies[:random].used?
end