<commit_before>require 'helper'

describe Surveygizmo::Client do
  subject do
    Surveygizmo::Client.new(
      :username => "<EMAIL>",
      :password => "<PASSWORD>"
    )
  end

  context "with module configuration" do
    before do
      Surveygizmo.configure do |config|
        Surveygizmo::Configurable.keys.each do |key|
          config.send("#{key}=", key)
        end
      end
    end

    after do
      Surveygizmo.reset
    end

    it "inherits the module configuration" do
      client = Surveygizmo::Client.new
      Surveygizmo::Configurable.keys.each do |key|
        client.instance_variable_get(:"@#{key}").should eq key
      end
    end
  end

  describe "#credentials?" do
    it "returns true if all credentials are present" do
      client = Surveygizmo::Client.new(:username => "<EMAIL>", :password => "<PASSWORD>") 
      client.credentials?.should be_true
    end
    it "returns false if any credentials are missing" do
      client = Surveygizmo::Client.new(:username => "<EMAIL>")
      client.credentials?.should be_false
    end
  end

  describe "#auth_query_hash" do
    it "creates the correct auth query params" do
      authorization = subject.send(:auth_query_hash)
      authorization[:'user:md5'].should eq "<EMAIL>:39f8d5313141b1f2bade311ba571537e"
    end
  end
end
<commit_msg>Test attaching authorization query hash<commit_after>require 'helper'

describe Surveygizmo::Client do
  subject do
    Surveygizmo::Client.new(
      :username => "<EMAIL>",
      :password => "<PASSWORD>"
    )
  end

  context "with module configuration" do
    before do
      Surveygizmo.configure do |config|
        Surveygizmo::Configurable.keys.each do |key|
          config.send("#{key}=", key)
        end
      end
    end

    after do
      Surveygizmo.reset
    end

    it "inherits the module configuration" do
      client = Surveygizmo::Client.new
      Surveygizmo::Configurable.keys.each do |key|
        client.instance_variable_get(:"@#{key}").should eq key
      end
    end
  end

  describe "#credentials?" do
    it "returns true if all credentials are present" do
      client = Surveygizmo::Client.new(:username => "<EMAIL>", :password => "<PASSWORD>") 
      client.credentials?.should be_true
    end
    it "returns false if any credentials are missing" do
      client = Surveygizmo::Client.new(:username => "<EMAIL>")
      client.credentials?.should be_false
    end
  end

  describe "#auth_query_hash" do
    it "creates the correct auth query params" do
      authorization = subject.send(:auth_query_hash)
      authorization[:'user:md5'].should eq "<EMAIL>:39f8d5313141<PASSWORD>ade311ba571537e"
    end
  end

  context "authenticating requests" do
    subject do
      Surveygizmo::Client.new(:username => "<EMAIL>", :password => "<PASSWORD>")
    end
    before do
     authorization = subject.send(:auth_query_hash)
     stub_get("/v1/account").
       with(:query => authorization).
       to_return(:body => fixture("account.json"), :headers => {:content_type => "application/json; charset=utf-8"})
    end
    it "includes authorization in request query hash" do
      subject.account
      a_get("/v1/account").
        with(:query => {:'user:md5' => "<EMAIL>:39f8d5313141b1f2bade311ba571537e"}).
        should have_been_made
    end
  end
end

{'fraction_non_alphanumeric': 0.11452682338758288, 'fraction_numerical': 0.020192887281494876, 'mean_word_length': 3.0328068043742404, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 37, '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': '2246267', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1022, 'n_words': 260}