Class: RSpec::Mocks::Constant

### Home Classes Methods

### In Files

- lib/rspec/mocks/mutate_const.rb

### Parent

Object

### Methods

- ::new
- ::original
- #hidden?
- #inspect
- #mutated?
- #previously_defined?
- #stubbed?
- #to_s

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Mocks
- RSpec::Mocks::AllowanceTarget
- RSpec::Mocks::AmbiguousReturnError
- RSpec::Mocks::AndCallOriginalImplementation
- RSpec::Mocks::AndReturnImplementation
- RSpec::Mocks::AndYieldImplementation
- RSpec::Mocks::AnyInstance
- RSpec::Mocks::AnyInstance::Chain
- RSpec::Mocks::AnyInstance::Chain::Customizations
- RSpec::Mocks::AnyInstance::ExpectationChain
- RSpec::Mocks::AnyInstance::MessageChains
- RSpec::Mocks::AnyInstance::PositiveExpectationChain
- RSpec::Mocks::AnyInstance::Recorder
- RSpec::Mocks::AnyInstance::StubChain
- RSpec::Mocks::AnyInstance::StubChainChain
- RSpec::Mocks::AnyInstanceAllowanceTarget
- RSpec::Mocks::AnyInstanceExpectationTarget
- RSpec::Mocks::ArgumentListMatcher
- RSpec::Mocks::ArgumentMatchers
- RSpec::Mocks::ArgumentMatchers::AnyArgMatcher
- RSpec::Mocks::ArgumentMatchers::AnyArgsMatcher
- RSpec::Mocks::ArgumentMatchers::BooleanMatcher
- RSpec::Mocks::ArgumentMatchers::DuckTypeMatcher
- RSpec::Mocks::ArgumentMatchers::EqualityProxy
- RSpec::Mocks::ArgumentMatchers::HashExcludingMatcher
- RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher
- RSpec::Mocks::ArgumentMatchers::InstanceOf
- RSpec::Mocks::ArgumentMatchers::KindOf
- RSpec::Mocks::ArgumentMatchers::MatcherMatcher
- RSpec::Mocks::ArgumentMatchers::NoArgsMatcher
- RSpec::Mocks::ArgumentMatchers::RegexpMatcher
- RSpec::Mocks::Configuration
- RSpec::Mocks::Constant
- RSpec::Mocks::ConstantMutator
- RSpec::Mocks::ConstantMutator::BaseMutator
- RSpec::Mocks::ConstantMutator::ConstantHider
- RSpec::Mocks::ConstantMutator::DefinedConstantReplacer
- RSpec::Mocks::ConstantMutator::UndefinedConstantSetter
- RSpec::Mocks::ConstantStubber
- RSpec::Mocks::Deprecation
- RSpec::Mocks::ErrorGenerator
- RSpec::Mocks::ExampleMethods
- RSpec::Mocks::ExampleMethods::ExpectHost
- RSpec::Mocks::ExpectationTarget
- RSpec::Mocks::Implementation
- RSpec::Mocks::InstanceExec
- RSpec::Mocks::InstanceMethodStasher
- RSpec::Mocks::Matchers
- RSpec::Mocks::Matchers::HaveReceived
- RSpec::Mocks::Matchers::Receive
- RSpec::Mocks::Matchers::Receive::Customization
- RSpec::Mocks::MessageExpectation
- RSpec::Mocks::MethodDouble
- RSpec::Mocks::MethodDouble::ProcWithBlock
- RSpec::Mocks::Mock
- RSpec::Mocks::MockExpectationError
- RSpec::Mocks::OrderGroup
- RSpec::Mocks::Proxy
- RSpec::Mocks::ProxyForNil
- RSpec::Mocks::RecursiveConstMethods
- RSpec::Mocks::Space
- RSpec::Mocks::StubChain
- RSpec::Mocks::Syntax
- RSpec::Mocks::TargetBase
- RSpec::Mocks::TestDouble
- RSpec::Mocks::Version
- Marshal

No matching classes.

# RSpec::Mocks::Constant

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

### Attributes

hidden[W]

@api private

name[R]

@return [String] The fully qualified name of the constant.

original_value[RW]

@return [Object, nil] The original value (e.g. before it

    was mutated by rspec-mocks) of the constant, or
    nil if the constant was not previously defined.

previously_defined[W]

@api private

stubbed[W]

@api private

### Public Class Methods

new(name) click to toggle source

@api private

    # File lib/rspec/mocks/mutate_const.rb, line 84
    def initialize(name)
      @name = name
      @previously_defined = false
      @stubbed = false
      @hidden = false
    end

original(name) click to toggle source

Queries rspec-mocks to find out information about the named constant.

@param [String] name the name of the constant @return [Constant] an object contaning information about the named

    constant.

    # File lib/rspec/mocks/mutate_const.rb, line 148
    def self.original(name)
      mutator = ConstantMutator.find(name)
      mutator ? mutator.to_constant : unmutated(name)
    end

### Public Instance Methods

hidden?() click to toggle source

@return [Boolean] Whether or not rspec-mocks has hidden

    this constant.

    # File lib/rspec/mocks/mutate_const.rb, line 122
    def hidden?
      @hidden
    end

inspect() click to toggle source
Alias for: to_s
mutated?() click to toggle source

@return [Boolean] Whether or not rspec-mocks has mutated

    (stubbed or hidden) this constant.

    # File lib/rspec/mocks/mutate_const.rb, line 110
    def mutated?
      @stubbed || @hidden
    end

previously_defined?() click to toggle source

@return [Boolean] Whether or not the constant was defined

    before the current example.

    # File lib/rspec/mocks/mutate_const.rb, line 104
    def previously_defined?
      @previously_defined
    end

stubbed?() click to toggle source

@return [Boolean] Whether or not rspec-mocks has stubbed

    this constant.

    # File lib/rspec/mocks/mutate_const.rb, line 116
    def stubbed?
      @stubbed
    end

to_s() click to toggle source

    # File lib/rspec/mocks/mutate_const.rb, line 126
    def to_s
      "#<#{self.class.name} #{name}>"
    end

Also aliased as: inspect

[Validate]

Generated with the Darkfish Rdoc Generator 2.