spec/helpers_spec.rb in chatterbot-1.0.2 vs spec/helpers_spec.rb in chatterbot-2.0.0.pre

- old
+ new

@@ -1,18 +1,18 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Chatterbot::Helpers" do - it "#tweet_user works with [:from_user]" do + it "#tweet_user works with Tweet" do bot = Chatterbot::Bot.new - expect(bot.tweet_user({:from_user => "foo"})).to eq("@foo") - expect(bot.tweet_user({:from_user => "@foo"})).to eq("@foo") + t = Twitter::Tweet.new(:id => 1, :user => {:id => 1, :screen_name => "skippy"}) + expect(bot.tweet_user(t)).to eq("@skippy") end - it "#tweet_user works with [:user][:screen_name]" do + it "#tweet_user works with User" do bot = Chatterbot::Bot.new - expect(bot.tweet_user({:user => {:screen_name => "foo"}})).to eq("@foo") - expect(bot.tweet_user({:user => {:screen_name => "@foo"}})).to eq("@foo") + u = Twitter::User.new({:id => 1, :name => "skippy"}) + expect(bot.tweet_user(u)).to eq("@skippy") end it "#tweet_user works with string" do bot = Chatterbot::Bot.new expect(bot.tweet_user("foo")).to eq("@foo") @@ -35,14 +35,10 @@ it "should accept user" do u = Twitter::User.new(:id => 123, :name => "x") expect(@bot.from_user(fake_user("x"))).to eq("x") end - - it "should accept :screen_name" do - expect(@bot.from_user(:user => {:screen_name => "x"})).to eq("x") - end end describe "#botname" do before(:each) do class TestBot < Chatterbot::Bot; end @@ -59,10 +55,10 @@ @bot2 = TestBot.new expect(@bot2.botname).to eq("testbot") end it "calls botname for non-inherited bots" do - expect(File).to receive(:basename).and_return("bot") + allow(File).to receive(:basename).and_return("bot") expect(@bot.botname).to eq("bot") end it "uses specified name" do @bot = Chatterbot::Bot.new(:name => 'xyzzy')