123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Core::Ordering::ConfigurationManager Private

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: rspec-core/lib/rspec/core/ordering.rb

Overview

Note:

This is not intended to be used externally. Use the APIs provided by ::RSpec::Core::Configuration instead.

Manages ordering configuration.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#order=(type) (writeonly)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/ordering.rb', line 164

def order=(type)
  order, seed = type.to_s.split(':')
  @seed = seed.to_i if seed

  ordering_name = if order.include?('rand')
                    :random
                  elsif order == 'defined'
                    :defined
                  elsif order == 'recently-modified'
                    :recently_modified
                  else
                    order.to_sym
                  end

  if ordering_name
    strategy =
      if ordering_registry.has_strategy?(ordering_name)
        ordering_registry.fetch(ordering_name)
      else
        Delayed.new(ordering_registry, ordering_name)
      end

    register_ordering(:global, strategy)
  end
end

#ordering_registry (readonly)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/ordering.rb', line 145

attr_reader :seed, :ordering_registry

#seed (rw)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/ordering.rb', line 145

attr_reader :seed, :ordering_registry

#seed=(seed) (rw)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/ordering.rb', line 158

def seed=(seed)
  return if @seed_forced
  register_ordering(:global, ordering_registry.fetch(:random))
  @seed = seed.to_i
end

#seed_used?Boolean (readonly)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/ordering.rb', line 154

def seed_used?
  ordering_registry.used_random_seed?
end

Instance Method Details

#force(hash)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/ordering.rb', line 190

def force(hash)
  if hash.key?(:seed)
    self.seed = hash[:seed]
    @seed_forced  = true
    @order_forced = true
  elsif hash.key?(:order)
    self.order = hash[:order]
    @order_forced = true
  end
end

#register_ordering(name, strategy = Custom.new(Proc.new { |l| yield l }))

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/ordering.rb', line 201

def register_ordering(name, strategy=Custom.new(Proc.new { |l| yield l }))
  return if @order_forced && name == :global
  ordering_registry.register(name, strategy)
end