module RSpec::Core::MemoizedHelpers
def self.define_helpers_on(example_group)
- Api: - private
def self.define_helpers_on(example_group) example_group.send(:include, module_for(example_group)) end
def self.get_constant_or_yield(example_group, name)
- Api: - private
def self.get_constant_or_yield(example_group, name) if example_group.const_defined?(name) example_group.const_get(name) else yield end end
def self.get_constant_or_yield(example_group, name)
- Api: - private
def self.get_constant_or_yield(example_group, name) if example_group.const_defined?(name, (check_ancestors = false)) example_group.const_get(name, check_ancestors) else yield end end
def self.included(mod)
def self.included(mod) mod.extend(ClassMethods) end
def self.module_for(example_group)
- Api: - private
def self.module_for(example_group) get_constant_or_yield(example_group, :LetDefinitions) do mod = Module.new do include Module.new { example_group.const_set(:NamedSubjectPreventSuper, self) } end example_group.const_set(:LetDefinitions, mod) mod end end
def __memoized
- Private: -
def __memoized @__memoized ||= {} end
def should(matcher=nil, message=nil)
- See: #subject -
def should(matcher=nil, message=nil) RSpec::Expectations::PositiveExpectationHandler.handle_matcher(subject, matcher, message) end
def should_not(matcher=nil, message=nil)
- See: #subject -
def should_not(matcher=nil, message=nil) RSpec::Expectations::NegativeExpectationHandler.handle_matcher(subject, matcher, message) end
def subject
- See: #should -
Other tags:
- Note: - Because `subject` is designed to create state that is reset between
Note: - `subject` was contributed by Joe Ferris to support the one-liner
def subject __memoized.fetch(:subject) do __memoized[:subject] = begin described = described_class || self.class.description Class === described ? described.new : described end end end