Skip to content

Commit

Permalink
Add aliases for favoriters, favoriters_count, and favourites_count
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Oct 18, 2012
1 parent 9b9f142 commit 60fce1e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
3 changes: 3 additions & 0 deletions lib/twitter/tweet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Tweet < Twitter::Identity
alias favorited? favorited
alias favourited favorited
alias favourited? favorited
alias favouriters favoriters
alias retweeted? retweeted
alias truncated? truncated

Expand All @@ -31,7 +32,9 @@ def favoriters_count
favoriters_count.to_i if favoriters_count
end
alias favorite_count favoriters_count
alias favorites_count favoriters_count
alias favourite_count favoriters_count
alias favourites_count favoriters_count
alias favouriters_count favoriters_count

# @return [String]
Expand Down
2 changes: 2 additions & 0 deletions lib/twitter/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ class User < Twitter::BasicUser
alias default_profile_image? default_profile_image
alias follow_request_sent? follow_request_sent
alias favorite_count favourites_count
alias favoriters_count favourites_count
alias favorites_count favourites_count
alias favourite_count favourites_count
alias favouriters_count favourites_count
alias follower_count followers_count
alias friend_count friends_count
alias geo_enabled? geo_enabled
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/status.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"place":{"country_code":"US","place_type":"neighborhood","url":"http:\/\/api.twitter.com\/1\/geo\/id\/41bcb736f84a799e.json","country":"The United States of America","attributes":{},"full_name":"Mission Bay, San Francisco","name":"Mission Bay","id":"41bcb736f84a799e","bounding_box":{"type":"Polygon","coordinates":[[[-122.40618084,37.76405301],[-122.38151184,37.76405301],[-122.38151184,37.78199199],[-122.40618084,37.78199199]]]}},"retweet_count":null,"geo":null,"retweeted":false,"in_reply_to_status_id":null,"source":"web","truncated":false,"in_reply_to_status_id_str":null,"created_at":"Thu Sep 30 01:43:44 +0000 2010","in_reply_to_user_id":3191321,"favorited":false,"in_reply_to_user_id_str":"3191321","user":{"contributors_enabled":false,"time_zone":"Pacific Time (US & Canada)","description":"Adventures in hunger and foolishness.","geo_enabled":true,"profile_sidebar_fill_color":"DDEEF6","followers_count":898,"notifications":false,"verified":false,"profile_use_background_image":true,"profile_sidebar_border_color":"C0DEED","follow_request_sent":false,"url":null,"profile_background_image_url":"http:\/\/a3.twimg.com\/profile_background_images\/162641967\/we_concept_bg2.png","lang":"en","created_at":"Mon Jul 16 12:59:01 +0000 2007","profile_background_color":"000000","location":"San Francisco","profile_background_tile":false,"protected":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/323331048\/me_normal.jpg","listed_count":28,"friends_count":88,"profile_text_color":"333333","name":"Erik Michaels-Ober","statuses_count":2968,"following":false,"screen_name":"sferik","id":7505382,"id_str":"7505382","show_all_inline_media":true,"utc_offset":-28800,"favourites_count":727,"profile_link_color":"0084B4"},"contributors":null,"coordinates":null,"in_reply_to_screen_name":"noradio","id":25938088801,"id_str":"25938088801","text":"@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"}
{"created_at":"Wed Apr 06 19:13:37 +0000 2011","id":55709764298092545,"id_str":"55709764298092545","text":"The problem with your code is that it's doing exactly what you told it to do.","source":"\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":7505382,"id_str":"7505382","name":"Erik Michaels-Ober","screen_name":"sferik","location":"San Francisco","description":"Write code. Not too much. Mostly Ruby.","url":"https:\/\/github.com\/sferik","entities":{"url":{"urls":[{"url":"https:\/\/github.com\/sferik","expanded_url":null,"indices":[0,25]}]},"description":{"urls":[]}},"protected":false,"followers_count":2479,"friends_count":200,"listed_count":132,"created_at":"Mon Jul 16 12:59:01 +0000 2007","favourites_count":4421,"utc_offset":-28800,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":false,"statuses_count":8730,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"000000","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/677717672\/bb0b3653dcf0644e344823e0a2eb3382.png","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/677717672\/bb0b3653dcf0644e344823e0a2eb3382.png","profile_background_tile":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1759857427\/image1326743606_normal.png","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1759857427\/image1326743606_normal.png","profile_banner_url":"https:\/\/si0.twimg.com\/profile_banners\/7505382\/1349499693","profile_link_color":"0084B4","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":{"type":"Point","coordinates":[37.78349999,-122.39362884]},"coordinates":{"type":"Point","coordinates":[-122.39362884,37.78349999]},"place":{"id":"5c92ab5379de3839","url":"https:\/\/api.twitter.com\/1.1\/geo\/id\/5c92ab5379de3839.json","place_type":"neighborhood","name":"South Beach","full_name":"South Beach, San Francisco","country_code":"US","country":"United States","bounding_box":{"type":"Polygon","coordinates":[[[-122.403482,37.777529],[-122.387436,37.777529],[-122.387436,37.794486],[-122.403482,37.794486]]]},"attributes":{}},"contributors":null,"retweet_count":316,"entities":{"hashtags":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false}
20 changes: 10 additions & 10 deletions spec/twitter/api/statuses_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
tweets = @client.favorite(25938088801)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
end

Expand All @@ -67,7 +67,7 @@
tweets = @client.unfavorite(25938088801)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
end

Expand Down Expand Up @@ -288,7 +288,7 @@
it "returns a Tweet" do
tweet = @client.status(25938088801)
expect(tweet).to be_a Twitter::Tweet
expect(tweet.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
expect(tweet.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
end

Expand All @@ -304,7 +304,7 @@
tweets = @client.statuses(25938088801)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
end

Expand Down Expand Up @@ -351,7 +351,7 @@
tweets = @client.status_destroy(25938088801)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
end

Expand All @@ -375,16 +375,16 @@

describe "#tweet" do
before do
stub_post("/1.1/statuses/update.json").with(:body => {:status => "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
stub_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do."}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.update("@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!")
expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"})).to have_been_made
@client.update("The problem with your code is that it's doing exactly what you told it to do.")
expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do."})).to have_been_made
end
it "returns a Tweet" do
tweet = @client.update("@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!")
tweet = @client.update("The problem with your code is that it's doing exactly what you told it to do.")
expect(tweet).to be_a Twitter::Tweet
expect(tweet.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
expect(tweet.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
end

Expand Down

0 comments on commit 60fce1e

Please sign in to comment.