spec/twitter/tweet_spec.rb in twitter-5.0.0.rc.1 vs spec/twitter/tweet_spec.rb in twitter-5.0.0

- old
+ new

@@ -1,5 +1,6 @@ +# coding: utf-8 require 'helper' describe Twitter::Tweet do before do @@ -13,21 +14,21 @@ describe "#==" do it "returns true when objects IDs are the same" do tweet = Twitter::Tweet.new(:id => 1, :text => "foo") other = Twitter::Tweet.new(:id => 1, :text => "bar") - expect(tweet == other).to be_true + expect(tweet == other).to be true end it "returns false when objects IDs are different" do tweet = Twitter::Tweet.new(:id => 1) other = Twitter::Tweet.new(:id => 2) - expect(tweet == other).to be_false + expect(tweet == other).to be false end it "returns false when classes are different" do tweet = Twitter::Tweet.new(:id => 1) other = Twitter::Identity.new(:id => 1) - expect(tweet == other).to be_false + expect(tweet == other).to be false end end describe "#created_at" do it "returns a Time when set" do @@ -41,35 +42,40 @@ end describe "#created?" do it "returns true when created_at is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :created_at => "Mon Jul 16 12:59:01 +0000 2007") - expect(tweet.created?).to be_true + expect(tweet.created?).to be true end it "returns false when created_at is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - expect(tweet.created?).to be_false + expect(tweet.created?).to be false end end describe "#entities?" do it "returns false if there are no entities set" do tweet = Twitter::Tweet.new(:id => 28669546014) - expect(tweet.entities?).to be_false + expect(tweet.entities?).to be false end + it "returns false if there are blank lists of entities set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => []}) + expect(tweet.entities?).to be false + end + it "returns true if there are entities set" do urls_array = [ { :url => "http://example.com/t.co", :expanded_url => "http://example.com/expanded", - :display_url => "example.com/expanded", + :display_url => "example.com/expanded…", :indices => [10, 33], } ] tweet = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => urls_array}) - expect(tweet.entities?).to be_true + expect(tweet.entities?).to be true end end describe "#filter_level" do it "returns the filter level when filter_level is set" do @@ -117,15 +123,15 @@ end describe "#geo?" do it "returns true when geo is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :geo => {:id => 1, :type => "Point"}) - expect(tweet.geo?).to be_true + expect(tweet.geo?).to be true end it "returns false when geo is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - expect(tweet.geo?).to be_false + expect(tweet.geo?).to be false end end describe "#hashtags" do it "returns an array of Entity::Hashtag when entities are set" do @@ -179,15 +185,15 @@ end describe "#metadata?" do it "returns true when metadata is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :metadata => {}) - expect(tweet.metadata?).to be_true + expect(tweet.metadata?).to be true end it "returns false when metadata is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - expect(tweet.metadata?).to be_false + expect(tweet.metadata?).to be false end end describe "#place" do it "returns a Twitter::Place when place is set" do @@ -201,37 +207,37 @@ end describe "#place?" do it "returns true when place is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :place => {:id => "247f43d441defc03"}) - expect(tweet.place?).to be_true + expect(tweet.place?).to be true end it "returns false when place is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - expect(tweet.place?).to be_false + expect(tweet.place?).to be false end end describe "#reply?" do it "returns true when there is an in-reply-to status" do tweet = Twitter::Tweet.new(:id => 28669546014, :in_reply_to_status_id => 114749583439036416) - expect(tweet.reply?).to be_true + expect(tweet.reply?).to be true end it "returns false when in_reply_to_status_id is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - expect(tweet.reply?).to be_false + expect(tweet.reply?).to be false end end describe "#retweet?" do it "returns true when there is a retweeted status" do tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 25938088801, :text => "BOOSH"}) - expect(tweet.retweet?).to be_true + expect(tweet.retweet?).to be true end it "returns false when retweeted_status is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - expect(tweet.retweet?).to be_false + expect(tweet.retweet?).to be false end end describe "#retweeted_status" do it "returns a Tweet when retweeted_status is set" do @@ -246,15 +252,15 @@ end describe "#retweeted_status?" do it "returns true when retweeted_status is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 25938088801, :text => "BOOSH"}) - expect(tweet.retweeted_status?).to be_true + expect(tweet.retweeted_status?).to be true end it "returns false when retweeted_status is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - expect(tweet.retweeted_status?).to be_false + expect(tweet.retweeted_status?).to be false end end describe "#symbols" do it "returns an array of Entity::Symbol when symbols are set" do @@ -283,20 +289,20 @@ it "returns an array of Entity::URIs when entities are set" do urls_array = [ { :url => "http://example.com/t.co", :expanded_url => "http://example.com/expanded", - :display_url => "example.com/expanded", + :display_url => "example.com/expanded…", :indices => [10, 33], } ] tweet = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => urls_array}) expect(tweet.uris).to be_an Array expect(tweet.uris.first).to be_a Twitter::Entity::URI expect(tweet.uris.first.indices).to eq([10, 33]) - expect(tweet.uris.first.display_uri).to be_a URI - expect(tweet.uris.first.display_uri.to_s).to eq("example.com/expanded") + expect(tweet.uris.first.display_uri).to be_a String + expect(tweet.uris.first.display_uri).to eq("example.com/expanded…") end it "is empty when not set" do tweet = Twitter::Tweet.new(:id => 28669546014) expect(tweet.uris).to be_empty end @@ -331,14 +337,14 @@ end describe "#user?" do it "returns true when status is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382}) - expect(tweet.user?).to be_true + expect(tweet.user?).to be true end it "returns false when status is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - expect(tweet.user?).to be_false + expect(tweet.user?).to be false end end describe "#user_mentions" do it "returns an array of Entity::UserMention when entities are set" do