Skip to content
Browse files

Added Twitter API versioning support

  • Loading branch information...
1 parent cdf99ec commit 69d4df515fe95f727221dad19b92665dc24f06d0 @sferik committed Mar 18, 2010
Showing with 123 additions and 117 deletions.
  1. +83 −77 lib/twitter/base.rb
  2. +40 −40 test/twitter/base_test.rb
View
160 lib/twitter/base.rb
@@ -2,6 +2,8 @@ module Twitter
class Base
extend Forwardable
+ API_VERSION = 1
+
def_delegators :client, :get, :post, :put, :delete
attr_reader :client
@@ -12,281 +14,283 @@ def initialize(client)
# Options: since_id, max_id, count, page
def home_timeline(query={})
- perform_get('/statuses/home_timeline.json', :query => query)
+ perform_get("/#{API_VERSION}/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)
+ perform_get("/#{API_VERSION}/statuses/friends_timeline.json", :query => query)
end
# 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)
+ perform_get("/#{API_VERSION}/statuses/user_timeline.json", :query => query)
end
def status(id)
- perform_get("/statuses/show/#{id}.json")
+ perform_get("/#{API_VERSION}/statuses/show/#{id}.json")
end
# Options: count
def retweets(id, query={ })
- perform_get("/statuses/retweets/#{id}.json", :query => query)
+ perform_get("/#{API_VERSION}/statuses/retweets/#{id}.json", :query => query)
end
# Options: in_reply_to_status_id
def update(status, query={})
- perform_post("/statuses/update.json", :body => {:status => status}.merge(query))
+ perform_post("/#{API_VERSION}/statuses/update.json", :body => {:status => status}.merge(query))
end
# DEPRECATED: Use #mentions instead
#
# Options: since_id, max_id, since, page
def replies(query={})
warn("DEPRECATED: #replies is deprecated by Twitter; use #mentions instead")
- perform_get('/statuses/replies.json', :query => query)
+ perform_get("/#{API_VERSION}/statuses/replies.json", :query => query)
end
# Options: since_id, max_id, count, page
def mentions(query={})
- perform_get('/statuses/mentions.json', :query => query)
+ perform_get("/#{API_VERSION}/statuses/mentions.json", :query => query)
end
# Options: since_id, max_id, count, page
def retweeted_by_me(query={})
- perform_get('/statuses/retweeted_by_me.json', :query => query)
+ perform_get("/#{API_VERSION}/statuses/retweeted_by_me.json", :query => query)
end
# Options: since_id, max_id, count, page
def retweeted_to_me(query={})
- perform_get('/statuses/retweeted_to_me.json', :query => query)
+ perform_get("/#{API_VERSION}/statuses/retweeted_to_me.json", :query => query)
end
# Options: since_id, max_id, count, page
def retweets_of_me(query={})
- perform_get('/statuses/retweets_of_me.json', :query => query)
+ perform_get("/#{API_VERSION}/statuses/retweets_of_me.json", :query => query)
end
def status_destroy(id)
- perform_post("/statuses/destroy/#{id}.json")
+ perform_post("/#{API_VERSION}/statuses/destroy/#{id}.json")
end
def retweet(id)
- perform_post("/statuses/retweet/#{id}.json")
+ perform_post("/#{API_VERSION}/statuses/retweet/#{id}.json")
end
# Options: id, user_id, screen_name, page
def friends(query={})
- perform_get('/statuses/friends.json', :query => query)
+ perform_get("/#{API_VERSION}/statuses/friends.json", :query => query)
end
# Options: id, user_id, screen_name, page
def followers(query={})
- perform_get('/statuses/followers.json', :query => query)
+ perform_get("/#{API_VERSION}/statuses/followers.json", :query => query)
end
def user(id, query={})
- perform_get("/users/show/#{id}.json", :query => query)
+ perform_get("/#{API_VERSION}/users/show/#{id}.json", :query => query)
end
# Options: page, per_page
def user_search(q, query={})
q = URI.escape(q)
- perform_get("/users/search.json", :query => ({:q => q}.merge(query)))
+ perform_get("/#{API_VERSION}/users/search.json", :query => ({:q => q}.merge(query)))
end
# Options: since, since_id, page
def direct_messages(query={})
- perform_get("/direct_messages.json", :query => query)
+ perform_get("/#{API_VERSION}/direct_messages.json", :query => query)
end
# Options: since, since_id, page
def direct_messages_sent(query={})
- perform_get("/direct_messages/sent.json", :query => query)
+ perform_get("/#{API_VERSION}/direct_messages/sent.json", :query => query)
end
def direct_message_create(user, text)
- perform_post("/direct_messages/new.json", :body => {:user => user, :text => text})
+ perform_post("/#{API_VERSION}/direct_messages/new.json", :body => {:user => user, :text => text})
end
def direct_message_destroy(id)
- perform_post("/direct_messages/destroy/#{id}.json")
+ perform_post("/#{API_VERSION}/direct_messages/destroy/#{id}.json")
end
def friendship_create(id, follow=false)
body = {}
body.merge!(:follow => follow) if follow
- perform_post("/friendships/create/#{id}.json", :body => body)
+ perform_post("/#{API_VERSION}/friendships/create/#{id}.json", :body => body)
end
def friendship_destroy(id)
- perform_post("/friendships/destroy/#{id}.json")
+ perform_post("/#{API_VERSION}/friendships/destroy/#{id}.json")
end
def friendship_exists?(a, b)
- perform_get("/friendships/exists.json", :query => {:user_a => a, :user_b => b})
+ perform_get("/#{API_VERSION}/friendships/exists.json", :query => {:user_a => a, :user_b => b})
end
def friendship_show(query)
- perform_get("/friendships/show.json", :query => query)
+ perform_get("/#{API_VERSION}/friendships/show.json", :query => query)
end
# Options: id, user_id, screen_name
def friend_ids(query={})
- perform_get("/friends/ids.json", :query => query, :mash => false)
+ perform_get("/#{API_VERSION}/friends/ids.json", :query => query, :mash => false)
end
# Options: id, user_id, screen_name
def follower_ids(query={})
- perform_get("/followers/ids.json", :query => query, :mash => false)
+ perform_get("/#{API_VERSION}/followers/ids.json", :query => query, :mash => false)
end
def verify_credentials
- perform_get("/account/verify_credentials.json")
+ perform_get("/#{API_VERSION}/account/verify_credentials.json")
end
# Device must be sms, im or none
def update_delivery_device(device)
- perform_post('/account/update_delivery_device.json', :body => {:device => device})
+ perform_post("/#{API_VERSION}/account/update_delivery_device.json", :body => {:device => device})
end
# One or more of the following must be present:
# profile_background_color, profile_text_color, profile_link_color,
# profile_sidebar_fill_color, profile_sidebar_border_color
def update_profile_colors(colors={})
- perform_post('/account/update_profile_colors.json', :body => colors)
+ perform_post("/#{API_VERSION}/account/update_profile_colors.json", :body => colors)
end
# file should respond to #read and #path
def update_profile_image(file)
- perform_post('/account/update_profile_image.json', build_multipart_bodies(:image => file))
+ perform_post("/#{API_VERSION}/account/update_profile_image.json", build_multipart_bodies(:image => file))
end
# file should respond to #read and #path
def update_profile_background(file, tile = false)
- perform_post('/account/update_profile_background_image.json', build_multipart_bodies(:image => file).merge(:tile => tile))
+ perform_post("/#{API_VERSION}/account/update_profile_background_image.json", build_multipart_bodies(:image => file).merge(:tile => tile))
end
def rate_limit_status
- perform_get('/account/rate_limit_status.json')
+ perform_get("/#{API_VERSION}/account/rate_limit_status.json")
end
# One or more of the following must be present:
# name, email, url, location, description
def update_profile(body={})
- perform_post('/account/update_profile.json', :body => body)
+ perform_post("/#{API_VERSION}/account/update_profile.json", :body => body)
end
# Options: id, page
def favorites(query={})
- perform_get('/favorites.json', :query => query)
+ perform_get("/#{API_VERSION}/favorites.json", :query => query)
end
def favorite_create(id)
- perform_post("/favorites/create/#{id}.json")
+ perform_post("/#{API_VERSION}/favorites/create/#{id}.json")
end
def favorite_destroy(id)
- perform_post("/favorites/destroy/#{id}.json")
+ perform_post("/#{API_VERSION}/favorites/destroy/#{id}.json")
end
def enable_notifications(id)
- perform_post("/notifications/follow/#{id}.json")
+ perform_post("/#{API_VERSION}/notifications/follow/#{id}.json")
end
def disable_notifications(id)
- perform_post("/notifications/leave/#{id}.json")
+ perform_post("/#{API_VERSION}/notifications/leave/#{id}.json")
end
def block(id)
- perform_post("/blocks/create/#{id}.json")
+ perform_post("/#{API_VERSION}/blocks/create/#{id}.json")
end
def unblock(id)
- perform_post("/blocks/destroy/#{id}.json")
+ perform_post("/#{API_VERSION}/blocks/destroy/#{id}.json")
end
def help
- perform_get('/help/test.json')
+ perform_get("/#{API_VERSION}/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))
+ perform_post("/#{API_VERSION}/#{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)
+ perform_put("/#{API_VERSION}/#{list_owner_username}/lists/#{slug}.json", :body => options)
end
def list_delete(list_owner_username, slug)
- perform_delete("/#{list_owner_username}/lists/#{slug}.json")
+ perform_delete("/#{API_VERSION}/#{list_owner_username}/lists/#{slug}.json")
end
def lists(list_owner_username=nil)
- path = "/#{list_owner_username}" if list_owner_username
- path += "/lists.json"
+ if list_owner_username
+ path = "/#{API_VERSION}/#{list_owner_username}/lists.json"
+ else
+ path = "/#{API_VERSION}/lists.json"
+ end
perform_get(path)
end
def list(list_owner_username, slug)
- perform_get("/#{list_owner_username}/lists/#{slug}.json")
+ perform_get("/#{API_VERSION}/#{list_owner_username}/lists/#{slug}.json")
end
# :per_page = max number of statues to get at once
# :page = which page of tweets you wish to get
def list_timeline(list_owner_username, slug, query = {})
- perform_get("/#{list_owner_username}/lists/#{slug}/statuses.json", :query => query)
+ perform_get("/#{API_VERSION}/#{list_owner_username}/lists/#{slug}/statuses.json", :query => query)
end
def memberships(list_owner_username, query={})
- perform_get("/#{list_owner_username}/lists/memberships.json", :query => query)
+ perform_get("/#{API_VERSION}/#{list_owner_username}/lists/memberships.json", :query => query)
end
def list_members(list_owner_username, slug, cursor = nil)
- path = "/#{list_owner_username}/#{slug}/members.json"
+ path = "/#{API_VERSION}/#{list_owner_username}/#{slug}/members.json"
path += "?cursor=#{cursor}" if cursor
perform_get(path)
end
def list_add_member(list_owner_username, slug, new_id)
- perform_post("/#{list_owner_username}/#{slug}/members.json", :body => {:id => new_id})
+ perform_post("/#{API_VERSION}/#{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", :query => {:id => id})
+ perform_delete("/#{API_VERSION}/#{list_owner_username}/#{slug}/members.json", :query => {:id => id})
end
def is_list_member?(list_owner_username, slug, id)
- perform_get("/#{list_owner_username}/#{slug}/members/#{id}.json").error.nil?
+ perform_get("/#{API_VERSION}/#{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")
+ perform_get("/#{API_VERSION}/#{list_owner_username}/#{slug}/subscribers.json")
end
def list_subscribe(list_owner_username, slug)
- perform_post("/#{list_owner_username}/#{slug}/subscribers.json")
+ perform_post("/#{API_VERSION}/#{list_owner_username}/#{slug}/subscribers.json")
end
def list_unsubscribe(list_owner_username, slug)
- perform_delete("/#{list_owner_username}/#{slug}/subscribers.json")
+ perform_delete("/#{API_VERSION}/#{list_owner_username}/#{slug}/subscribers.json")
end
def list_subscriptions(list_owner_username)
- perform_get("/#{list_owner_username}/lists/subscriptions.json")
+ perform_get("/#{API_VERSION}/#{list_owner_username}/lists/subscriptions.json")
end
-
def blocked_ids
- perform_get("/blocks/blocking/ids.json", :mash => false)
+ perform_get("/#{API_VERSION}/blocks/blocking/ids.json", :mash => false)
end
-
+
def blocking(options={})
- perform_get("/blocks/blocking.json", options)
+ perform_get("/#{API_VERSION}/blocks/blocking.json", options)
end
-
-
+
protected
+
def self.mime_type(file)
case
when file =~ /\.jpg/ then 'image/jpg'
@@ -296,7 +300,7 @@ def self.mime_type(file)
end
end
def mime_type(f) self.class.mime_type(f) end
-
+
CRLF = "\r\n"
def self.build_multipart_bodies(parts)
boundary = Time.now.to_i.to_s(16)
@@ -319,23 +323,25 @@ def self.build_multipart_bodies(parts)
:headers => {"Content-Type" => "multipart/form-data; boundary=#{boundary}"}
}
end
+
def build_multipart_bodies(parts) self.class.build_multipart_bodies(parts) end
private
- def perform_get(path, options={})
- Twitter::Request.get(self, path, options)
- end
- def perform_post(path, options={})
- Twitter::Request.post(self, path, options)
- end
+ def perform_get(path, options={})
+ Twitter::Request.get(self, path, options)
+ end
- def perform_put(path, options={})
- Twitter::Request.put(self, path, options)
- end
+ def perform_post(path, options={})
+ Twitter::Request.post(self, path, options)
+ end
- def perform_delete(path, options={})
- Twitter::Request.delete(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
end
end
View
80 test/twitter/base_test.rb
@@ -28,7 +28,7 @@ class BaseTest < Test::Unit::TestCase
context "hitting the api" do
should "be able to get home timeline" do
- stub_get('/statuses/home_timeline.json', 'home_timeline.json')
+ stub_get('/1/statuses/home_timeline.json', 'home_timeline.json')
timeline = @twitter.home_timeline
timeline.size.should == 20
first = timeline.first
@@ -40,7 +40,7 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to get friends timeline" do
- stub_get('/statuses/friends_timeline.json', 'friends_timeline.json')
+ stub_get('/1/statuses/friends_timeline.json', 'friends_timeline.json')
timeline = @twitter.friends_timeline
timeline.size.should == 20
first = timeline.first
@@ -52,7 +52,7 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to get user timeline" do
- stub_get('/statuses/user_timeline.json', 'user_timeline.json')
+ stub_get('/1/statuses/user_timeline.json', 'user_timeline.json')
timeline = @twitter.user_timeline
timeline.size.should == 20
first = timeline.first
@@ -61,21 +61,21 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to get a status" do
- stub_get('/statuses/show/1441588944.json', 'status.json')
+ stub_get('/1/statuses/show/1441588944.json', 'status.json')
status = @twitter.status(1441588944)
status.user.name.should == 'John Nunemaker'
status.id.should == 1441588944
end
should "be able to update status" do
- stub_post('/statuses/update.json', 'status.json')
+ stub_post('/1/statuses/update.json', 'status.json')
status = @twitter.update('Rob Dyrdek is the funniest man alive. That is all.')
status.user.name.should == 'John Nunemaker'
status.text.should == 'Rob Dyrdek is the funniest man alive. That is all.'
end
should "be able to retweet a status" do
- stub_post('/statuses/retweet/6235127466.json', 'retweet.json')
+ stub_post('/1/statuses/retweet/6235127466.json', 'retweet.json')
status = @twitter.retweet(6235127466)
status.user.name.should == 'Michael D. Ivey'
status.text.should == "RT @jstetser: I'm not actually awake. My mind's on autopilot for food and I managed to take a detour along the way."
@@ -84,7 +84,7 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to get retweets of a status" do
- stub_get('/statuses/retweets/6192831130.json', 'retweets.json')
+ stub_get('/1/statuses/retweets/6192831130.json', 'retweets.json')
retweets = @twitter.retweets(6192831130)
retweets.size.should == 6
first = retweets.first
@@ -93,7 +93,7 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to get mentions" do
- stub_get('/statuses/mentions.json', 'mentions.json')
+ stub_get('/1/statuses/mentions.json', 'mentions.json')
mentions = @twitter.mentions
mentions.size.should == 19
first = mentions.first
@@ -102,7 +102,7 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to get retweets by me" do
- stub_get('/statuses/retweeted_by_me.json', 'retweeted_by_me.json')
+ stub_get('/1/statuses/retweeted_by_me.json', 'retweeted_by_me.json')
retweeted_by_me = @twitter.retweeted_by_me
retweeted_by_me.size.should == 20
first = retweeted_by_me.first.retweeted_status
@@ -111,7 +111,7 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to get retweets to me" do
- stub_get('/statuses/retweeted_to_me.json', 'retweeted_to_me.json')
+ stub_get('/1/statuses/retweeted_to_me.json', 'retweeted_to_me.json')
retweeted_to_me = @twitter.retweeted_to_me
retweeted_to_me.size.should == 20
first = retweeted_to_me.first.retweeted_status
@@ -120,7 +120,7 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to get retweets of me" do
- stub_get('/statuses/retweets_of_me.json', 'retweets_of_me.json')
+ stub_get('/1/statuses/retweets_of_me.json', 'retweets_of_me.json')
retweets_of_me = @twitter.retweets_of_me
retweets_of_me.size.should == 11
first = retweets_of_me.first
@@ -129,62 +129,62 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to get follower ids" do
- stub_get('/followers/ids.json', 'follower_ids.json')
+ stub_get('/1/followers/ids.json', 'follower_ids.json')
follower_ids = @twitter.follower_ids
follower_ids.size.should == 1252
follower_ids.first.should == 613
end
should "be able to get friend ids" do
- stub_get('/friends/ids.json', 'friend_ids.json')
+ stub_get('/1/friends/ids.json', 'friend_ids.json')
friend_ids = @twitter.friend_ids
friend_ids.size.should == 161
friend_ids.first.should == 15323
end
should "correctly hash statuses" do
- stub_get('/statuses/friends_timeline.json', 'friends_timeline.json')
+ stub_get('/1/statuses/friends_timeline.json', 'friends_timeline.json')
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')
+ stub_get("/1/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')
+ stub_get("/1/users/search.json?q=Wynn%20Netherland", 'people_search.json')
people = @twitter.user_search('Wynn Netherland')
people.first.screen_name.should == 'pengwynn'
end
should "be able to get followers' stauses" do
- stub_get('/statuses/followers.json', 'followers.json')
+ stub_get('/1/statuses/followers.json', 'followers.json')
followers = @twitter.followers
followers.should == @twitter.followers
end
should "be able to get blocked users' IDs" do
- stub_get('/blocks/blocking/ids.json', 'ids.json')
+ stub_get('/1/blocks/blocking/ids.json', 'ids.json')
blocked = @twitter.blocked_ids
blocked.should == @twitter.blocked_ids
end
should "be able to get an array of blocked users" do
- stub_get('/blocks/blocking.json', 'blocking.json')
+ stub_get('/1/blocks/blocking.json', 'blocking.json')
blocked = @twitter.blocking
blocked.last.screen_name.should == "euciavkvyplx"
end
should "upload a profile image" do
- stub_post('/account/update_profile_image.json', 'update_profile_image.json')
+ stub_post('/1/account/update_profile_image.json', 'update_profile_image.json')
user = @twitter.update_profile_image(File.new(sample_image('sample-image.png')))
user.name.should == 'John Nunemaker' # update_profile_image responds with the user
end
should "upload a background image" do
- stub_post('/account/update_profile_background_image.json', 'update_profile_background_image.json')
+ stub_post('/1/account/update_profile_background_image.json', 'update_profile_background_image.json')
user = @twitter.update_profile_background(File.new(sample_image('sample-image.png')))
user.name.should == 'John Nunemaker' # update_profile_background responds with the user
end
@@ -193,71 +193,71 @@ class BaseTest < Test::Unit::TestCase
context "when using lists" do
should "be able to create a new list" do
- stub_post('/pengwynn/lists.json', 'list.json')
+ stub_post('/1/pengwynn/lists.json', 'list.json')
list = @twitter.list_create('pengwynn', {:name => 'Rubyists'})
list.name.should == 'Rubyists'
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')
+ stub_put('/1/pengwynn/lists/rubyists.json', 'list.json')
list = @twitter.list_update('pengwynn', 'rubyists', {:name => 'Rubyists'})
list.name.should == 'Rubyists'
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')
+ stub_delete('/1/pengwynn/lists/rubyists.json', 'list.json')
list = @twitter.list_delete('pengwynn', 'rubyists')
list.name.should == 'Rubyists'
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')
+ stub_get('/1/pengwynn/lists/memberships.json', 'memberships.json')
lists = @twitter.memberships('pengwynn').lists
lists.size.should == 16
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('/pengwynn/lists.json', 'lists.json')
+ stub_get('/1/pengwynn/lists.json', 'lists.json')
lists = @twitter.lists('pengwynn').lists
lists.size.should == 1
lists.first.name.should == 'Rubyists'
lists.first.slug.should == 'rubyists'
end
should "be able to view list details" do
- stub_get('/pengwynn/lists/rubyists.json', 'list.json')
+ stub_get('/1/pengwynn/lists/rubyists.json', 'list.json')
list = @twitter.list('pengwynn', 'rubyists')
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')
+ stub_get('/1/pengwynn/lists/rubyists/statuses.json', 'list_statuses.json')
tweets = @twitter.list_timeline('pengwynn', 'rubyists')
tweets.size.should == 20
tweets.first.id.should == 5272535583
tweets.first.user.name.should == 'John Nunemaker'
end
should "be able to limit number of tweets in list timeline" do
- stub_get('/pengwynn/lists/rubyists/statuses.json?per_page=1', 'list_statuses_1_1.json')
+ stub_get('/1/pengwynn/lists/rubyists/statuses.json?per_page=1', 'list_statuses_1_1.json')
tweets = @twitter.list_timeline('pengwynn', 'rubyists', :per_page => 1)
tweets.size.should == 1
tweets.first.id.should == 5272535583
tweets.first.user.name.should == 'John Nunemaker'
end
should "be able to paginate through the timeline" do
- stub_get('/pengwynn/lists/rubyists/statuses.json?page=1&per_page=1', 'list_statuses_1_1.json')
- stub_get('/pengwynn/lists/rubyists/statuses.json?page=2&per_page=1', 'list_statuses_2_1.json')
+ stub_get('/1/pengwynn/lists/rubyists/statuses.json?page=1&per_page=1', 'list_statuses_1_1.json')
+ stub_get('/1/pengwynn/lists/rubyists/statuses.json?page=2&per_page=1', 'list_statuses_2_1.json')
tweets = @twitter.list_timeline('pengwynn', 'rubyists', { :page => 1, :per_page => 1 })
tweets.size.should == 1
tweets.first.id.should == 5272535583
@@ -269,52 +269,52 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to view list members" do
- stub_get('/pengwynn/rubyists/members.json', 'list_users.json')
+ stub_get('/1/pengwynn/rubyists/members.json', 'list_users.json')
members = @twitter.list_members('pengwynn', 'rubyists').users
members.size.should == 2
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')
+ stub_post('/1/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?id=4243', 'user.json')
+ stub_delete('/1/pengwynn/rubyists/members.json?id=4243', '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')
+ stub_get('/1/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')
+ stub_get('/1/pengwynn/rubyists/subscribers.json', 'list_users.json')
subscribers = @twitter.list_subscribers('pengwynn', 'rubyists').users
subscribers.size.should == 2
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')
+ stub_post('/1/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')
+ stub_delete('/1/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')
+ stub_get('/1/pengwynn/lists/subscriptions.json', 'list_subscriptions.json')
subscriptions = @twitter.list_subscriptions('pengwynn').lists
subscriptions.size.should == 1
subscriptions.first.full_name.should == '@chriseppstein/sass-users'
@@ -330,7 +330,7 @@ class BaseTest < Test::Unit::TestCase
end
should "get the home timeline" do
- stub_get('http://wynn%40example.com:mypass@tumblr.com/statuses/home_timeline.json', 'home_timeline.json')
+ stub_get('http://wynn%40example.com:mypass@tumblr.com/1/statuses/home_timeline.json', 'home_timeline.json')
timeline = @twitter.home_timeline
timeline.size.should == 20
end

0 comments on commit 69d4df5

Please sign in to comment.
Something went wrong with that request. Please try again.