<commit_before>require 'uri_config'

module URIConfig
  describe Config do
    subject { described_class.new(url) }

    {
      "https://TESTMERCHANT1:abcd1234abcd@secure.ap.tnspayments.com" => {
        username: 'TESTMERCHANT1',
        password: '<PASSWORD>',
        base_uri: 'https://secure.ap.tnspayments.com',
      },
      "https://foo:bar@us-west-2.amazonaws.com/namespace" => {
        username: "foo",
        password: "<PASSWORD>",
        path: "/namespace",
      },
      "https://AKIAJBPUOK67MOQ3VVXQ:<PASSWORD>@s3.amazonaws.com/bucket_name" => {
        username: "AKIAJBPUOK67MOQ3VVXQ",
        password: "<PASSWORD>",
        path: "/bucket_name",
      },
      "https://example.com:8080" => {
        host: "example.com",
        port: 8080,
      },
    }.each do |url, components|
      context "with a URL of #{url}" do
        let(:url) { url }

        components.each do |key, value|
          it "has a #{key} of #{value}" do
            expect(subject.send(key)).to eq value
          end
        end
      end
    end

    describe ".values_from" do
      context "when TEST_URL is not set" do
        specify do
          expect do
            URIConfig::Config.values_from("TEST_URL")
          end.to raise_error
        end
      end

      context "when TEST_URL is set" do
        before(:each) do
          ENV["TEST_URL"] = "https://user:pass@example.com/foo"
        end

        after(:each) do
          ENV["TEST_URL"] = nil
        end

        specify do
          expect(
            URIConfig::Config.values_from("TEST_URL", :username, :password)
          ).to eq(%w(user pass))
        end<commit_msg>Fix rubocop style issue<commit_after>require 'uri_config'

module URIConfig
  describe Config do
    subject { described_class.new(url) }

    {
      "https://TESTMERCHANT1:abcd1234abcd@secure.ap.tnspayments.com" => {
        username: 'TESTMERCHANT1',
        password: '<PASSWORD>',
        base_uri: 'https://secure.ap.tnspayments.com',
      },
      "https://foo:bar@us-west-2.amazonaws.com/namespace" => {
        username: "foo",
        password: "<PASSWORD>",
        path: "/namespace",
      },
      "https://AKIAJBPUOK67MOQ3VVXQ:<PASSWORD>@s3.amazonaws.com/bucket_name" => {
        username: "AKIAJBPUOK67MOQ3VVXQ",
        password: "<PASSWORD>",
        path: "/bucket_name",
      },
      "https://example.com:8080" => {
        host: "example.com",
        port: 8080,
      },
    }.each do |url, components|
      context "with a URL of #{url}" do
        let(:url) { url }

        components.each do |key, value|
          it "has a #{key} of #{value}" do
            expect(subject.send(key)).to eq value
          end
        end
      end
    end

    describe ".values_from" do
      context "when TEST_URL is not set" do
        specify do
          expect do
            URIConfig::Config.values_from("TEST_URL")
          end.to raise_error
        end
      end

      context "when TEST_URL is set" do
        before(:each) do
          ENV["TEST_URL"] = "https://user:pass@example.com/foo"
        end

        after(:each) do
          ENV["TEST_URL"] = nil
        end

        specify do
          expect(
            URIConfig::Config.values_from("TEST_URL", :username, :password),
          ).to eq(%w(user pass))
        end
{'fraction_non_alphanumeric': 0.13355441664154355, 'fraction_numerical': 0.013264998492613807, 'mean_word_length': 1.9003496503496504, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '3582061', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1041, 'n_words': 224}