Skip to content

Commit

Permalink
Add methods to get to parameters of quoted tweet.
Browse files Browse the repository at this point in the history
  • Loading branch information
couhie authored and sferik committed Jun 5, 2015
1 parent 7a234b4 commit 9af58fc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/twitter/tweet.rb
Expand Up @@ -20,9 +20,13 @@ class Tweet < Twitter::Identity
object_attr_reader :Metadata, :metadata
object_attr_reader :Place, :place
object_attr_reader :Tweet, :retweeted_status
object_attr_reader :Tweet, :quoted_status
alias_method :retweeted_tweet, :retweeted_status
alias_method :retweet?, :retweeted_status?
alias_method :retweeted_tweet?, :retweeted_status?
alias_method :quoted_tweet, :quoted_status
alias_method :quote?, :quoted_status?
alias_method :quoted_tweet?, :quoted_status?
object_attr_reader :User, :user, :status
predicate_attr_reader :favorited, :possibly_sensitive, :retweeted,
:truncated
Expand Down
34 changes: 34 additions & 0 deletions spec/twitter/tweet_spec.rb
Expand Up @@ -296,6 +296,40 @@
end
end

describe '#quote?' do
it 'returns true when there is a quoted status' do
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :quoted_status => {:id => 540_897_316_908_331_009, :text => 'BOOSH'})
expect(tweet.quote?).to be true
end
it 'returns false when quoted_status is not set' do
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
expect(tweet.quote?).to be false
end
end

describe '#quoted_status' do
it 'returns a Tweet when quoted_status is set' do
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :quoted_status => {:id => 540_897_316_908_331_009, :text => 'BOOSH'})
expect(tweet.quoted_tweet).to be_a Twitter::Tweet
expect(tweet.quoted_tweet.text).to eq('BOOSH')
end
it 'returns nil when quoted_status is not set' do
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
expect(tweet.quoted_tweet).to be_nil
end
end

describe '#quoted_status?' do
it 'returns true when quoted_status is set' do
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :quoted_status => {:id => 540_897_316_908_331_009, :text => 'BOOSH'})
expect(tweet.quoted_status?).to be true
end
it 'returns false when quoted_status is not set' do
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
expect(tweet.quoted_status?).to be false
end
end

describe '#symbols' do
it 'returns an array of Entity::Symbol when symbols are set' do
symbols_array = [
Expand Down

0 comments on commit 9af58fc

Please sign in to comment.