<commit_before>require "spec_helper"
require "delegate"

describe "Stubbing/mocking methods in before(:all) blocks" do
  old_rspec = nil

  shared_examples_for "A stub/mock in a before(:all) block" do |message_expectation_block|
    the_error = nil
    before(:all) do
      begin
        use_rspec_mocks
      rescue
        the_error = $!
      end
    end

    it "raises an error with a useful message" do
      expect(the_error).to be_a_kind_of(RSpec::Mocks::OutsideOfExampleError)

      expect(the_error.message).to match(/The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported./)
    end
  end

  describe "#stub" do
    it_behaves_like "A stub/mock in a before(:all) block" do
      def use_rspec_mocks
        Object.stub(:foo)
      end
    end
  end<commit_msg>Fix a warning introduced with some orderings on the before(:all) specs<commit_after>require "spec_helper"
require "delegate"

describe "Stubbing/mocking methods in before(:all) blocks" do
  old_rspec = nil

  shared_examples_for "A stub/mock in a before(:all) block" do
    the_error = nil
    before(:all) do
      begin
        use_rspec_mocks
      rescue
        the_error = $!
      end
    end

    it "raises an error with a useful message" do
      expect(the_error).to be_a_kind_of(RSpec::Mocks::OutsideOfExampleError)

      expect(the_error.message).to match(/The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported./)
    end
  end

  describe "#stub" do
    it_behaves_like "A stub/mock in a before(:all) block" do
      def use_rspec_mocks
        Object.stub(:foo)
      end
    end
  end
{'fraction_non_alphanumeric': 0.07692307692307693, 'fraction_numerical': 0.0, 'mean_word_length': 3.014354066985646, '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': '6880849', 'n_tokens_mistral': 548, 'n_tokens_neox': 534, 'n_words': 168}