spec/reply_spec.rb in chatterbot-0.5.1 vs spec/reply_spec.rb in chatterbot-0.6.1

- old
+ new

@@ -6,29 +6,34 @@ #bot = Chatterbot::Bot.new bot.should_receive(:require_login).and_return(false) bot.replies end - # it "calls update_since_id" do - # bot = Chatterbot::Bot.new - # bot.should_receive(:require_login).and_return(true) - # bot.stub!(:client).and_return(fake_replies(100)) - # bot.should_receive(:update_since_id).with({'results' => []}) + it "updates since_id when complete" do + bot = test_bot + bot.should_receive(:require_login).and_return(true) + results = fake_replies(100, 1, 1000) - # bot.replies - # end + bot.stub!(:client).and_return(results) + + bot.replies do |x| + ; + end + bot.config[:tmp_since_id].should == 1000 + end + it "iterates results" do bot = test_bot bot.should_receive(:require_login).and_return(true) bot.stub!(:client).and_return(fake_replies(100, 3)) bot.should_receive(:update_since_id).exactly(3).times indexes = [] bot.replies do |x| - indexes << x[:index] + indexes << x[:id] end indexes.should == [1,2,3] end @@ -39,13 +44,14 @@ bot.should_receive(:update_since_id).exactly(2).times bot.stub!(:on_blacklist?).and_return(true, false) + indexes = [] bot.replies do |x| - indexes << x[:index] + indexes << x[:id] end indexes.should == [2,3] end @@ -54,11 +60,11 @@ bot = test_bot bot.should_receive(:require_login).and_return(true) bot.stub!(:client).and_return(fake_replies(100, 3)) bot.stub!(:since_id).and_return(123) - bot.client.should_receive(:replies).with({:since_id => 123}) + bot.client.should_receive(:mentions).with({:since_id => 123, :count => 200}) bot.replies end @@ -66,22 +72,10 @@ bot = test_bot bot.should_receive(:require_login).and_return(true) bot.stub!(:client).and_return(fake_replies(100, 3)) bot.stub!(:since_id).and_return(0) - bot.client.should_receive(:replies).with({ }) + bot.client.should_receive(:mentions).with({:count => 200}) bot.replies end - - - it "outputs an error if we get one from API" do - bot = test_bot - bot.stub!(:require_login).and_return(true) - bot.stub!(:client).and_return(mock(Object, :replies => {"error" => "You messed up"})) - - bot.should_receive(:critical).with("You messed up") - - bot.replies - end - end