class RSpec::Core::MemoizedHelpers::ContextHookMemoized

Used internally to customize the behavior of the memoized hash when used in a ‘before(:context)` hook.

@private

Public Class Methods

# File rspec-core/lib/rspec/core/memoized_helpers.rb, line 222
        def self.fetch_or_store(key, &_block)
          description = if key == :subject
                          "subject"
                        else
                          "let declaration `#{key}`"
                        end

          raise <<-EOS
#{description} accessed in #{article} #{hook_expression} hook at:
  #{CallerFilter.first_non_rspec_line}

`let` and `subject` declarations are not intended to be called
in #{article} #{hook_expression} hook, as they exist to define state that
is reset between each example, while #{hook_expression} exists to
#{hook_intention}.
EOS
        end
# File rspec-core/lib/rspec/core/memoized_helpers.rb, line 201
def self.isolate_for_context_hook(example_group_instance)
  exploding_memoized = self

  example_group_instance.instance_exec do
    @__memoized = exploding_memoized

    begin
      yield
    ensure
      # This is doing a reset instead of just isolating for context hook.
      # Really, this should set the old @__memoized back into place.
      #
      # Caller is the before and after context hooks
      # which are both called from self.run
      # I didn't look at why it made tests fail, maybe an object was getting reused in RSpec tests,
      # if so, then that probably already works, and its the tests that are wrong.
      __init_memoized
    end
  end
end