<commit_before>require "spec_helper"

require "ailurus/client"

describe Ailurus::Client do
  context "initializes properly" do
    it "accepts config arguments" do
      client = Ailurus::Client.new(
        :api_key => "api key",
        :domain => "domain name",
        :email => "email address"
      )

      expect(client.api_key).to eq("api key")
      expect(client.domain).to eq("domain name")
      expect(client.email).to eq("email address")
    end

    it "accepts environment variables" do
      ClimateControl.modify PANDA_API_KEY: "api key", PANDA_DOMAIN: "domain name", PANDA_EMAIL: "email address" do
        client = Ailurus::Client.new

        expect(client.api_key).to eq("api key")
        expect(client.domain).to eq("domain name")
        expect(client.email).to eq("email address")
      end
    end
  end

  it "adds authentication parameters to requests" do
    stub_request(:any, /panda\.example\.com/).to_return(:body => "{}")

    client = Ailurus::Client.new(
      :api_key => "API_KEY_HERE",
      :domain => "panda.example.com",
      :email => "<EMAIL>"
    )
    client.make_request("/")

    expected_url = "http://panda.example.com/"
    expect_url(expected_url, :get, {
      "format" => "json",
      "email" => "<EMAIL>",
      "api_key" => "API_KEY_HERE"
    })
  end
end<commit_msg>Test Client requests with other methods<commit_after>require "spec_helper"

require "ailurus/client"

describe Ailurus::Client do
  context "initializes properly" do
    it "accepts config arguments" do
      client = Ailurus::Client.new(
        :api_key => "api key",
        :domain => "domain name",
        :email => "email address"
      )

      expect(client.api_key).to eq("api key")
      expect(client.domain).to eq("domain name")
      expect(client.email).to eq("email address")
    end

    it "accepts environment variables" do
      ClimateControl.modify PANDA_API_KEY: "api key", PANDA_DOMAIN: "domain name", PANDA_EMAIL: "email address" do
        client = Ailurus::Client.new

        expect(client.api_key).to eq("api key")
        expect(client.domain).to eq("domain name")
        expect(client.email).to eq("email address")
      end
    end
  end

  context "adds authentication parameters to requests" do
    before(:each) do
      stub_request(:any, /panda\.example\.com/).to_return(:body => "{}")

      @client = Ailurus::Client.new(
        :api_key => "API_KEY_HERE",
        :domain => "panda.example.com",
        :email => "<EMAIL>"
      )
      @url = "http://panda.example.com/"
    end

    it "GET" do
      @client.make_request("/")
      expect_url(@url, :get, {
        "format" => "json",
        "email" => "<EMAIL>",
        "api_key" => "API_KEY_HERE"
      })
    end

    it "POST" do
      @client.make_request("/", {}, :post)
      expect_url(@url, :post, {
        "format" => "json",
        "email" => "<EMAIL>",
        "api_key" => "API_KEY_HERE"
      })
    end
  end
end
{'fraction_non_alphanumeric': 0.15064319566689235, 'fraction_numerical': 0.0, 'mean_word_length': 2.6391625615763545, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 31, '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': '1976735', 'n_tokens_mistral': 985, 'n_tokens_neox': 956, 'n_words': 219}