class RSpec::Mocks::ConstantStubber::BaseStubber

Contains common functionality used by both of the constant stubbers.

@api private

Attributes

full_constant_name[R]
original_value[R]

Public Class Methods

new(full_constant_name, stubbed_value, transfer_nested_constants) click to toggle source
# File lib/rspec/mocks/stub_const.rb, line 170
def initialize(full_constant_name, stubbed_value, transfer_nested_constants)
  @full_constant_name        = full_constant_name
  @stubbed_value             = stubbed_value
  @transfer_nested_constants = transfer_nested_constants
  @context_parts             = @full_constant_name.split('::')
  @const_name                = @context_parts.pop
end

Public Instance Methods

to_constant() click to toggle source
# File lib/rspec/mocks/stub_const.rb, line 178
def to_constant
  const = Constant.new(full_constant_name)
  const.stubbed = true
  const.previously_defined = previously_defined?
  const.original_value = original_value

  const
end