module RSpec::Core::MemoizedHelpers
def self.define_helpers_on(example_group)
- 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)
- 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)
- 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.module_for(example_group)
- 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 __init_memoized
- Private: -
def __init_memoized @__memoized = if RSpec.configuration.threadsafe? ThreadsafeMemoized.new else NonThreadSafeMemoized.new end end
def initialize(*)
- Private: -
def initialize(*) __init_memoized super end
def is_expected
- Note: - This only works if you are using rspec-expectations.
Other tags:
- See: #should_not -
See: #should -
See: #subject -
def is_expected expect(subject) end
def should(matcher=nil, message=nil)
- Note: - If you are using RSpec's newer expect-based syntax you may
Note: - This only works if you are using rspec-expectations.
Other tags:
- See: #is_expected -
See: #subject -
def should(matcher=nil, message=nil) RSpec::Expectations::PositiveExpectationHandler.handle_matcher(subject, matcher, message) end
def should_not(matcher=nil, message=nil)
- Note: - If you are using RSpec's newer expect-based syntax you may
Note: - This only works if you are using rspec-expectations.
Other tags:
- See: #is_expected -
See: #subject -
def should_not(matcher=nil, message=nil) RSpec::Expectations::NegativeExpectationHandler.handle_matcher(subject, matcher, message) end
def subject
- See: #is_expected -
See: #should_not -
See: #should -
Other tags:
- Note: - Because `subject` is designed to create state that is reset
Note: - `subject` was contributed by Joe Ferris to support the one-liner
def subject __memoized.fetch_or_store(:subject) do described = described_class || self.class.metadata.fetch(:description_args).first Class === described ? described.new : described end end