<commit_before>require 'spec_helper'

describe Giphy::Client do
  let(:api_response) { double }
  let(:response)     { double }

  before { Giphy::Response.stub(:build).with(api_response).and_return(response) }

  subject { Giphy::Client.new }

  describe "#recent" do
    it "does a GET on the 'recent' endpoint" do
      Giphy::Request.stub(:get).with('/recent', options: 'options').and_return(api_response)
      expect(subject.recent(options: 'options')).to eq response
    end
  end

  describe "#translate" do
    it "does a GET on the 'transalate' endpoint" do
      Giphy::Request.stub(:get).with('/translate', s: 'word').and_return(api_response)
      expect(subject.translate('word')).to eq response
    end
  end

  describe "#search" do
    it "does a GET on the 'search' endpoint" do
      Giphy::Request.stub(:get).with('/search', {q: 'keyword', options: 'options'}).and_return(api_response)
      expect(subject.search('keyword', options: 'options')).to eq response
    end
  end

  describe "#flag" do
    it "does a POST on the 'flagged' endpoint" do
      Giphy::Request.stub(:post).with('/12HoHdqnDxz5NS/flagged', {}).and_return(api_response)
      expect(subject.flag('12HoHdqnDxz5NS')).to eq response
    end
  end

  describe "#flagged" do
    it "does a GET on the 'flagged' endpoint" do
      Giphy::Request.stub(:get).with('/flagged', {}).and_return(api_response)
      expect(subject.flagged).to eq response
    end
  end

  describe "#favorite" do
    it "does a POST on the 'favorites' endpoint" do
      Giphy::Request.stub(:post).with('/12HoHdqnDxz5NS/favorites', {}).and_return(api_response)
      expect(subject.favorite('12HoHdqnDxz5NS')).to eq response
    end
  end

  describe "#favorites" do
    context "when no username is passed to it" do
      it "does a GET on the 'favorites' endpoint with no username" do
        Giphy::Request.stub(:get).with('/favorites', {username: ''}).and_return(api_response)
        expect(subject.favorites).to eq response
      end
    end

    context "when a username is passed as an argument" do
      it "does a GET on the 'favorites' endpoint with the username" do
        username = 'absurdnoise'
        Giphy::Request.stub(:get).with('/favorites', {username: username}).and_return(api_response)
        expect(subject.favorites(username)).to eq response
      end
    end
  end

  describe "#screensaver" do
    it "does a GET on the 'screensaver' endpoint" do
      Giphy::Request.stub(:get).with('/screensaver', {tag: 'tag'}).and_return(api_response)
      expect(subject.screensaver('tag')).to eq response
    end
  end

  describe "#ramdom" do
    it "does a GET on the 'random' endpoint" do
      Giphy::Request.stub(:get).with('/random', {}).and_return(api_response)
      expect(subject.random).to eq response
    end
  end

  describe "#artists" do
    it "does a GET on the 'artists' endpoint" do
      Giphy::Request.stub(:get).with('/artists', {}).and_return(api_response)
      expect(subject.artists).to eq response
    end
  end

  describe "#gif" do
    it "does a GET on the 'gif_by_id' endpoint" do
      Giphy::Request.stub(:get).with('/12HoHdqnDxz5NS', {}).and_return(api_response)
      expect(subject.gif('12HoHdqnDxz5NS')).to eq response
    end<commit_msg>Updated client unit tests<commit_after>require 'spec_helper'

describe Giphy::Client do
  let(:api_response) { double }
  let(:response)     { double }

  before { Giphy::Response.stub(:build).with(api_response).and_return(response) }

  subject { Giphy::Client.new }

  describe "#recent" do
    it "does a GET on the 'recent' endpoint" do
      Giphy::Request.stub(:get).with('/recent', options: 'options').and_return(api_response)
      expect(subject.recent(options: 'options')).to eq response
    end
  end

  describe "#translate" do
    it "does a GET on the 'transalate' endpoint" do
      Giphy::Request.stub(:get).with('/translate', s: 'word').and_return(api_response)
      expect(subject.translate('word')).to eq response
    end
  end

  describe "#search" do
    it "does a GET on the 'search' endpoint" do
      Giphy::Request.stub(:get).with('/search', {q: 'keyword', options: 'options'}).and_return(api_response)
      expect(subject.search('keyword', options: 'options')).to eq response
    end
  end

  describe "#flag" do
    it "does a POST on the 'flagged' endpoint" do
      Giphy::Request.stub(:post).with('/12HoHdqnDxz5NS/flagged', {}).and_return(api_response)
      expect(subject.flag('12HoHdqnDxz5NS')).to eq response
    end
  end

  describe "#flagged" do
    it "does a GET on the 'flagged' endpoint" do
      Giphy::Request.stub(:get).with('/flagged', {}).and_return(api_response)
      expect(subject.flagged).to eq response
    end
  end

  describe "#favorite" do
    it "does a POST on the 'favorites' endpoint" do
      Giphy::Request.stub(:post).with('/12HoHdqnDxz5NS/favorites', {}).and_return(api_response)
      expect(subject.favorite('12HoHdqnDxz5NS')).to eq response
    end
  end

  describe "#favorites" do
    context "when no username is passed to it" do
      it "does a GET on the 'favorites' endpoint with no username" do
        Giphy::Request.stub(:get).with('/favorites', {username: ''}).and_return(api_response)
        expect(subject.favorites).to eq response
      end
    end

    context "when a username is passed as an argument" do
      it "does a GET on the 'favorites' endpoint with the username" do
        username = 'absurdnoise'
        Giphy::Request.stub(:get).with('/favorites', {username: username}).and_return(api_response)
        expect(subject.favorites(username)).to eq response
      end
    end
  end

  describe "#screensaver" do
    it "does a GET on the 'screensaver' endpoint" do
      Giphy::Request.stub(:get).with('/screensaver', {tag: 'tag'}).and_return(api_response)
      expect(subject.screensaver('tag')).to eq response
    end
  end

  describe "#random" do
    context "when no tag is passed to it" do
      it "does a GET on the 'random' endpoint with no tag" do
        Giphy::Request.stub(:get).with('/random', {tag: ''}).and_return(api_response)
        expect(subject.random).to eq response
      end
    end

    context "when a tag is passed to it" do
      it "does a GET on the 'random' endpoint with a tag" do
        Giphy::Request.stub(:get).with('/random', {tag: 'american psycho'}).and_return(api_response)
        expect(subject.random('american psycho')).to eq response
      end
    end
  end

  describe "#artists" do
    it "does a GET on the 'artists' endpoint" do
      Giphy::Request.stub(:get).with('/artists', {}).and_return(api_response)
      expect(subject.artists).to eq response
    end
  end

  describe "#gif" do
    it "does a GET on the 'gif_by_id' endpoint" do
      Giphy::Request.stub(:get).with('/12HoHdqnDxz5NS', {}).and_return(api_response)
      expect(subject.gif('12HoHdqnDxz5NS')).to eq response
    end
{'fraction_non_alphanumeric': 0.13370069605568446, 'fraction_numerical': 0.005220417633410673, 'mean_word_length': 3.507843137254902, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4119191', 'n_tokens_mistral': 2295, 'n_tokens_neox': 2246, 'n_words': 599}