<commit_before>require 'spec_helper'

describe Daikon::Daemon do
  let(:client) { stub("client") }

  before do
    Daikon::Client.stubs(:new => client)
    Daikon::Daemon.sleep_time = 0.01
    client.stubs(:setup => true,
                 :start_monitor => true,
                 :rotate_monitor => true,
                 :report_info => true)
  end

  it "submits the last minute of data" do
    thread = Thread.new do
      Daikon::Daemon.start(["run", "--", "-k", "1234"], true)
    end
    sleep 0.65
    Daikon::Daemon.run = false
    client.should have_received(:rotate_monitor)
  end

  it "submits info to radish every 5 runs" do
    thread = Thread.new do
      Daikon::Daemon.start(["run", "--", "-k", "1234"], true)
    end
    sleep 0.15
    Daikon::Daemon.run = false
    client.should have_received(:report_info).twice
  end
end

describe Daikon::Daemon, "flags" do
  %w[-v --version].each do |flag|
    it "shows the daikon version with #{flag}" do
      old_stdout = $stdout
      $stdout = StringIO.new("")
      Daikon::Daemon.start([flag])
      $stdout.string.should include(Daikon::VERSION)
      $stdout = old_stdout
    end
  end
end<commit_msg>Give it some more time<commit_after>require 'spec_helper'

describe Daikon::Daemon do
  let(:client) { stub("client") }

  before do
    Daikon::Client.stubs(:new => client)
    Daikon::Daemon.sleep_time = 0.01
    client.stubs(:setup => true,
                 :start_monitor => true,
                 :rotate_monitor => true,
                 :report_info => true)
  end

  it "submits the last minute of data" do
    thread = Thread.new do
      Daikon::Daemon.start(["run", "--", "-k", "1234"], true)
    end
    sleep 0.65
    Daikon::Daemon.run = false
    client.should have_received(:rotate_monitor)
  end

  it "submits info to radish every 5 runs" do
    thread = Thread.new do
      Daikon::Daemon.start(["run", "--", "-k", "1234"], true)
    end
    sleep 0.2
    Daikon::Daemon.run = false
    client.should have_received(:report_info).times(3)
  end
end

describe Daikon::Daemon, "flags" do
  %w[-v --version].each do |flag|
    it "shows the daikon version with #{flag}" do
      old_stdout = $stdout
      $stdout = StringIO.new("")
      Daikon::Daemon.start([flag])
      $stdout.string.should include(Daikon::VERSION)
      $stdout = old_stdout
    end
  end
end
{'fraction_non_alphanumeric': 0.1387824606215411, 'fraction_numerical': 0.01532567049808429, 'mean_word_length': 2.6547433903576985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '2838982', 'n_tokens_mistral': 831, 'n_tokens_neox': 786, 'n_words': 199}