Sha256: 96c444bdc00e1781c50378520302e309d12c5448f1ec4bdaee883b41cf88daa1

Contents?: true

Size: 1.58 KB

Versions: 7

Compression:

Stored size: 1.58 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "Chatterbot::Reply" do
  it "calls require_login" do
    bot = test_bot
    expect(bot).to receive(:require_login).and_return(false)
    bot.replies
  end

  it "updates since_id_reply when complete" do
    bot = test_bot
    expect(bot).to receive(:require_login).and_return(true)
    results = fake_replies(1, 1000)

    allow(bot).to receive(:client).and_return(results)

    bot.replies do
    end

    expect(bot.config[:since_id_reply]).to eq(1000)
  end

  it "iterates results" do
    bot = test_bot
    expect(bot).to receive(:require_login).and_return(true)
    allow(bot).to receive(:client).and_return(fake_replies(3))

    expect(bot).to receive(:update_since_id_reply).exactly(3).times

    indexes = []
    bot.replies do |x|
      indexes << x.id
    end

    expect(indexes).to eq([1,2,3])
  end

  it "checks blocklist" do
    bot = test_bot
    expect(bot).to receive(:require_login).and_return(true)
    allow(bot).to receive(:client).and_return(fake_replies(3))

    allow(bot).to receive(:on_blocklist?).and_return(true, false, false)


    indexes = []
    bot.replies do |x|
      indexes << x.id
    end

    expect(indexes).to eq([2,3])
  end


  it "passes along since_id_reply" do
    bot = test_bot
    expect(bot).to receive(:require_login).and_return(true)
    allow(bot).to receive(:client).and_return(fake_replies(100, 3))
    allow(bot).to receive(:since_id_reply).and_return(123)

    expect(bot.client).to receive(:mentions_timeline).with({:since_id => 123, :count => 200})

    bot.replies
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chatterbot-2.2.0 spec/reply_spec.rb
chatterbot-2.1.0 spec/reply_spec.rb
chatterbot-2.0.5 spec/reply_spec.rb
chatterbot-2.0.4 spec/reply_spec.rb
chatterbot-2.0.3 spec/reply_spec.rb
chatterbot-2.0.2 spec/reply_spec.rb
chatterbot-2.0.0.pre spec/reply_spec.rb