<commit_before>require './spec/spec_helper'

describe "create object from irc message" do
  let(:revueobj) { Revuelog.new("2014-11-28 13:58:33 +0100", "nickname", "Love TDD") }
  describe "checking revue object initialize" do
    it { expect(revueobj.nick).to eq("nickname") }
    it { expect(revueobj.time).to eq("2014-11-28 13:58:33 +0100") }
    it { expect(revueobj.message).to eq("Love TDD") }
  end

  describe "checking hash object" do
    it { expect(revueobj.to_hash).to be_kind_of(Hash)}
    it { expect(revueobj.to_hash["time"]).to eq("2014-11-28 13:58:33 +0100")}
    it { expect(revueobj.to_hash["nick"]).to eq("nickname")}
    it { expect(revueobj.to_hash["message"]).to eq("Love TDD")}
  end

end

describe "Test Mongodb" do
  let(:revuedb) {Revuedb.new}
  before(:each) do
    revuehash = Revuelog.new("2012-11-28 13:58:33 +0100", "Paul", "Love TDD and Paul").to_hash
    revuedb.dbinsert(revuehash)
    revuehash2 = Revuelog.new("2014-11-28 16:58:33 +0100", "Semia", "Love TDD !!").to_hash
    revuedb.dbinsert(revuehash2)
  end

  after(:each) do
    revuedb.dbclean
  end

  it { expect(revuedb.find("nick", "Paul").first['nick']).to eq('Paul')}
  it { expect(revuedb.distinct("nick")).to eq(['Paul','Semia'])}
end

describe "Sinatra render json" do
  let(:revuedb) {Revuedb.new}
  before(:each) do
    revuehash = Revuelog.new("2012-11-28 13:58:33 +0100", "Paul", "Love TDD and Paul").to_hash
    revuedb.dbinsert(revuehash)
  end

  def app
    Sinatra::Application
  end

  after(:each) do
    revuedb.dbclean
  end

  it "answer json" do
    #get '/'
    expect(last.response).to be_ok
  end
end<commit_msg>Trying to fix fail with rspec and sinatra<commit_after>require './spec/spec_helper'

describe "create object from irc message" do
  let(:revueobj) { Revuelog.new("2014-11-28 13:58:33 +0100", "nickname", "Love TDD") }
  describe "checking revue object initialize" do
    it { expect(revueobj.nick).to eq("nickname") }
    it { expect(revueobj.time).to eq("2014-11-28 13:58:33 +0100") }
    it { expect(revueobj.message).to eq("Love TDD") }
  end

  describe "checking hash object" do
    it { expect(revueobj.to_hash).to be_kind_of(Hash)}
    it { expect(revueobj.to_hash["time"]).to eq("2014-11-28 13:58:33 +0100")}
    it { expect(revueobj.to_hash["nick"]).to eq("nickname")}
    it { expect(revueobj.to_hash["message"]).to eq("Love TDD")}
  end

end

describe "Test Mongodb" do
  let(:revuedb) {Revuedb.new}
  before(:each) do
    revuehash = Revuelog.new("2012-11-28 13:58:33 +0100", "Paul", "Love TDD and Paul").to_hash
    revuedb.dbinsert(revuehash)
    revuehash2 = Revuelog.new("2014-11-28 16:58:33 +0100", "Semia", "Love TDD !!").to_hash
    revuedb.dbinsert(revuehash2)
  end

  after(:each) do
    revuedb.dbclean
  end

  it { expect(revuedb.find("nick", "Paul").first['nick']).to eq('Paul')}
  it { expect(revuedb.distinct("nick")).to eq(['Paul','Semia'])}
end

describe "Sinatra render json" do
  let(:revuedb) {Revuedb.new}
  before(:each) do
    revuehash = Revuelog.new("2012-11-28 13:58:33 +0100", "Paul", "Love TDD and Paul").to_hash
    revuedb.dbinsert(revuehash)
  end

  after(:each) do
    revuedb.dbclean
  end

  it "answer json" do
    get '/'
    expect(last.response).to be_ok
  end
end
{'fraction_non_alphanumeric': 0.16733436055469955, 'fraction_numerical': 0.06779661016949153, 'mean_word_length': 4.017001545595054, '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': '76976', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1254, 'n_words': 270}