Skip to content
Browse files

Specify Twitter API version for all REST API calls

  • Loading branch information...
1 parent 108019e commit 76b1fa31588bbc20166464313027f75e3771e385 @sferik committed Sep 23, 2010
View
11 lib/twitter.rb
@@ -6,7 +6,6 @@
module Twitter
include HTTParty
- API_VERSION = "1".freeze
class TwitterError < StandardError
attr_reader :data
@@ -26,13 +25,21 @@ class InformTwitter < StandardError; end
class NotFound < StandardError; end
def self.api_endpoint
- @api_endpoint ||= "api.twitter.com/#{API_VERSION}"
+ @api_endpoint ||= "api.twitter.com/#{self.api_version}"
end
def self.api_endpoint=(value)
@api_endpoint = value
end
+ def self.api_version
+ @api_version ||= "1"
+ end
+
+ def self.api_version=(value)
+ @api_version = value
+ end
+
def self.firehose(options = {})
perform_get("/statuses/public_timeline.json")
end
View
134 lib/twitter/base.rb
@@ -12,87 +12,87 @@ def initialize(client)
# Options: since_id, max_id, count, page
def home_timeline(query={})
- perform_get("/statuses/home_timeline.json", :query => query)
+ perform_get("/#{Twitter.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("/#{Twitter.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("/#{Twitter.api_version}/statuses/user_timeline.json", :query => query)
end
def status(id)
- perform_get("/statuses/show/#{id}.json")
+ perform_get("/#{Twitter.api_version}/statuses/show/#{id}.json")
end
# Options: count
def retweets(id, query={})
- perform_get("/statuses/retweets/#{id}.json", :query => query)
+ perform_get("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.api_version}/statuses/retweets_of_me.json", :query => query)
end
# options: count, page, ids_only
def retweeters_of(id, options={})
ids_only = !!(options.delete(:ids_only))
- perform_get("/statuses/#{id}/retweeted_by#{"/ids" if ids_only}.json", :query => options)
+ perform_get("/#{Twitter.api_version}/statuses/#{id}/retweeted_by#{"/ids" if ids_only}.json", :query => options)
end
def status_destroy(id)
- perform_post("/statuses/destroy/#{id}.json")
+ perform_post("/#{Twitter.api_version}/statuses/destroy/#{id}.json")
end
def retweet(id)
- perform_post("/statuses/retweet/#{id}.json")
+ perform_post("/#{Twitter.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("/#{Twitter.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("/#{Twitter.api_version}/statuses/followers.json", :query => query)
end
def user(id, query={})
- perform_get("/users/show/#{id}.json", :query => query)
+ perform_get("/#{Twitter.api_version}/users/show/#{id}.json", :query => query)
end
def users(*ids_or_usernames)
@@ -107,226 +107,226 @@ def users(*ids_or_usernames)
query = {}
query[:user_id] = ids.join(",") unless ids.empty?
query[:screen_name] = usernames.join(",") unless usernames.empty?
- perform_get("/users/lookup.json", :query => query)
+ perform_get("/#{Twitter.api_version}/users/lookup.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.api_version}/friendships/create/#{id}.json", :body => body)
end
def friendship_destroy(id)
- perform_post("/friendships/destroy/#{id}.json")
+ perform_post("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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)
+ perform_get("/#{Twitter.api_version}/friends/ids.json", :query => query)
end
# Options: id, user_id, screen_name
def follower_ids(query={})
- perform_get("/followers/ids.json", :query => query)
+ perform_get("/#{Twitter.api_version}/followers/ids.json", :query => query)
end
def verify_credentials
- perform_get("/account/verify_credentials.json")
+ perform_get("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.api_version}/account/update_profile.json", :body => body)
end
# Options: id, page
def favorites(query={})
- perform_get("/favorites.json", :query => query)
+ perform_get("/#{Twitter.api_version}/favorites.json", :query => query)
end
def favorite_create(id)
- perform_post("/favorites/create/#{id}.json")
+ perform_post("/#{Twitter.api_version}/favorites/create/#{id}.json")
end
def favorite_destroy(id)
- perform_post("/favorites/destroy/#{id}.json")
+ perform_post("/#{Twitter.api_version}/favorites/destroy/#{id}.json")
end
def enable_notifications(id)
- perform_post("/notifications/follow/#{id}.json")
+ perform_post("/#{Twitter.api_version}/notifications/follow/#{id}.json")
end
def disable_notifications(id)
- perform_post("/notifications/leave/#{id}.json")
+ perform_post("/#{Twitter.api_version}/notifications/leave/#{id}.json")
end
def block(id)
- perform_post("/blocks/create/#{id}.json")
+ perform_post("/#{Twitter.api_version}/blocks/create/#{id}.json")
end
def unblock(id)
- perform_post("/blocks/destroy/#{id}.json")
+ perform_post("/#{Twitter.api_version}/blocks/destroy/#{id}.json")
end
# When reporting a user for spam, specify one or more of id, screen_name, or user_id
def report_spam(options)
- perform_post("/report_spam.json", :body => options)
+ perform_post("/#{Twitter.api_version}/report_spam.json", :body => options)
end
def help
- perform_get("/help/test.json")
+ perform_get("/#{Twitter.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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.api_version}/#{list_owner_username}/lists/#{slug}.json")
end
def lists(list_owner_username = nil, query = {})
path = case list_owner_username
when nil, Hash
query = list_owner_username
- "/lists.json"
+ "/#{Twitter.api_version}/lists.json"
else
- "/#{list_owner_username}/lists.json"
+ "/#{Twitter.api_version}/#{list_owner_username}/lists.json"
end
perform_get(path, :query => query)
end
def list(list_owner_username, slug)
- perform_get("/#{list_owner_username}/lists/#{slug}.json")
+ perform_get("/#{Twitter.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("/#{Twitter.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("/#{Twitter.api_version}/#{list_owner_username}/lists/memberships.json", :query => query)
end
def subscriptions(list_owner_username, query = {})
- perform_get("/#{list_owner_username}/lists/subscriptions.json", :query => query)
+ perform_get("/#{Twitter.api_version}/#{list_owner_username}/lists/subscriptions.json", :query => query)
end
def list_members(list_owner_username, slug, query = {})
- perform_get("/#{list_owner_username}/#{slug}/members.json", :query => query)
+ perform_get("/#{Twitter.api_version}/#{list_owner_username}/#{slug}/members.json", :query => query)
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("/#{Twitter.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("/#{Twitter.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("/#{Twitter.api_version}/#{list_owner_username}/#{slug}/members/#{id}.json").error.nil?
end
def list_subscribers(list_owner_username, slug, query={})
- perform_get("/#{list_owner_username}/#{slug}/subscribers.json", :body => {:query => query})
+ perform_get("/#{Twitter.api_version}/#{list_owner_username}/#{slug}/subscribers.json", :body => {:query => query})
end
def list_subscribe(list_owner_username, slug)
- perform_post("/#{list_owner_username}/#{slug}/subscribers.json")
+ perform_post("/#{Twitter.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("/#{Twitter.api_version}/#{list_owner_username}/#{slug}/subscribers.json")
end
def blocked_ids
- perform_get("/blocks/blocking/ids.json", :mash => false)
+ perform_get("/#{Twitter.api_version}/blocks/blocking/ids.json", :mash => false)
end
def blocking(options={})
- perform_get("/blocks/blocking.json", options)
+ perform_get("/#{Twitter.api_version}/blocks/blocking.json", options)
end
def saved_searches
- perform_get("/saved_searches.json")
+ perform_get("/#{Twitter.api_version}/saved_searches.json")
end
def saved_search(id)
- perform_get("/saved_searches/show/#{id}.json")
+ perform_get("/#{Twitter.api_version}/saved_searches/show/#{id}.json")
end
def saved_search_create(query)
- perform_post("/saved_searches/create.json", :body => {:query => query})
+ perform_post("/#{Twitter.api_version}/saved_searches/create.json", :body => {:query => query})
end
def saved_search_destroy(id)
- perform_delete("/saved_searches/destroy/#{id}.json")
+ perform_delete("/#{Twitter.api_version}/saved_searches/destroy/#{id}.json")
end
protected
View
11 lib/twitter/geo.rb
@@ -1,11 +1,11 @@
module Twitter
class Geo
include HTTParty
- base_uri "api.twitter.com/#{API_VERSION}/geo"
+ base_uri "api.twitter.com/#{Twitter.api_version}/geo"
format :json
def self.place(place_id, query={})
- Twitter.mash(get("/id/#{place_id}.json", :query => query))
+ Twitter.mash(Twitter.parse(get("/id/#{place_id}.json", :query => query)))
end
def self.search(query={})
@@ -18,8 +18,9 @@ def self.reverse_geocode(query={})
private
- def self.mashup(response)
- response["result"].values.flatten.map{|t| Twitter.mash(t)}
- end
+ def self.mashup(response)
+ Twitter.parse(response)["result"].values.flatten.map{|t| Twitter.mash(t)}
+ end
+
end
end
View
19 lib/twitter/local_trends.rb
@@ -1,29 +1,22 @@
module Twitter
class LocalTrends
include HTTParty
- base_uri "api.twitter.com/#{API_VERSION}/trends"
+ base_uri "api.twitter.com/#{Twitter.api_version}/trends"
format :json
def self.available(query={})
- before_test(query)
query.delete(:api_endpoint)
- get("/available.json", :query => query).map{|location| Twitter.mash(location)}
+ mashup(get("/available.json", :query => query))
end
- def self.for_location(woeid,options = {})
- before_test(options)
- get("/#{woeid}.json").map{|location| Twitter.mash(location)}
+ def self.for_location(woeid, options = {})
+ mashup(get("/#{woeid}.json"))
end
private
- def self.before_test(options)
- configure_base_uri(options)
- end
-
- def self.configure_base_uri(options)
- new_base_url = options[:api_endpoint]
- base_uri "#{new_base_url}/#{API_VERSION}/trends" if new_base_url
+ def self.mashup(response)
+ Twitter.parse(response).map{|t| Twitter.mash(t)}
end
end
View
8 lib/twitter/trends.rb
@@ -6,7 +6,7 @@ class Trends
format :json
def self.api_endpoint
- @api_endpoint ||= "api.twitter.com/#{API_VERSION}/trends"
+ @api_endpoint ||= "api.twitter.com/#{Twitter.api_version}/trends"
end
def self.api_endpoint=(value)
@@ -35,9 +35,9 @@ def self.available(query={})
LocalTrends.available(query)
end
- def self.for_location(woeid,options={})
+ def self.for_location(woeid, options={})
# Checking for api_endpoint in local_trends
- LocalTrends.for_location(woeid,options)
+ LocalTrends.for_location(woeid, options)
end
private
@@ -48,7 +48,7 @@ def self.get(*args)
end
def self.mashup(response)
- response["trends"].values.flatten.map{|t| Twitter.mash(t)}
+ Twitter.parse(response)["trends"].values.flatten.map{|t| Twitter.mash(t)}
end
end
View
2 test/test_helper.rb
@@ -24,7 +24,7 @@ def fixture_file(filename)
end
def twitter_url(url)
- url =~ /^http/ ? url : "http://api.twitter.com:80#{url}"
+ url =~ /^http/ ? url : "http://api.twitter.com#{url}"
end
def stub_get(url, filename, status=nil)
View
132 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,130 +129,130 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to get users who retweeted a tweet" do
- stub_get("/statuses/9021932472/retweeted_by.json", "retweeters_of_tweet.json")
+ stub_get("/1/statuses/9021932472/retweeted_by.json", "retweeters_of_tweet.json")
retweeters = @twitter.retweeters_of("9021932472")
retweeters.size.should == 4
first = retweeters.first
first.screen_name.should == "bryanl"
end
should "be able to get ids of users who retweeted a tweet" do
- stub_get("/statuses/9021932472/retweeted_by/ids.json", "ids.json")
+ stub_get("/1/statuses/9021932472/retweeted_by/ids.json", "ids.json")
retweeters = @twitter.retweeters_of("9021932472", :ids_only => true)
retweeters.first.should == 61940910
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 test whether a friendship exists" do
- stub_get("/friendships/exists.json?user_a=pengwynn&user_b=sferik", "friendship_exists.json")
+ stub_get("/1/friendships/exists.json?user_a=pengwynn&user_b=sferik", "friendship_exists.json")
@twitter.friendship_exists?("pengwynn", "sferik").should == true
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 lookup a user" do
- stub_get("/users/show/4243.json", "user.json")
+ stub_get("/1/users/show/4243.json", "user.json")
user = @twitter.user(4243)
user.screen_name.should == "jnunemaker"
end
should "be able to lookup users in bulk" do
- stub_get("/users/lookup.json?screen_name=sferik&user_id=59593,774010", "users.json")
+ stub_get("/1/users/lookup.json?screen_name=sferik&user_id=59593,774010", "users.json")
users = @twitter.users("sferik", 59593, 774010)
users.count.should == 3
- usernames = users.map{|u| u['screen_name']}
- usernames.should include 'sferik'
- usernames.should include 'jm3'
- usernames.should include 'jamiew'
+ usernames = users.map{|u| u["screen_name"]}
+ usernames.should include "sferik"
+ usernames.should include "jm3"
+ usernames.should include "jamiew"
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 "report a spammer" do
- stub_post("/report_spam.json", "report_spam.json")
- spammer = @twitter.report_spam(:screen_name => 'lucaasvaz00')
+ stub_post("/1/report_spam.json", "report_spam.json")
+ spammer = @twitter.report_spam(:screen_name => "lucaasvaz00")
spammer.screen_name.should == "lucaasvaz00"
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
end
context "when using saved searches" do
should "be able to retrieve my saved searches" do
- stub_get('/saved_searches.json', 'saved_searches.json')
+ stub_get("/1/saved_searches.json", "saved_searches.json")
searches = @twitter.saved_searches
searches[0].query.should == "great danes"
searches[1].query.should == "rubyconf OR railsconf"
end
should "be able to retrieve a saved search by id" do
- stub_get('/saved_searches/show/7095598.json', 'saved_search.json')
+ stub_get("/1/saved_searches/show/7095598.json", "saved_search.json")
search = @twitter.saved_search(7095598)
search.query.should == "great danes"
end
should "be able to create a saved search" do
- stub_post('/saved_searches/create.json', 'saved_search.json')
- search = @twitter.saved_search_create('great danes')
+ stub_post("/1/saved_searches/create.json", "saved_search.json")
+ search = @twitter.saved_search_create("great danes")
search.query.should == "great danes"
end
should "be able to delete a saved search" do
- stub_delete('/saved_searches/destroy/7095598.json', 'saved_search.json')
+ stub_delete("/1/saved_searches/destroy/7095598.json", "saved_search.json")
search = @twitter.saved_search_destroy(7095598)
search.query.should == "great danes"
end
@@ -261,95 +261,95 @@ 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 the user owned lists without passing the username" do
- stub_get('/lists.json', 'lists.json')
+ stub_get("/1/lists.json", "lists.json")
lists = @twitter.lists().lists
lists.size.should == 1
- lists.first.name.should == 'Rubyists'
- lists.first.slug.should == 'rubyists'
+ lists.first.name.should == "Rubyists"
+ lists.first.slug.should == "rubyists"
end
should "be able to view lists for the authenticated user by passing in a cursor" do
- stub_get('/pengwynn/lists.json?cursor=-1', 'lists.json')
- lists = @twitter.lists('pengwynn', :cursor => -1).lists
+ stub_get("/1/pengwynn/lists.json?cursor=-1", "lists.json")
+ lists = @twitter.lists("pengwynn", :cursor => -1).lists
lists.size.should == 1
- lists.first.name.should == 'Rubyists'
- lists.first.slug.should == 'rubyists'
+ lists.first.name.should == "Rubyists"
+ lists.first.slug.should == "rubyists"
end
should "be able to view the user owned lists without passing the username and passing in a cursor" do
- stub_get('/lists.json?cursor=-1', 'lists.json')
+ stub_get("/1/lists.json?cursor=-1", "lists.json")
lists = @twitter.lists(:cursor => -1).lists
lists.size.should == 1
- lists.first.name.should == 'Rubyists'
- lists.first.slug.should == 'rubyists'
+ 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
@@ -361,53 +361,53 @@ 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')
- subscriptions = @twitter.subscriptions('pengwynn').lists
+ stub_get("/1/pengwynn/lists/subscriptions.json", "list_subscriptions.json")
+ subscriptions = @twitter.subscriptions("pengwynn").lists
subscriptions.size.should == 1
subscriptions.first.full_name.should == "@chriseppstein/sass-users"
subscriptions.first.slug.should == "sass-users"
View
4 test/twitter/geo_test.rb
@@ -18,7 +18,7 @@ class GeoTest < Test::Unit::TestCase
context "Geographic search" do
should "work" do
- stub_get 'http://api.twitter.com:80/1/geo/search.json?lat=35.061161&long=-80.854568', 'geo_search.json'
+ stub_get 'http://api.twitter.com/1/geo/search.json?lat=35.061161&long=-80.854568', 'geo_search.json'
places = Geo.search(:lat => 35.061161, :long => -80.854568)
places.size.should == 3
places[0].full_name.should eql('Ballantyne West, Charlotte')
@@ -49,7 +49,7 @@ class GeoTest < Test::Unit::TestCase
context "Geographic reverse_geocode" do
should "work" do
- stub_get 'http://api.twitter.com:80/1/geo/reverse_geocode.json?lat=35.061161&long=-80.854568', 'geo_reverse_geocode.json'
+ stub_get 'http://api.twitter.com/1/geo/reverse_geocode.json?lat=35.061161&long=-80.854568', 'geo_reverse_geocode.json'
places = Geo.reverse_geocode(:lat => 35.061161, :long => -80.854568)
places.size.should == 4
places[0].full_name.should eql('Ballantyne West, Charlotte')
View
20 test/twitter/request_test.rb
@@ -138,63 +138,63 @@ class RequestTest < Test::Unit::TestCase
end
should "not raise error for 200" do
- stub_get('http://api.twitter.com:80/foo', '', ['200'])
+ stub_get('http://api.twitter.com/foo', '', ['200'])
lambda {
Twitter::Request.get(@client, '/foo')
}.should_not raise_error
end
should "not raise error for 304" do
- stub_get('http://api.twitter.com:80/foo', '', ['304'])
+ stub_get('http://api.twitter.com/foo', '', ['304'])
lambda {
Twitter::Request.get(@client, '/foo')
}.should_not raise_error
end
should "raise RateLimitExceeded for 400" do
- stub_get('http://api.twitter.com:80/foo', 'rate_limit_exceeded.json', ['400'])
+ stub_get('http://api.twitter.com/foo', 'rate_limit_exceeded.json', ['400'])
lambda {
Twitter::Request.get(@client, '/foo')
}.should raise_error(Twitter::RateLimitExceeded)
end
should "raise Unauthorized for 401" do
- stub_get('http://api.twitter.com:80/foo', '', ['401'])
+ stub_get('http://api.twitter.com/foo', '', ['401'])
lambda {
Twitter::Request.get(@client, '/foo')
}.should raise_error(Twitter::Unauthorized)
end
should "raise General for 403" do
- stub_get('http://api.twitter.com:80/foo', '', ['403'])
+ stub_get('http://api.twitter.com/foo', '', ['403'])
lambda {
Twitter::Request.get(@client, '/foo')
}.should raise_error(Twitter::General)
end
should "raise NotFound for 404" do
- stub_get('http://api.twitter.com:80/foo', '', ['404'])
+ stub_get('http://api.twitter.com/foo', '', ['404'])
lambda {
Twitter::Request.get(@client, '/foo')
}.should raise_error(Twitter::NotFound)
end
should "raise InformTwitter for 500" do
- stub_get('http://api.twitter.com:80/foo', '', ['500'])
+ stub_get('http://api.twitter.com/foo', '', ['500'])
lambda {
Twitter::Request.get(@client, '/foo')
}.should raise_error(Twitter::InformTwitter)
end
should "raise Unavailable for 502" do
- stub_get('http://api.twitter.com:80/foo', '', ['502'])
+ stub_get('http://api.twitter.com/foo', '', ['502'])
lambda {
Twitter::Request.get(@client, '/foo')
}.should raise_error(Twitter::Unavailable)
end
should "raise Unavailable for 503" do
- stub_get('http://api.twitter.com:80/foo', '', ['503'])
+ stub_get('http://api.twitter.com/foo', '', ['503'])
lambda {
Twitter::Request.get(@client, '/foo')
}.should raise_error(Twitter::Unavailable)
@@ -209,7 +209,7 @@ class RequestTest < Test::Unit::TestCase
end
should "not attempt to create mash of return object" do
- stub_get('http://api.twitter.com:80/foo', 'friend_ids.json')
+ stub_get('http://api.twitter.com/foo', 'friend_ids.json')
object = Twitter::Request.get(@client, '/foo', :mash => false)
object.class.should_not be(Hashie::Mash)
end
View
4 test/twitter/search_test.rb
@@ -149,7 +149,7 @@ class SearchTest < Test::Unit::TestCase
context "fetching" do
setup do
- stub_get('http://search.twitter.com:80/search.json?q=%40jnunemaker', 'search.json')
+ stub_get('http://search.twitter.com/search.json?q=%40jnunemaker', 'search.json')
@search = Twitter::Search.new('@jnunemaker')
@response = @search.fetch
end
@@ -186,7 +186,7 @@ class SearchTest < Test::Unit::TestCase
context "iterating over results" do
setup do
- stub_get('http://search.twitter.com:80/search.json?q=from%3Ajnunemaker', 'search_from_jnunemaker.json')
+ stub_get('http://search.twitter.com/search.json?q=from%3Ajnunemaker', 'search_from_jnunemaker.json')
@search.from('jnunemaker')
end
View
16 test/twitter/trends_test.rb
@@ -64,32 +64,32 @@ class TrendsTest < Test::Unit::TestCase
stub_get 'http://api.twitter.com/1/trends/weekly.json?', 'trends_weekly.json'
trends = Trends.weekly
trends.size.should == 210
- trends[0].name.should == 'Happy Mothers Day'
- trends[0].query.should == %Q(\"Happy Mothers Day\" OR \"Mothers Day\")
+ trends[0].name.should == "Grey's Anatomy"
+ trends[0].query.should == %Q(\"Grey's Anatomy\")
end
should "be able to exclude hastags" do
stub_get 'http://api.twitter.com/1/trends/weekly.json?exclude=hashtags', 'trends_weekly_exclude.json'
trends = Trends.weekly(:exclude => 'hashtags')
trends.size.should == 210
- trends[0].name.should == 'Happy Mothers Day'
- trends[0].query.should == %Q(\"Happy Mothers Day\" OR \"Mothers Day\")
+ trends[0].name.should == "Grey's Anatomy"
+ trends[0].query.should == %Q(\"Grey's Anatomy\")
end
should "be able to get for specific date (with date string)" do
stub_get 'http://api.twitter.com/1/trends/weekly.json?date=2009-05-01', 'trends_weekly_date.json'
trends = Trends.weekly(:date => '2009-05-01')
trends.size.should == 210
- trends[0].name.should == 'TGIF'
- trends[0].query.should == 'TGIF'
+ trends[0].name.should == "Swine Flu"
+ trends[0].query.should == %Q(\"Swine Flu\")
end
should "be able to get for specific date (with date object)" do
stub_get 'http://api.twitter.com/1/trends/weekly.json?date=2009-05-01', 'trends_weekly_date.json'
trends = Trends.weekly(:date => Date.new(2009, 5, 1))
trends.size.should == 210
- trends[0].name.should == 'TGIF'
- trends[0].query.should == 'TGIF'
+ trends[0].name.should == "Swine Flu"
+ trends[0].query.should == %Q(\"Swine Flu\")
end
end
View
28 test/twitter_test.rb
@@ -2,7 +2,7 @@
class TwitterTest < Test::Unit::TestCase
should "have firehose method for public timeline" do
- stub_get('http://api.twitter.com:80/1/statuses/public_timeline.json', 'firehose.json')
+ stub_get('http://api.twitter.com/1/statuses/public_timeline.json', 'firehose.json')
hose = Twitter.firehose
hose.size.should == 20
first = hose.first
@@ -11,61 +11,61 @@ class TwitterTest < Test::Unit::TestCase
end
should "have user method for unauthenticated calls to get a user's information" do
- stub_get('http://api.twitter.com:80/1/users/show/jnunemaker.json', 'user.json')
+ stub_get('http://api.twitter.com/1/users/show/jnunemaker.json', 'user.json')
user = Twitter.user('jnunemaker')
user.name.should == 'John Nunemaker'
user.description.should == 'Loves his wife, ruby, notre dame football and iu basketball'
end
should "have status method for unauthenticated calls to get a status" do
- stub_get('http://api.twitter.com:80/1/statuses/show/1533815199.json', 'status_show.json')
+ stub_get('http://api.twitter.com/1/statuses/show/1533815199.json', 'status_show.json')
status = Twitter.status(1533815199)
status.id.should == 1533815199
status.text.should == 'Eating some oatmeal and butterscotch cookies with a cold glass of milk for breakfast. Tasty!'
end
should "raise NotFound for unauthenticated calls to get a deleted or nonexistent status" do
- stub_get('http://api.twitter.com:80/1/statuses/show/1.json', 'not_found.json', 404)
+ stub_get('http://api.twitter.com/1/statuses/show/1.json', 'not_found.json', 404)
lambda {
Twitter.status(1)
}.should raise_error(Twitter::NotFound)
end
should "have a timeline method for unauthenticated calls to get a user's timeline" do
- stub_get('http://api.twitter.com:80/1/statuses/user_timeline/jnunemaker.json', 'user_timeline.json')
+ stub_get('http://api.twitter.com/1/statuses/user_timeline/jnunemaker.json', 'user_timeline.json')
statuses = Twitter.timeline('jnunemaker')
statuses.first.id.should == 1445986256
statuses.first.user.screen_name.should == 'jnunemaker'
end
should "raise Unauthorized for unauthenticated calls to get a protected user's timeline" do
- stub_get('http://api.twitter.com:80/1/statuses/user_timeline/protected.json', 'unauthorized.json', 401)
+ stub_get('http://api.twitter.com/1/statuses/user_timeline/protected.json', 'unauthorized.json', 401)
lambda {
Twitter.timeline('protected')
}.should raise_error(Twitter::Unauthorized)
end
should "have friend_ids method" do
- stub_get('http://api.twitter.com:80/1/friends/ids/jnunemaker.json', 'friend_ids.json')
+ stub_get('http://api.twitter.com/1/friends/ids/jnunemaker.json', 'friend_ids.json')
ids = Twitter.friend_ids('jnunemaker')
ids.size.should == 161
end
should "raise Unauthorized for unauthenticated calls to get a protected user's friend_ids" do
- stub_get('http://api.twitter.com:80/1/friends/ids/protected.json', 'unauthorized.json', 401)
+ stub_get('http://api.twitter.com/1/friends/ids/protected.json', 'unauthorized.json', 401)
lambda {
Twitter.friend_ids('protected')
}.should raise_error(Twitter::Unauthorized)
end
should "have follower_ids method" do
- stub_get('http://api.twitter.com:80/1/followers/ids/jnunemaker.json', 'follower_ids.json')
+ stub_get('http://api.twitter.com/1/followers/ids/jnunemaker.json', 'follower_ids.json')
ids = Twitter.follower_ids('jnunemaker')
ids.size.should == 1252
end
should "raise Unauthorized for unauthenticated calls to get a protected user's follower_ids" do
- stub_get('http://api.twitter.com:80/1/followers/ids/protected.json', 'unauthorized.json', 401)
+ stub_get('http://api.twitter.com/1/followers/ids/protected.json', 'unauthorized.json', 401)
lambda {
Twitter.follower_ids('protected')
}.should raise_error(Twitter::Unauthorized)
@@ -74,24 +74,24 @@ class TwitterTest < Test::Unit::TestCase
context "when using lists" do
should "be able to view list timeline" do
- stub_get('http://api.twitter.com:80/1/pengwynn/lists/rubyists/statuses.json', 'list_statuses.json')
+ stub_get('http://api.twitter.com/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('http://api.twitter.com:80/1/pengwynn/lists/rubyists/statuses.json?per_page=1', 'list_statuses_1_1.json')
+ stub_get('http://api.twitter.com/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('http://api.twitter.com:80/1/pengwynn/lists/rubyists/statuses.json?page=1&per_page=1', 'list_statuses_1_1.json')
- stub_get('http://api.twitter.com:80/1/pengwynn/lists/rubyists/statuses.json?page=2&per_page=1', 'list_statuses_2_1.json')
+ stub_get('http://api.twitter.com/1/pengwynn/lists/rubyists/statuses.json?page=1&per_page=1', 'list_statuses_1_1.json')
+ stub_get('http://api.twitter.com/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

0 comments on commit 76b1fa3

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