<commit_before>require 'spec_helper'

describe Loggly do

  before(:all) do
    @test_subdomain = 'example'
    @test_user = 'user'
    @test_pass = '<PASSWORD>'
    @test_key = '123456'
    @loggly = Loggly.new(
      :subdomain => @test_subdomain, 
      :user => @test_user, 
      :pass => <PASSWORD>, 
      :key => @test_key
    )
  end

  describe "#search" do

    before(:each) do
      RestClient.stub!(:get)
      Kernel.stub!(:print)
    end

    it "should generate an appropriate RestClient GET" do

      search_string = "search string"
      RestClient.should_receive(:get).with(
        "https://#{@test_user}:#{@test_pass}@#{@test_subdomain}.loggly.com/api/search", 
        {:params => {:q => search_string}}
      )

      @loggly.search(search_string)
    end

    it "should execute the callback if one is provided" do

      Kernel.should_receive(:print).with('return data')
      RestClient.should_receive(:get).and_return('return data')

      @loggly.search('anything') do |data|
        Kernel.print data
      end
    end
  end

  describe "#log" do
    
    before(:each) do
      RestClient.stub!(:post)
    end

    it "should generate an appropriate RestClient POST with a raw payload" do

      log_string = "this is a test log"
      RestClient.should_receive(:post).with(
        "https://logs.loggly.com/inputs/%s" % @test_key,
        log_string
      )

      @loggly.log(log_string)
    end<commit_msg>No need to stuf RestClient once rspec expectations are set<commit_after>require 'spec_helper'

describe Loggly do

  before(:all) do
    @test_subdomain = 'example'
    @test_user = 'user'
    @test_pass = '<PASSWORD>'
    @test_key = '123456'
    @loggly = Loggly.new(
      :subdomain => @test_subdomain, 
      :user => @test_user, 
      :pass => <PASSWORD>, 
      :key => @test_key
    )
  end

  describe "#search" do
    it "should generate an appropriate RestClient GET" do

      search_string = "search string"
      RestClient.should_receive(:get).with(
        "https://#{@test_user}:#{@test_pass}@#{@test_subdomain}.loggly.com/api/search", 
        {:params => {:q => search_string}}
      )

      @loggly.search(search_string)
    end

    it "should execute the callback if one is provided" do

      Kernel.should_receive(:print).with('return data')
      RestClient.should_receive(:get).and_return('return data')

      @loggly.search('anything') do |data|
        Kernel.print data
      end
    end
  end

  describe "#log" do

    it "should generate an appropriate RestClient POST with a raw payload" do

      log_string = "this is a test log"
      RestClient.should_receive(:post).with(
        "https://logs.loggly.com/inputs/%s" % @test_key,
        log_string
      )

      @loggly.log(log_string)
    end
{'fraction_non_alphanumeric': 0.12644092219020173, 'fraction_numerical': 0.004322766570605188, 'mean_word_length': 2.668428005284016, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 4, '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': '3592573', 'n_tokens_mistral': 937, 'n_tokens_neox': 884, 'n_words': 209}