Sha256: 25773762683b86534dfad8cbbf02f97ea078422d9d8651ede3cecf7ad0ef9285

Contents?: true

Size: 1.97 KB

Versions: 8

Compression:

Stored size: 1.97 KB

Contents

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

describe "Chatterbot::Tweet" do
  describe "#tweet" do
    before(:each) do
      @bot = test_bot
    end

    it "calls require_login when tweeting" do
      @bot.should_receive(:require_login).and_return(false)
      @bot.tweet "tweet test!"
    end

    it "calls client.update with the right values" do
      bot = test_bot

      bot.should_receive(:require_login).and_return(true)
      bot.stub!(:client).and_return(mock(TwitterOAuth::Client))

      bot.stub!(:debug_mode?).and_return(false)

      test_str = "test!"
      bot.client.should_receive(:update).with(test_str, {})
      bot.tweet test_str
    end

    it "doesn't tweet when debug_mode? is set" do
      bot = test_bot
      
      bot.should_receive(:require_login).and_return(true)
      bot.stub!(:client).and_return(mock(TwitterOAuth::Client))

      bot.stub!(:debug_mode?).and_return(true)

      bot.client.should_not_receive(:update)
      bot.tweet "no tweet!"
    end
  end

  describe "#reply" do
    it "calls require_login when replying" do
      bot = test_bot
      bot.should_receive(:require_login).and_return(false)
      bot.reply "reply test!", {"id" => 100}
    end

    it "calls client.update with the right values" do
      bot = test_bot
      bot.should_receive(:require_login).and_return(true)
      bot.stub!(:client).and_return(mock(TwitterOAuth::Client))

      bot.stub!(:debug_mode?).and_return(false)

      test_str = "test!"

      s = {
        :id => 100
      }
      bot.client.should_receive(:update).with(test_str, {:in_reply_to_status_id => 100})
      bot.reply test_str, s
    end


    it "doesn't reply when debug_mode? is set" do
      bot = test_bot
      bot.should_receive(:require_login).and_return(true)
      bot.stub!(:client).and_return(mock(TwitterOAuth::Client))

      bot.stub!(:debug_mode?).and_return(true)

      bot.client.should_not_receive(:update)
      bot.reply "no reply test!", {:id => 100}
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
chatterbot-0.5.1 spec/tweet_spec.rb
chatterbot-0.5.0 spec/tweet_spec.rb
chatterbot-0.4.0 spec/tweet_spec.rb
chatterbot-0.3.0 spec/tweet_spec.rb
chatterbot-0.2.9 spec/tweet_spec.rb
chatterbot-0.2.8 spec/tweet_spec.rb
chatterbot-0.2.7 spec/tweet_spec.rb
chatterbot-0.2.6 spec/tweet_spec.rb