# File lib/rspec/mocks/stub_const.rb, line 134
      def self.stub(constant_name, value, options = {})
        stubber = if recursive_const_defined?(constant_name, &raise_on_invalid_const)
          DefinedConstantReplacer
        else
          UndefinedConstantSetter
        end

        stubber = stubber.new(constant_name, value, options[:transfer_nested_constants])
        stubbers << stubber

        stubber.stub
        ensure_registered_with_mocks_space
        value
      end