Skip to content

Commit

Permalink
Fix bug in Tweet#full_text
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Oct 18, 2012
1 parent 60fce1e commit 9646a5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/twitter/tweet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ def from_user
# @return [String]
# @note May be > 140 characters.
def full_text
retweeted_status && retweeted_status.user ? "RT @#{retweeted_status.user.screen_name}: #{retweeted_status.text}" : text
if retweeted_status
prefix = text[/\A(RT @[a-z0-9_]{1,20}: )/i, 1]
[prefix, retweeted_status.text].compact.join
else
text
end
end

# @return [Twitter::Geo]
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/tweet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
expect(tweet.full_text).to eq "BOOSH"
end
it "returns the full text of a retweeted Tweet" do
tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 28561922516, :text => 'BOOSH', :user => {:id => 7505382, :screen_name => 'sferik'}})
tweet = Twitter::Tweet.new(:id => 28669546014, :text => 'RT @sferik: BOOSH', :retweeted_status => {:id => 28561922516, :text => 'BOOSH'})
expect(tweet.full_text).to be_a String
expect(tweet.full_text).to eq "RT @sferik: BOOSH"
end
Expand Down

0 comments on commit 9646a5b

Please sign in to comment.