<commit_before>require_relative 'test-common'

require 'cinch/plugins/tyrant-history'

describe Cinch::Plugins::TyrantHistory do
  include Cinch::Test

  let(:bot) {
    make_bot(Cinch::Plugins::TyrantHistory) { |c|
      self.loggers.stub('debug') { nil }
    }
  }

  before :each do
    @conn = FakeConnection.new
    @tyrant = Tyrants.get_fake('testplayer', @conn)
    allow(Tyrants).to receive(:get).with('testplayer').and_return(@tyrant)

    @conn.respond('getOldFactionWars', nil, {'wars' => [
      {
        'faction_war_id' => '1',
        'name' => 'THE ENEMY',
        'attacker_faction_id' => '1000',
        'defender_faction_id' => '1001',
        'start_time' => Time.now.to_i.to_s,
        'duration' => '6',
        'atk_pts' => '0',
        'def_pts' => '0',
      },
    ]})
  end

  it 'makes a test bot' do
    expect(bot).to be_a Cinch::Bot
  end

  it 'shows old wars' do
    msg = make_message(bot, '!last', channel: '#test')
    replies = get_replies_text(msg)
    expect(replies).to be == ['         1 - faction 1000 vs THE ENEMY 0-0 (+0) 06:00:00 left']
  end

  describe 'flood control' do
    def msg
      make_message(bot, '!last', channel: '#test')
    end<commit_msg>spec: Don't expect getOldFactionWar in TyrantHistory init<commit_after>require_relative 'test-common'

require 'cinch/plugins/tyrant-history'

describe Cinch::Plugins::TyrantHistory do
  include Cinch::Test

  let(:bot) {
    make_bot(Cinch::Plugins::TyrantHistory) { |c|
      self.loggers.stub('debug') { nil }
    }
  }

  before :each do
    @conn = FakeConnection.new
    @tyrant = Tyrants.get_fake('testplayer', @conn)
    allow(Tyrants).to receive(:get).with('testplayer').and_return(@tyrant)
  end

  it 'makes a test bot' do
    expect(bot).to be_a Cinch::Bot
  end

  it 'shows old wars' do
    @conn.respond('getOldFactionWars', nil, {'wars' => [
      {
        'faction_war_id' => '1',
        'name' => '<NAME>',
        'attacker_faction_id' => '1000',
        'defender_faction_id' => '1001',
        'start_time' => Time.now.to_i.to_s,
        'duration' => '6',
        'atk_pts' => '0',
        'def_pts' => '0',
      },
    ]})

    msg = make_message(bot, '!last', channel: '#test')
    replies = get_replies_text(msg)
    expect(replies).to be == ['         1 - faction 1000 vs THE ENEMY 0-0 (+0) 06:00:00 left']
  end

  describe 'flood control' do
    def msg
      make_message(bot, '!last', channel: '#test')
    end

    before :each do
      @conn.respond('getOldFactionWars', nil, {'wars' => [
        {
          'faction_war_id' => '1',
          'name' => '<NAME>',
          'attacker_faction_id' => '1000',
          'defender_faction_id' => '1001',
          'start_time' => Time.now.to_i.to_s,
          'duration' => '6',
          'atk_pts' => '0',
          'def_pts' => '0',
        },
      ]})
    end
{'fraction_non_alphanumeric': 0.16760365425158116, 'fraction_numerical': 0.022487702037947997, 'mean_word_length': 2.6267515923566878, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, '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': '93347', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1050, 'n_words': 209}