Permalink
Browse files

Merge pull request #223 from raykrueger/add_retweeted_status_to_status

Add a reader for retweeted_status
  • Loading branch information...
2 parents 5068238 + 617ebcc commit bc4f82f0ea9357c8a2817e0fa307f2d4870f38b9 @sferik committed Dec 27, 2011
Showing with 24 additions and 0 deletions.
  1. +7 −0 lib/twitter/status.rb
  2. +17 −0 spec/twitter/status_spec.rb
View
@@ -59,5 +59,12 @@ def user
@user ||= Twitter::User.new(@attrs.dup['user'].merge('status' => @attrs.except('user'))) unless @attrs['user'].nil?
end
+ # If this status is itself a retweet, the original tweet is available here.
+ #
+ # @return [Twitter::Status]
+ def retweeted_status
+ @retweeted_status ||= self.class.new(@attrs['retweeted_status']) unless @attrs['retweeted_status'].nil?
+ end
+
end
end
@@ -105,4 +105,21 @@
end
end
+ describe "#retweeted_status" do
+ before do
+ @a_retweeted_status = Twitter::Status.new('retweeted_status' => {'text' => 'BOOSH'})
+ end
+ it "should return a Status when retweeted_status is set" do
+ @a_retweeted_status.retweeted_status.should be_a Twitter::Status
+ end
+ it "should return nil when a retweeted_status is NOT set" do
+ status = Twitter::Status.new
+ status.retweeted_status.should be_nil
+ end
+ it "should have text when retweeted_status is set" do
+ status = Twitter::Status.new('retweeted_status' => {'text' => 'BOOSH'})
+ status.retweeted_status.text.should == 'BOOSH'
+ end
+ end
+
end

0 comments on commit bc4f82f

Please sign in to comment.