class RSpec::Core::MemoizedHelpers::ContextHookMemoizedHash

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

@private

Public Class Methods

fetch(key, &_block) click to toggle source
# File lib/rspec/core/memoized_helpers.rb, line 148
        def self.fetch(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
isolate_for_context_hook(example_group_instance) { || ... } click to toggle source
# File lib/rspec/core/memoized_helpers.rb, line 134
def self.isolate_for_context_hook(example_group_instance)
  hash = self

  example_group_instance.instance_exec do
    @__memoized = hash

    begin
      yield
    ensure
      @__memoized = nil
    end
  end
end