spec/client_spec.rb in chatterbot-0.7.0 vs spec/client_spec.rb in chatterbot-0.7.1

- old
+ new

@@ -1,18 +1,31 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Chatterbot::Client" do before(:each) do @bot = Chatterbot::Bot.new - @bot.client = mock(Object) + @bot.client = double(Object) end + describe "reset_since_id_reply" do + it "gets the id of the last reply" do + bot = test_bot + bot.stub(:client).and_return(fake_replies(1, 1000)) + bot.client.should_receive(:mentions) + + bot.reset_since_id_reply + + bot.config[:tmp_since_id_reply].should == 1000 + end + + end + describe "reset_since_id" do it "runs a search to get a new max_id" do bot = test_bot - bot.stub!(:client).and_return(fake_search(100, 1)) + bot.stub(:client).and_return(fake_search(100, 1)) bot.client.should_receive(:search).with("a") # bot.search("a") bot.reset_since_id bot.config[:tmp_since_id].should == 100 @@ -25,11 +38,11 @@ @bot.require_login end describe "init_client" do before(:each) do - @client = mock(Twitter::Client) + @client = double(Twitter::Client) @bot.should_receive(:client).and_return(@client) end it "returns true when client has credentials" do @client.should_receive(:credentials?).and_return(true) @@ -63,18 +76,18 @@ @bot.should_receive(:needs_auth_token?).and_return(true) @bot.should_receive(:get_oauth_verifier).and_return("pin") end it "handles getting an auth token" do - token = mock(Object, + token = double(Object, :token => "token", :secret => "secret" ) @bot.should_receive(:request_token).and_return(token) token.should_receive(:get_access_token).with(:oauth_verifier => "pin"). - and_return(mock(:token => "access_token", :secret => "access_secret")) + and_return(double(:token => "access_token", :secret => "access_secret")) @bot.should_receive(:get_screen_name) @bot.should_receive(:update_config) @bot.login @@ -89,19 +102,19 @@ end end describe "get_screen_name" do before(:each) do - @json = '{"id":12345,"screen_name":"mockbot"}' + @json = '{"id":12345,"screen_name":"bot"}' - @token = mock(Object) - response = mock(Object, :body => @json) + @token = double(Object) + response = double(Object, :body => @json) @token.should_receive(:get).with("/1.1/account/verify_credentials.json").and_return(response) end it "should work" do @bot.get_screen_name(@token) - @bot.screen_name.should == "mockbot" + @bot.screen_name.should == "bot" end end