diff --git a/README.md b/README.md index 44b846755..fff9df618 100644 --- a/README.md +++ b/README.md @@ -273,7 +273,7 @@ Here are some fun facts about the 3.0 release: * The entire library is implemented in just 2,000 lines of code * With over 5,000 lines of specs, the spec-to-code ratio is over 2.5:1 -* The spec suite contains 659 examples and runs in under 2 seconds on a MacBook +* The spec suite contains 661 examples and runs in under 2 seconds on a MacBook * This project has 100% C0 code coverage (the tests execute every line of source code at least once) * At the time of release, this library is comprehensive: you can request all diff --git a/lib/twitter/tweet.rb b/lib/twitter/tweet.rb index d14c8dabf..73b2c346d 100644 --- a/lib/twitter/tweet.rb +++ b/lib/twitter/tweet.rb @@ -79,6 +79,10 @@ def repliers_count end alias reply_count repliers_count + def retweet? + !!retweeted_status + end + # If this Tweet is a retweet, the original Tweet is available here. # # @return [Twitter::Tweet] @@ -86,6 +90,7 @@ def retweeted_status @retweeted_status ||= self.class.fetch_or_new(@attrs[:retweeted_status]) end alias retweeted_tweet retweeted_status + alias retweet retweeted_status # @return [String] def retweeters_count diff --git a/spec/twitter/tweet_spec.rb b/spec/twitter/tweet_spec.rb index 7804a6d30..16b3854fc 100644 --- a/spec/twitter/tweet_spec.rb +++ b/spec/twitter/tweet_spec.rb @@ -176,20 +176,14 @@ end end - describe "#retweeters_count" do - it "returns the count of favoriters when retweet_count is set" do - tweet = Twitter::Tweet.new(:id => 28669546014, :retweet_count => '1') - tweet.retweeters_count.should be_an Integer - tweet.retweeters_count.should eq 1 - end - it "returns the count of favoriters when retweeters_count is set" do - tweet = Twitter::Tweet.new(:id => 28669546014, :retweeters_count => '1') - tweet.retweeters_count.should be_an Integer - tweet.retweeters_count.should eq 1 + describe "#retweet?" do + it "returns true when there is a retweeted status" do + tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 28561922516, :text => 'BOOSH'}) + tweet.retweet?.should be_true end - it "returns nil when not set" do + it "returns false when retweeted_status is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.retweeters_count.should be_nil + tweet.retweet?.should be_false end end @@ -205,6 +199,23 @@ end end + describe "#retweeters_count" do + it "returns the count of favoriters when retweet_count is set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :retweet_count => '1') + tweet.retweeters_count.should be_an Integer + tweet.retweeters_count.should eq 1 + end + it "returns the count of favoriters when retweeters_count is set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :retweeters_count => '1') + tweet.retweeters_count.should be_an Integer + tweet.retweeters_count.should eq 1 + end + it "returns nil when not set" do + tweet = Twitter::Tweet.new(:id => 28669546014) + tweet.retweeters_count.should be_nil + end + end + describe "#entities?" do it "returns false if there are no entities set" do tweet = Twitter::Tweet.new(:id => 28669546014)