Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix behavior of Twitter::Tweet.entities? method. #453

Merged
merged 1 commit into from
Sep 17, 2013

Conversation

michaelherold
Copy link
Contributor

Previously, this method returned true when inflating a tweet that has no entities because the inflated model does not set @attrs[:entities] to nil, but to a hash of empty lists.

For example:

> tweet = Twitter.status(372706156361576448)
=> #<Twitter::Tweet:0x000000062add38
 @attrs=
  {:created_at=>"Wed Aug 28 13:04:06 +0000 2013",
   :id=>372706156361576448,
   # snip extras for brevity
   :entities=>{:hashtags=>[], :symbols=>[], :urls=>[], :user_mentions=>[]},
   :favorited=>false,
   :retweeted=>false,
   :lang=>"en"}
> tweet.entities?
=> true

This pull request fixes this behavior to properly return false in this case. It also adds a spec to test this behavior. I opted to change this method as it seems less likely to affect things than changing the inflating method to set to nil.

Previously, this method returned true when inflating a
tweet that has no entities because the inflated model
does not set @attrs[:entities] to nil, but to a hash of
empty lists.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) when pulling 8ef885c on michaelherold:entities-fix into 554ff7c on sferik:master.

@sferik
Copy link
Owner

sferik commented Sep 17, 2013

Thanks!

sferik added a commit that referenced this pull request Sep 17, 2013
Fix behavior of Twitter::Tweet.entities? method.
@sferik sferik merged commit 969ef65 into sferik:master Sep 17, 2013
sferik added a commit that referenced this pull request Sep 17, 2013
@michaelherold michaelherold deleted the entities-fix branch September 17, 2013 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants