class RSpec::Core::MemoizedHelpers::AllHookMemoizedHash
@private
memoized hash when used in a ‘before(:all)` hook.
Used internally to customize the behavior of the
def self.isolate_for_all_hook(example_group_instance)
def self.isolate_for_all_hook(example_group_instance) hash_type = self example_group_instance.instance_eval do @__memoized = hash_type.new(example_group_instance) begin yield ensure @__memoized.preserve_accessed_lets @__memoized = nil end end end
def []=(key, value)
def []=(key, value) @hash[key] = value end
def fetch(key, &block)
def fetch(key, &block) description = if key == :subject "subject" else "let declaration `#{key}`" end ::RSpec.warn_deprecation <<-EOS ION: #{description} accessed in #{article} #{hook_expression} hook at: erFilter.first_non_rspec_line} d `subject` declarations are not intended to be called icle} #{hook_expression} hook, as they exist to define state that between each example, while #{hook_expression} exists to ntention}. deprecated behavior that will not be supported in RSpec 3. @hash.fetch(key, &block) end
def initialize(example_group_instance)
def initialize(example_group_instance) @example_group_instance = example_group_instance @hash = {} end
def preserve_accessed_lets
def preserve_accessed_lets hash = @hash @example_group_instance.class.class_eval do hash.each do |key, value| undef_method(key) if method_defined?(key) define_method(key) { value } end end end