<commit_before>shared_examples_for "an http stubbing adapter" do |supported_http_libraries, supported_request_match_attributes, *other|
  extend HttpLibrarySpecs
  before(:each) { VCR.stub!(:http_stubbing_adapter).and_return(subject) }
  subject { described_class }

  if other.include?(:needs_net_http_extension)
    describe '#request_uri' do
      it 'returns the uri for the given http request' do
        net_http = Net::HTTP.new('example.com', 80)
        request = Net::HTTP::Get.new('/foo/bar')
        subject.request_uri(net_http, request).should == 'http://example.com:80/foo/bar'
      end

      it 'handles basic auth' do
        net_http = Net::HTTP.new('example.com',80)
        request = Net::HTTP::Get.new('/auth.txt')
        request.basic_auth 'user', 'pass'
        subject.request_uri(net_http, request).should == 'http://user:pass@example.com:80/auth.txt'
      end
    end
  end

  describe '.ignore_localhost?' do
    [true, false].each do |val|
      it "returns #{val} when ignore_localhost is set to #{val}" do
        subject.ignore_localhost = val
        subject.ignore_localhost?.should == val
      end
    end

    it "returns false when ignore_localhost is set to nil" do
      subject.ignore_localhost = nil
      subject.ignore_localhost?.should == false
    end
  end

  if other.include?(:needs_net_http_extension)
    describe '#request_stubbed? using specific match_attributes' do
      let(:interactions) { YAML.load(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', YAML_SERIALIZATION_VERSION, 'match_requests_on.yml'))) }

      @supported_request_match_attributes = supported_request_match_attributes
      def self.matching_on(attribute, valid1, valid2, invalid, &block)
        supported_request_match_attributes = @supported_request_match_attributes

        describe ":#{attribute}" do
          if supported_request_match_attributes.include?(attribute)
            before(:each) { subject.stub_requests(interactions, [attribute]) }
            module_eval(&block)<commit_msg>Reorganize some specs.<commit_after>shared_examples_for "an http stubbing adapter" do |supported_http_libraries, supported_request_match_attributes, *other|
  extend HttpLibrarySpecs
  before(:each) { VCR.stub!(:http_stubbing_adapter).and_return(subject) }
  subject { described_class }

  describe '.ignore_localhost?' do
    [true, false].each do |val|
      it "returns #{val} when ignore_localhost is set to #{val}" do
        subject.ignore_localhost = val
        subject.ignore_localhost?.should == val
      end
    end

    it "returns false when ignore_localhost is set to nil" do
      subject.ignore_localhost = nil
      subject.ignore_localhost?.should == false
    end
  end

  if other.include?(:needs_net_http_extension)
    describe '#request_uri' do
      it 'returns the uri for the given http request' do
        net_http = Net::HTTP.new('example.com', 80)
        request = Net::HTTP::Get.new('/foo/bar')
        subject.request_uri(net_http, request).should == 'http://example.com:80/foo/bar'
      end

      it 'handles basic auth' do
        net_http = Net::HTTP.new('example.com',80)
        request = Net::HTTP::Get.new('/auth.txt')
        request.basic_auth 'user', 'pass'
        subject.request_uri(net_http, request).should == 'http://user:pass@example.com:80/auth.txt'
      end
    end

    describe '#request_stubbed? using specific match_attributes' do
      let(:interactions) { YAML.load(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', YAML_SERIALIZATION_VERSION, 'match_requests_on.yml'))) }

      @supported_request_match_attributes = supported_request_match_attributes
      def self.matching_on(attribute, valid1, valid2, invalid, &block)
        supported_request_match_attributes = @supported_request_match_attributes

        describe ":#{attribute}" do
          if supported_request_match_attributes.include?(attribute)
            before(:each) { subject.stub_requests(interactions, [attribute]) }
            module_eval(&block)
{'fraction_non_alphanumeric': 0.11315136476426799, 'fraction_numerical': 0.004962779156327543, 'mean_word_length': 3.665509259259259, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1771194', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1178, 'n_words': 254}