Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Twitter::Base#home_timeline

From Twitter API wiki:
  In a future version of the API, statuses/friends_timeline will go away and be
  replaced by home_timeline.
  • Loading branch information...
commit 2de3786e75e6a1725572d3f08f6886f64e507851 1 parent 5e54e6d
@coderifous coderifous authored
View
48 lib/twitter/base.rb
@@ -1,22 +1,26 @@
module Twitter
class Base
extend Forwardable
-
+
def_delegators :client, :get, :post, :put, :delete
-
+
attr_reader :client
def initialize(client)
@client = client
end
+ # Options: since_id, max_id, count, page
+ def home_timeline(query={})
+ perform_get('http://api.twitter.com/1/statuses/home_timeline.json', :query => query)
+ end
+
# Options: since_id, max_id, count, page, since
def friends_timeline(query={})
perform_get('/statuses/friends_timeline.json', :query => query)
end
-
- # Options: id, user_id, screen_name, since_id, max_id, page, since, count
+ # Options: id, user_id, screen_name, since_id, max_id, page, since, count
def user_timeline(query={})
perform_get('/statuses/user_timeline.json', :query => query)
end
@@ -60,7 +64,7 @@ def followers(query={})
def user(id, query={})
perform_get("/users/show/#{id}.json", :query => query)
end
-
+
# Options: page, per_page
def user_search(q, query={})
q = URI.escape(q)
@@ -171,66 +175,66 @@ def unblock(id)
def help
perform_get('/help/test.json')
end
-
+
def list_create(list_owner_username, options)
perform_post("/#{list_owner_username}/lists.json", :body => {:user => list_owner_username}.merge(options))
end
-
+
def list_update(list_owner_username, slug, options)
perform_put("/#{list_owner_username}/lists/#{slug}.json", :body => options)
end
-
+
def list_delete(list_owner_username, slug)
perform_delete("/#{list_owner_username}/lists/#{slug}.json")
end
-
+
def lists(list_owner_username=nil)
path = "http://api.twitter.com/1"
path += "/#{list_owner_username}" if list_owner_username
path += "/lists.json"
perform_get(path)
end
-
+
def list(list_owner_username, slug)
perform_get("/#{list_owner_username}/lists/#{slug}.json")
end
-
+
def list_timeline(list_owner_username, slug)
perform_get("/#{list_owner_username}/lists/#{slug}/statuses.json")
end
-
+
def memberships(list_owner_username)
perform_get("/#{list_owner_username}/lists/memberships.json")
end
-
+
def list_members(list_owner_username, slug)
perform_get("/#{list_owner_username}/#{slug}/members.json")
end
-
+
def list_add_member(list_owner_username, slug, new_id)
perform_post("/#{list_owner_username}/#{slug}/members.json", :body => {:id => new_id})
end
-
+
def list_remove_member(list_owner_username, slug, id)
perform_delete("/#{list_owner_username}/#{slug}/members.json", :body => {:id => id})
end
-
+
def is_list_member?(list_owner_username, slug, id)
perform_get("/#{list_owner_username}/#{slug}/members/#{id}.json").error.nil?
end
-
+
def list_subscribers(list_owner_username, slug)
perform_get("/#{list_owner_username}/#{slug}/subscribers.json")
end
-
+
def list_subscribe(list_owner_username, slug)
perform_post("/#{list_owner_username}/#{slug}/subscribers.json")
end
-
+
def list_unsubscribe(list_owner_username, slug)
perform_delete("/#{list_owner_username}/#{slug}/subscribers.json")
end
-
+
def list_subscriptions(list_owner_username)
perform_get("/#{list_owner_username}/lists/subscriptions.json")
end
@@ -243,11 +247,11 @@ def perform_get(path, options={})
def perform_post(path, options={})
Twitter::Request.post(self, path, options)
end
-
+
def perform_put(path, options={})
Twitter::Request.put(self, path, options)
end
-
+
def perform_delete(path, options={})
Twitter::Request.delete(self, path, options)
end
View
1  test/fixtures/home_timeline.json
@@ -0,0 +1 @@
+[{"in_reply_to_screen_name":null,"user":{"profile_sidebar_border_color":"181A1E","description":"Loves his wife, ruby, notre dame football and iu basketball","time_zone":"Indiana (East)","utc_offset":-18000,"friends_count":161,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","following":true,"notifications":false,"profile_background_color":"1A1B1F","url":"http:\/\/railstips.org\/about","screen_name":"jnunemaker","name":"John Nunemaker","profile_background_tile":false,"profile_text_color":"666666","followers_count":1231,"protected":false,"favourites_count":73,"created_at":"Sun Aug 13 22:56:06 +0000 2006","profile_link_color":"2FC2EF","statuses_count":4664,"profile_sidebar_fill_color":"252429","location":"Mishawaka, Indiana","id":4243,"profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme9\/bg.gif"},"text":"Rob Dyrdek is the funniest man alive. That is all.","truncated":false,"in_reply_to_status_id":null,"in_reply_to_user_id":null,"created_at":"Thu Apr 02 22:57:00 +0000 2009","favorited":false,"id":1441588944,"source":"<a href=\"http:\/\/www.atebits.com\/software\/tweetie\/\">Tweetie<\/a>"},{"favorited":false,"user":{"profile_sidebar_fill_color":"252429","description":"Loves his wife, ruby, notre dame football and iu basketball","utc_offset":-18000,"profile_sidebar_border_color":"181A1E","followers_count":1228,"following":true,"notifications":false,"profile_background_tile":false,"friends_count":161,"time_zone":"Indiana (East)","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","favourites_count":73,"profile_background_color":"1A1B1F","protected":false,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme9\/bg.gif","profile_text_color":"666666","screen_name":"jnunemaker","statuses_count":4663,"profile_link_color":"2FC2EF","location":"Mishawaka, Indiana","id":4243,"created_at":"Sun Aug 13 22:56:06 +0000 2006"},"text":"Dang, forgot about CAN http:\/\/calendaraboutnothing.com\/~jnunemaker yesterday and broke my streak of 5 days in a row.","in_reply_to_screen_name":null,"truncated":false,"in_reply_to_status_id":null,"id":1438916463,"in_reply_to_user_id":null,"source":"web","created_at":"Thu Apr 02 15:24:17 +0000 2009"},{"in_reply_to_screen_name":null,"user":{"friends_count":161,"profile_background_color":"1A1B1F","description":"Loves his wife, ruby, notre dame football and iu basketball","time_zone":"Indiana (East)","utc_offset":-18000,"favourites_count":72,"profile_text_color":"666666","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","following":true,"profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme9\/bg.gif","profile_link_color":"2FC2EF","url":"http:\/\/railstips.org\/about","screen_name":"jnunemaker","name":"John Nunemaker","protected":false,"statuses_count":4660,"profile_sidebar_fill_color":"252429","notifications":false,"created_at":"Sun Aug 13 22:56:06 +0000 2006","profile_sidebar_border_color":"181A1E","followers_count":1228,"profile_background_tile":false,"location":"Mishawaka, Indiana","id":4243},"text":"@kebabsylan yes. I'll be there at noon.","truncated":false,"in_reply_to_status_id":null,"in_reply_to_user_id":null,"created_at":"Thu Apr 02 14:38:03 +0000 2009","favorited":false,"id":1438637063,"source":"<a href=\"http:\/\/help.twitter.com\/index.php?pg=kb.page&id=75\">txt<\/a>"},{"in_reply_to_screen_name":null,"user":{"notifications":false,"profile_background_tile":false,"friends_count":161,"description":"Loves his wife, ruby, notre dame football and iu basketball","time_zone":"Indiana (East)","utc_offset":-18000,"favourites_count":72,"profile_background_color":"1A1B1F","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","following":true,"profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme9\/bg.gif","profile_text_color":"666666","url":"http:\/\/railstips.org\/about","screen_name":"jnunemaker","name":"John Nunemaker","statuses_count":4659,"protected":false,"profile_link_color":"2FC2EF","created_at":"Sun Aug 13 22:56:06 +0000 2006","profile_sidebar_fill_color":"252429","location":"Mishawaka, Indiana","id":4243,"profile_sidebar_border_color":"181A1E","followers_count":1228},"text":"http:\/\/twitpic.com\/2pwjy - The books I'm reading right now. Wish I had more time.","truncated":false,"in_reply_to_status_id":null,"in_reply_to_user_id":null,"created_at":"Thu Apr 02 14:34:10 +0000 2009","favorited":false,"id":1438613754,"source":"<a href=\"http:\/\/twitpic.com\/\">TwitPic<\/a>"},{"favorited":false,"user":{"statuses_count":4658,"profile_background_color":"1A1B1F","description":"Loves his wife, ruby, notre dame football and iu basketball","utc_offset":-18000,"followers_count":1226,"profile_text_color":"666666","following":true,"favourites_count":72,"time_zone":"Indiana (East)","profile_link_color":"2FC2EF","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","protected":false,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","notifications":false,"profile_sidebar_fill_color":"252429","friends_count":161,"screen_name":"jnunemaker","profile_sidebar_border_color":"181A1E","profile_background_tile":false,"profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme9\/bg.gif","location":"Mishawaka, Indiana","id":4243,"created_at":"Sun Aug 13 22:56:06 +0000 2006"},"text":"Reading a couple hokey named books of late, but really enjoying them. \"I Will Teach You To Be Rich\" and \"Get Anyone To Do Anything\".","in_reply_to_screen_name":null,"truncated":false,"in_reply_to_status_id":null,"id":1436286949,"in_reply_to_user_id":null,"source":"web","created_at":"Thu Apr 02 03:52:02 +0000 2009"},{"favorited":false,"user":{"profile_link_color":"2FC2EF","description":"Loves his wife, ruby, notre dame football and iu basketball","utc_offset":-18000,"profile_sidebar_fill_color":"252429","followers_count":1226,"following":true,"time_zone":"Indiana (East)","profile_sidebar_border_color":"181A1E","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","notifications":false,"profile_background_tile":false,"friends_count":161,"protected":false,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","favourites_count":72,"profile_background_color":"1A1B1F","screen_name":"jnunemaker","statuses_count":4657,"profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme9\/bg.gif","profile_text_color":"666666","location":"Mishawaka, Indiana","id":4243,"created_at":"Sun Aug 13 22:56:06 +0000 2006"},"text":"Megan Joy turned into a train wreck tonight.","in_reply_to_screen_name":null,"truncated":false,"in_reply_to_status_id":null,"id":1435963959,"in_reply_to_user_id":null,"source":"<a href=\"http:\/\/help.twitter.com\/index.php?pg=kb.page&id=75\">txt<\/a>","created_at":"Thu Apr 02 02:51:01 +0000 2009"},{"in_reply_to_screen_name":null,"user":{"notifications":false,"profile_background_tile":false,"friends_count":161,"description":"Loves his wife, ruby, notre dame football and iu basketball","time_zone":"Indiana (East)","utc_offset":-18000,"favourites_count":72,"profile_background_color":"1A1B1F","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","following":true,"profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme9\/bg.gif","profile_text_color":"666666","url":"http:\/\/railstips.org\/about","screen_name":"jnunemaker","name":"John Nunemaker","statuses_count":4656,"protected":false,"profile_link_color":"2FC2EF","created_at":"Sun Aug 13 22:56:06 +0000 2006","profile_sidebar_fill_color":"252429","location":"Mishawaka, Indiana","id":4243,"profile_sidebar_border_color":"181A1E","followers_count":1226},"text":"Watching latest House. Cool idea.","truncated":false,"in_reply_to_status_id":null,"in_reply_to_user_id":null,"created_at":"Thu Apr 02 01:25:46 +0000 2009","favorited":false,"id":1435502494,"source":"<a href=\"http:\/\/www.atebits.com\/software\/tweetie\/\">Tweetie<\/a>"},{"in_reply_to_screen_name":null,"user":{"notifications":false,"profile_background_tile":false,"friends_count":179,"description":"Loves his wife, ruby, notre dame football and iu basketball","time_zone":"Indiana (East)","utc_offset":-18000,"favourites_count":72,"profile_background_color":"1A1B1F","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","following":true,"profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme9\/bg.gif","profile_text_color":"666666","url":"http:\/\/railstips.org\/about","screen_name":"jnunemaker","name":"John Nunemaker","statuses_count":4650,"protected":false,"profile_link_color":"2FC2EF","created_at":"Sun Aug 13 22:56:06 +0000 2006","profile_sidebar_fill_color":"252429","location":"Mishawaka, Indiana","id":4243,"profile_sidebar_border_color":"181A1E","followers_count":1226},"text":"Sat on a fat bob today. Want! http:\/\/tr.im\/i7ha Love the flat black. Wish I could get a used one for less money, but they are too new.","truncated":false,"in_reply_to_status_id":null,"in_reply_to_user_id":null,"created_at":"Wed Apr 01 23:16:13 +0000 2009","favorited":false,"id":1434842036,"source":"web"},{"truncated":false,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","protected":false,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","location":"Mishawaka, Indiana","id":4243,"followers_count":1226,"screen_name":"jnunemaker"},"in_reply_to_status_id":null,"text":"Just test drove an Escape with @nunieswife and visited the Harley Store. Johnny want a Harley...BAD!","in_reply_to_user_id":null,"favorited":false,"created_at":"Wed Apr 01 22:31:04 +0000 2009","in_reply_to_screen_name":null,"id":1434591491,"source":"web"},{"in_reply_to_user_id":null,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","protected":false,"followers_count":1222,"screen_name":"jnunemaker","location":"Mishawaka, Indiana","id":4243},"text":"I hope the Bears go after Jay Cutler.","favorited":false,"created_at":"Wed Apr 01 12:35:28 +0000 2009","in_reply_to_screen_name":null,"truncated":false,"id":1431011290,"in_reply_to_status_id":null,"source":"<a href=\"http:\/\/help.twitter.com\/index.php?pg=kb.page&id=75\">txt<\/a>"},{"in_reply_to_user_id":null,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","protected":false,"followers_count":1216,"screen_name":"jnunemaker","location":"Mishawaka, Indiana","id":4243},"text":"Bundled up HTTParty's JSON and XML parsers (ganked from Merb and Rails) into a separate gem for all to enjoy. http:\/\/tr.im\/i4rc","favorited":false,"created_at":"Wed Apr 01 04:30:10 +0000 2009","in_reply_to_screen_name":null,"truncated":false,"id":1429401587,"in_reply_to_status_id":null,"source":"web"},{"truncated":false,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","protected":false,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","location":"Mishawaka, Indiana","id":4243,"followers_count":1215,"screen_name":"jnunemaker"},"in_reply_to_status_id":null,"text":"Opened an ING savings account tonight. First step towards automating more of my finances.","in_reply_to_user_id":null,"favorited":false,"created_at":"Wed Apr 01 01:13:13 +0000 2009","in_reply_to_screen_name":null,"id":1428332783,"source":"<a href=\"http:\/\/loungeapp.com\">Lounge<\/a>"},{"in_reply_to_status_id":null,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","protected":false,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","followers_count":1214,"screen_name":"jnunemaker","location":"Mishawaka, Indiana","id":4243},"in_reply_to_user_id":null,"text":"Working from the ND bookstore.","created_at":"Tue Mar 31 19:19:44 +0000 2009","favorited":false,"in_reply_to_screen_name":null,"truncated":false,"id":1426346076,"source":"web"},{"in_reply_to_status_id":null,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","protected":false,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","followers_count":1214,"location":"Mishawaka, Indiana","id":4243,"screen_name":"jnunemaker"},"text":"Wishes the slide screen on the iPhone had an api so he could put weather and ego app stats there.","in_reply_to_user_id":null,"favorited":false,"created_at":"Tue Mar 31 14:46:14 +0000 2009","in_reply_to_screen_name":null,"id":1424683964,"truncated":false,"source":"<a href=\"http:\/\/www.atebits.com\/software\/tweetie\/\">Tweetie<\/a>"},{"in_reply_to_user_id":null,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","protected":false,"followers_count":1214,"screen_name":"jnunemaker","location":"Mishawaka, Indiana","id":4243},"favorited":false,"text":"En route to @ebrackley's. We're going to a fondue murder mystery tonight. Who killed the fondue!","created_at":"Sun Mar 29 17:44:43 +0000 2009","in_reply_to_screen_name":null,"truncated":false,"in_reply_to_status_id":null,"id":1413049459,"source":"<a href=\"http:\/\/www.atebits.com\/software\/tweetie\/\">Tweetie<\/a>"},{"favorited":false,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","followers_count":1214,"url":"http:\/\/railstips.org\/about","name":"John Nunemaker","screen_name":"jnunemaker","protected":false,"location":"Mishawaka, Indiana","id":4243},"in_reply_to_screen_name":null,"text":"Added a sexy bar graph of the RailsTips archives in the footer. http:\/\/tr.im\/hWt5","created_at":"Sun Mar 29 06:09:54 +0000 2009","truncated":false,"in_reply_to_status_id":null,"in_reply_to_user_id":null,"id":1411056131,"source":"web"},{"in_reply_to_user_id":null,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","protected":false,"followers_count":1214,"screen_name":"jnunemaker","location":"Mishawaka, Indiana","id":4243},"favorited":false,"text":"Corn!!!","created_at":"Sun Mar 29 03:34:49 +0000 2009","in_reply_to_screen_name":null,"truncated":false,"in_reply_to_status_id":null,"id":1410528666,"source":"<a href=\"http:\/\/help.twitter.com\/index.php?pg=kb.page&id=75\">txt<\/a>"},{"in_reply_to_user_id":null,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","protected":false,"followers_count":1214,"screen_name":"jnunemaker","location":"Mishawaka, Indiana","id":4243},"favorited":false,"text":"Famous Dave's was so tasty tonight. Had fun with @nunieswife, @orderedlist, @carrie, @oaknd1, @lizsmc1 and @catbrad. Dang lots of tweeps.","created_at":"Sun Mar 29 00:26:09 +0000 2009","in_reply_to_screen_name":null,"truncated":false,"in_reply_to_status_id":null,"id":1409709416,"source":"<a href=\"http:\/\/www.atebits.com\/software\/tweetie\/\">Tweetie<\/a>"},{"in_reply_to_user_id":null,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","protected":false,"followers_count":1214,"screen_name":"jnunemaker","location":"Mishawaka, Indiana","id":4243},"favorited":false,"text":"We told him he was making a big mistake and that he obviously didn't know who we are.","created_at":"Sat Mar 28 22:30:04 +0000 2009","in_reply_to_screen_name":null,"truncated":false,"in_reply_to_status_id":null,"id":1409188633,"source":"<a href=\"http:\/\/help.twitter.com\/index.php?pg=kb.page&id=75\">txt<\/a>"},{"in_reply_to_user_id":null,"user":{"description":"Loves his wife, ruby, notre dame football and iu basketball","url":"http:\/\/railstips.org\/about","name":"John Nunemaker","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","protected":false,"followers_count":1214,"screen_name":"jnunemaker","location":"Mishawaka, Indiana","id":4243},"favorited":false,"text":"Just brainstormed next addition to @harmonyapp with @orderedlist. It is going to be awesome.","created_at":"Sat Mar 28 21:15:34 +0000 2009","in_reply_to_screen_name":null,"truncated":false,"in_reply_to_status_id":null,"id":1408861206,"source":"<a href=\"http:\/\/www.atebits.com\/software\/tweetie\/\">Tweetie<\/a>"}]
View
54 test/twitter/base_test.rb
@@ -27,6 +27,18 @@ class BaseTest < Test::Unit::TestCase
end
context "hitting the api" do
+ should "be able to get home timeline" do
+ stub_get('http://api.twitter.com/1/statuses/home_timeline.json', 'home_timeline.json')
+ timeline = @twitter.home_timeline
+ timeline.size.should == 20
+ first = timeline.first
+ first.source.should == '<a href="http://www.atebits.com/software/tweetie/">Tweetie</a>'
+ first.user.name.should == 'John Nunemaker'
+ first.user.url.should == 'http://railstips.org/about'
+ first.id.should == 1441588944
+ first.favorited.should be(false)
+ end
+
should "be able to get friends timeline" do
stub_get('/statuses/friends_timeline.json', 'friends_timeline.json')
timeline = @twitter.friends_timeline
@@ -90,21 +102,21 @@ class BaseTest < Test::Unit::TestCase
hashes = @twitter.friends_timeline.map{ |s| s.hash }
hashes.should == @twitter.friends_timeline.map{ |s| s.hash }
end
-
+
should "be able to get a friendship" do
stub_get("/friendships/show.json?source_screen_name=dcrec1&target_screen_name=pengwynn", 'friendship.json')
@twitter.friendship_show(:source_screen_name => 'dcrec1', :target_screen_name => 'pengwynn').relationship.target.followed_by == false
end
-
+
should "be able to search people" do
stub_get("/users/search.json?q=Wynn%20Netherland", 'people_search.json')
- people = @twitter.user_search('Wynn Netherland')
+ people = @twitter.user_search('Wynn Netherland')
people.first.screen_name.should == 'pengwynn'
end
end
-
+
context "when using lists" do
-
+
should "be able to create a new list" do
stub_post('/pengwynn/lists.json', 'list.json')
list = @twitter.list_create('pengwynn', {:name => 'Rubyists'})
@@ -112,7 +124,7 @@ class BaseTest < Test::Unit::TestCase
list.slug.should == 'rubyists'
list.mode.should == 'public'
end
-
+
should "be able to update a list" do
stub_put('/pengwynn/lists/rubyists.json', 'list.json')
list = @twitter.list_update('pengwynn', 'rubyists', {:name => 'Rubyists'})
@@ -120,7 +132,7 @@ class BaseTest < Test::Unit::TestCase
list.slug.should == 'rubyists'
list.mode.should == 'public'
end
-
+
should "be able to delete a list" do
stub_delete('/pengwynn/lists/rubyists.json', 'list.json')
list = @twitter.list_delete('pengwynn', 'rubyists')
@@ -128,7 +140,7 @@ class BaseTest < Test::Unit::TestCase
list.slug.should == 'rubyists'
list.mode.should == 'public'
end
-
+
should "be able to view lists to which a user belongs" do
stub_get('/pengwynn/lists/memberships.json', 'memberships.json')
lists = @twitter.memberships('pengwynn').lists
@@ -136,7 +148,7 @@ class BaseTest < Test::Unit::TestCase
lists.first.name.should == 'web-dev'
lists.first.member_count.should == 38
end
-
+
should "be able to view lists for the authenticated user" do
stub_get('http://api.twitter.com/1/pengwynn/lists.json', 'lists.json')
lists = @twitter.lists('pengwynn').lists
@@ -151,7 +163,7 @@ class BaseTest < Test::Unit::TestCase
list.name.should == 'Rubyists'
list.subscriber_count.should == 0
end
-
+
should "be able to view list timeline" do
stub_get('/pengwynn/lists/rubyists/statuses.json', 'list_statuses.json')
tweets = @twitter.list_timeline('pengwynn', 'rubyists')
@@ -159,7 +171,7 @@ class BaseTest < Test::Unit::TestCase
tweets.first.id.should == 5272535583
tweets.first.user.name.should == 'John Nunemaker'
end
-
+
should "be able to view list members" do
stub_get('/pengwynn/rubyists/members.json', 'list_users.json')
members = @twitter.list_members('pengwynn', 'rubyists').users
@@ -167,24 +179,24 @@ class BaseTest < Test::Unit::TestCase
members.first.name.should == 'John Nunemaker'
members.first.screen_name.should == 'jnunemaker'
end
-
+
should "be able to add a member to a list" do
stub_post('/pengwynn/rubyists/members.json', 'user.json')
user = @twitter.list_add_member('pengwynn', 'rubyists', 4243)
user.screen_name.should == 'jnunemaker'
end
-
+
should "be able to remove a member from a list" do
stub_delete('/pengwynn/rubyists/members.json', 'user.json')
user = @twitter.list_remove_member('pengwynn', 'rubyists', 4243)
user.screen_name.should == 'jnunemaker'
end
-
+
should "be able to check if a user is member of a list" do
stub_get('/pengwynn/rubyists/members/4243.json', 'user.json')
@twitter.is_list_member?('pengwynn', 'rubyists', 4243).should == true
end
-
+
should "be able to view list subscribers" do
stub_get('/pengwynn/rubyists/subscribers.json', 'list_users.json')
subscribers = @twitter.list_subscribers('pengwynn', 'rubyists').users
@@ -192,19 +204,19 @@ class BaseTest < Test::Unit::TestCase
subscribers.first.name.should == 'John Nunemaker'
subscribers.first.screen_name.should == 'jnunemaker'
end
-
+
should "be able to subscribe to a list" do
stub_post('/pengwynn/rubyists/subscribers.json', 'user.json')
user = @twitter.list_subscribe('pengwynn', 'rubyists')
user.screen_name.should == 'jnunemaker'
end
-
+
should "be able to unsubscribe from a list" do
stub_delete('/pengwynn/rubyists/subscribers.json', 'user.json')
user = @twitter.list_unsubscribe('pengwynn', 'rubyists')
user.screen_name.should == 'jnunemaker'
end
-
+
should "be able to view a members list subscriptions" do
stub_get('/pengwynn/lists/subscriptions.json', 'list_subscriptions.json')
subscriptions = @twitter.list_subscriptions('pengwynn').lists
@@ -212,9 +224,9 @@ class BaseTest < Test::Unit::TestCase
subscriptions.first.full_name.should == '@chriseppstein/sass-users'
subscriptions.first.slug.should == 'sass-users'
end
-
+
end
-
-
+
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.