Sha256: 3e8521c299f6a9cd2bf5ba6787374596792794c1fdf5d51ffda4039454d3134a

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'
require 'pry'

describe Lita::Handlers::Markov, lita_handler: true do
  before(:each) do
    subject.engine.db[:dictionary].delete
  end

  it "won't call #ingest for non-command messages" do
    expect(subject).to_not receive(:ingest)

    send_message "#{robot.name} foo"
    send_command 'bar'
  end

  it 'will build a sentence' do
    send_message 'I love cookies!'
    send_message 'I love pancakes!'

    send_command "#{robot.name} markov #{user.mention_name}"

    expect(replies.count).to eql 1

    reply = replies[0]
    possible_replies = [
      'I love cookies.',
      'I love pancakes.'
    ]
    expect(possible_replies.any? { |r| reply.include?(r) }).to eql true
  end

  it 'will also accept @-names' do
    send_message 'I like cookies.'

    send_command "#{robot.name} markov @#{user.mention_name}"

    expect(replies.count).to eql 1
    expect(replies[0]).to include('I like cookies.')
  end

  it "will complain if the user hasn't said anything" do
    send_command "#{robot.name} markov #{user.mention_name}"

    expect(replies.count).to eql 1
    expect(replies[0]).to eql "Looks like Test User hasn't said anything!"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lita-markov-1.3.0 spec/lita/handlers/markov_spec.rb
lita-markov-1.2.1 spec/lita/handlers/markov_spec.rb