<commit_before>require File.dirname(__FILE__) << "/test_helper"
require "json"

class ClientTest < Test::Unit::TestCase
  include Tweetwine

  context "A client" do
    setup do
      @client = Client.new({ :username => "foo", :password => "<PASSWORD>" })
    end

    should "raise ClientError for invalid request" do
      RestClient.expects(:get) \
                .with("https://foo:bar@twitter.com/statuses/friends_timeline.json?count=20") \
                .raises(RestClient::Unauthorized)
      assert_raises(ClientError) { @client.friends }
    end

    should "fetch friends' status timeline" do
      statuses = [
        {
          :created_at => Time.at(1),
          :user => { :username => "zanzibar" },
          :text => "wassup?"
        },
        {
          :created_at => Time.at(2),
          :user => { :username => "lulzwoo" },
          :text => "nuttin"
        }
      ]
      RestClient.expects(:get) \
                .with("https://foo:bar@twitter.com/statuses/friends_timeline.json?count=20") \
                .returns(statuses.to_json)
      @client.expects(:print_statuses)
      @client.friends
    end

    should "fetch a specific user's statuses, with the user identified by given argument" do
      statuses = [
        {<commit_msg>Better description for a spec.<commit_after>require File.dirname(__FILE__) << "/test_helper"
require "json"

class ClientTest < Test::Unit::TestCase
  include Tweetwine

  context "A client" do
    setup do
      @client = Client.new({ :username => "foo", :password => "<PASSWORD>" })
    end

    should "raise ClientError for invalid request" do
      RestClient.expects(:get) \
                .with("https://foo:bar@twitter.com/statuses/friends_timeline.json?count=20") \
                .raises(RestClient::Unauthorized)
      assert_raises(ClientError) { @client.friends }
    end

    should "fetch friends' statuses" do
      statuses = [
        {
          :created_at => Time.at(1),
          :user => { :username => "zanzibar" },
          :text => "wassup?"
        },
        {
          :created_at => Time.at(2),
          :user => { :username => "lulzwoo" },
          :text => "nuttin"
        }
      ]
      RestClient.expects(:get) \
                .with("https://foo:bar@twitter.com/statuses/friends_timeline.json?count=20") \
                .returns(statuses.to_json)
      @client.expects(:print_statuses)
      @client.friends
    end

    should "fetch a specific user's statuses, with the user identified by given argument" do
      statuses = [
        {
{'fraction_non_alphanumeric': 0.13565285379202502, 'fraction_numerical': 0.004691164972634871, 'mean_word_length': 2.202753441802253, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '2839431', 'n_tokens_mistral': 801, 'n_tokens_neox': 764, 'n_words': 159}