class RSpec::Mocks::Constant

have been mutated by rspec-mocks.
Provides information about constants that may (or may not)

def self.original(name)

Returns:
  • (Constant) - an object containing information about the named

Parameters:
  • name (String) -- the name of the constant
def self.original(name)
  mutator = ::RSpec::Mocks.space.constant_mutator_for(name)
  mutator ? mutator.to_constant : unmutated(name)
end

def self.unmutated(name)

Other tags:
    Private: -
def self.unmutated(name)
  previously_defined = !!recursive_const_defined?(name)
rescue NameError
  new(name) do |c|
    c.valid_name = false
  end
else
  new(name) do |const|
    const.previously_defined = previously_defined
    const.original_value = recursive_const_get(name) if previously_defined
  end
end

def hidden?

Returns:
  • (Boolean) - Whether or not rspec-mocks has hidden
def hidden?
  @hidden
end

def initialize(name)

Other tags:
    Api: - private
def initialize(name)
  @name = name
  @previously_defined = false
  @stubbed = false
  @hidden = false
  @valid_name = true
  yield self if block_given?
end

def mutated?

Returns:
  • (Boolean) - Whether or not rspec-mocks has mutated
def mutated?
  @stubbed || @hidden
end

def previously_defined?

Returns:
  • (Boolean) - Whether or not the constant was defined
def previously_defined?
  @previously_defined
end

def stubbed?

Returns:
  • (Boolean) - Whether or not rspec-mocks has stubbed
def stubbed?
  @stubbed
end

def to_s

The default `to_s` isn't very useful, so a custom version is provided.
def to_s
  "#<#{self.class.name} #{name}>"
end

def valid_name?

Returns:
  • (Boolean) - Whether or not the provided constant name
def valid_name?
  @valid_name
end