<commit_before>require File.expand_path("./base", File.dirname(__FILE__))
require "cgi"
require "heroku/client"

describe Heroku::Client do
  before do
    @client = Heroku::Client.new(nil, nil)
    @resource = mock('heroku rest resource')
    @client.stub!(:extract_warning)
  end

  it "list -> get a list of this user's apps" do
    stub_api_request(:get, "/apps").to_return(:body => <<-EOXML)
      <?xml version='1.0' encoding='UTF-8'?>
      <apps type="array">
        <app><name>myapp1</name><owner><EMAIL></owner></app>
        <app><name>myapp2</name><owner><EMAIL></owner></app>
      </apps>
    EOXML
    @client.list.should == [
      ["myapp1", "<EMAIL>"],
      ["myapp2", "<EMAIL>"]
    ]
  end

  it "info -> get app attributes" do
    stub_api_request(:get, "/apps/myapp").to_return(:body => <<-EOXML)
      <?xml version='1.0' encoding='UTF-8'?>
      <app>
        <blessed type='boolean'>true</blessed>
        <created-at type='datetime'>2008-07-08T17:21:50-07:00</created-at>
        <id type='integer'>49134</id>
        <name>myapp</name>
        <production type='boolean'>true</production>
        <share-public type='boolean'>true</share-public>
        <domain_name/>
      </app><commit_msg>added spec for Heroku::Client.auth<commit_after>require File.expand_path("./base", File.dirname(__FILE__))
require "cgi"
require "heroku/client"

describe Heroku::Client do
  before do
    @client = Heroku::Client.new(nil, nil)
    @resource = mock('heroku rest resource')
    @client.stub!(:extract_warning)
  end

  it "Client.auth -> get user details" do
    user_info = { "api_key" => "abc" }
    stub_request(:post, "https://foo:<EMAIL>/login").to_return(:body => user_info.to_json)
    Heroku::Client.auth("foo", "bar").should == user_info
  end

  it "list -> get a list of this user's apps" do
    stub_api_request(:get, "/apps").to_return(:body => <<-EOXML)
      <?xml version='1.0' encoding='UTF-8'?>
      <apps type="array">
        <app><name>myapp1</name><owner><EMAIL></owner></app>
        <app><name>myapp2</name><owner><EMAIL></owner></app>
      </apps>
    EOXML
    @client.list.should == [
      ["myapp1", "<EMAIL>"],
      ["myapp2", "<EMAIL>"]
    ]
  end

  it "info -> get app attributes" do
    stub_api_request(:get, "/apps/myapp").to_return(:body => <<-EOXML)
      <?xml version='1.0' encoding='UTF-8'?>
      <app>
        <blessed type='boolean'>true</blessed>
        <created-at type='datetime'>2008-07-08T17:21:50-07:00</created-at>
        <id type='integer'>49134</id>
        <name>myapp</name>
        <production type='boolean'>true</production>
        <share-public type='boolean'>true</share-public>
        <domain_name/>
      </app>
{'fraction_non_alphanumeric': 0.19467061435973354, 'fraction_numerical': 0.02442635085122132, 'mean_word_length': 3.2366771159874608, 'pattern_counts': {'":': 0, '<': 82, '<?xml version=': 4, '>': 85, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2838979', 'n_tokens_mistral': 968, 'n_tokens_neox': 945, 'n_words': 168}