module RSpec::Support::RecursiveConstMethods
def const_defined_on?(mod, const_name)
def const_defined_on?(mod, const_name) mod.const_defined?(const_name) end
def const_defined_on?(mod, const_name)
def const_defined_on?(mod, const_name) mod.const_defined?(const_name, false) end
def constants_defined_on(mod)
def constants_defined_on(mod) mod.constants.select { |c| const_defined_on?(mod, c) } end
def constants_defined_on(mod)
def constants_defined_on(mod) mod.constants(false) end
def get_const_defined_on(mod, const_name)
def get_const_defined_on(mod, const_name) return mod.const_get(const_name) if const_defined_on?(mod, const_name) raise NameError, "uninitialized constant #{mod.name}::#{const_name}" end
def get_const_defined_on(mod, const_name)
def get_const_defined_on(mod, const_name) mod.const_get(const_name, false) end
def normalize_const_name(const_name)
def normalize_const_name(const_name) const_name.sub(/\A::/, '') end
def recursive_const_defined?(const_name)
def recursive_const_defined?(const_name) parts = normalize_const_name(const_name).split('::') parts.inject([Object, '']) do |(mod, full_name), name| yield(full_name, name) if block_given? && !(Module === mod) return false unless const_defined_on?(mod, name) [get_const_defined_on(mod, name), [mod.name, name].join('::')] end end
def recursive_const_get(const_name)
def recursive_const_get(const_name) normalize_const_name(const_name).split('::').inject(Object) do |mod, name| get_const_defined_on(mod, name) end end