<commit_before>Feature: before and after hooks

  Use `before` and `after` hooks to execute arbitrary code before and/or
  after the body of an example is run:

      before(:each) # run before each example
      before(:all)  # run one time only, before all of the examples in a group

      after(:each) # run after each example
      after(:all)  # run one time only, after all of the examples in a group

  Before and after blocks are called in the following order:

      before suite
      before all
      before each
      after  each
      after  all
      after  suite

  `before` and `after` hooks can be defined directly in the example groups they
  should run in, or in a global RSpec.configure block.

  Scenario: define before(:each) block
    Given a file named "before_each_spec.rb" with:
      """
      require "rspec/expectations"

      class Thing
        def widgets
          @widgets ||= []
        end
      end

      describe Thing do
        before(:each) do
          @thing = Thing.new
        end

        describe "initialized in before(:each)" do
          it "has 0 widgets" do
            @thing.should have(0).widgets<commit_msg>Adds information about instance variables and mocks in hooks<commit_after>Feature: before and after hooks

  Use `before` and `after` hooks to execute arbitrary code before and/or
  after the body of an example is run:

      before(:each) # run before each example
      before(:all)  # run one time only, before all of the examples in a group

      after(:each) # run after each example
      after(:all)  # run one time only, after all of the examples in a group

  Before and after blocks are called in the following order:

      before suite
      before all
      before each
      after  each
      after  all
      after  suite

  `before` and `after` hooks can be defined directly in the example groups they
  should run in, or in a global RSpec.configure block.

  Setting instance variables are not supported in `before(:suite)`.

  Mocks are only supported in `before(:each)`.

  Scenario: define before(:each) block
    Given a file named "before_each_spec.rb" with:
      """
      require "rspec/expectations"

      class Thing
        def widgets
          @widgets ||= []
        end
      end

      describe Thing do
        before(:each) do
          @thing = Thing.new
        end

        describe "initialized in before(:each)" do
          it "has 0 widgets" do
            @thing.should have(0).widgets
{'fraction_non_alphanumeric': 0.0641025641025641, 'fraction_numerical': 0.0016025641025641025, 'mean_word_length': 2.316069057104914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6977763', 'n_tokens_mistral': 676, 'n_tokens_neox': 643, 'n_words': 307}