Skip to content

Commit

Permalink
Update all endpoints to Twitter API v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Sep 7, 2012
1 parent fc3a006 commit f55471a
Show file tree
Hide file tree
Showing 22 changed files with 651 additions and 651 deletions.
438 changes: 219 additions & 219 deletions lib/twitter/api.rb

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions spec/twitter/api/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

describe "#rate_limit_status" do
before do
stub_get("/1/account/rate_limit_status.json").
stub_get("/1.1/account/rate_limit_status.json").
to_return(:body => fixture("rate_limit_status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.rate_limit_status
a_get("/1/account/rate_limit_status.json").
a_get("/1.1/account/rate_limit_status.json").
should have_been_made
end
it "returns the remaining number of API requests available to the requesting user before the API limit is reached" do
Expand All @@ -25,12 +25,12 @@

describe "#verify_credentials" do
before do
stub_get("/1/account/verify_credentials.json").
stub_get("/1.1/account/verify_credentials.json").
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.verify_credentials
a_get("/1/account/verify_credentials.json").
a_get("/1.1/account/verify_credentials.json").
should have_been_made
end
it "returns the requesting user" do
Expand All @@ -42,12 +42,12 @@

describe "#end_session" do
before do
stub_post("/1/account/end_session.json").
stub_post("/1.1/account/end_session.json").
to_return(:body => fixture("end_session.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.end_session
a_post("/1/account/end_session.json").
a_post("/1.1/account/end_session.json").
should have_been_made
end
it "returns a null cookie" do
Expand All @@ -58,13 +58,13 @@

describe "#update_delivery_device" do
before do
stub_post("/1/account/update_delivery_device.json").
stub_post("/1.1/account/update_delivery_device.json").
with(:body => {:device => "sms"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.update_delivery_device("sms")
a_post("/1/account/update_delivery_device.json").
a_post("/1.1/account/update_delivery_device.json").
with(:body => {:device => "sms"}).
should have_been_made
end
Expand All @@ -77,13 +77,13 @@

describe "#update_profile" do
before do
stub_post("/1/account/update_profile.json").
stub_post("/1.1/account/update_profile.json").
with(:body => {:url => "http://github.com/sferik/"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.update_profile(:url => "http://github.com/sferik/")
a_post("/1/account/update_profile.json").
a_post("/1.1/account/update_profile.json").
with(:body => {:url => "http://github.com/sferik/"}).
should have_been_made
end
Expand All @@ -96,12 +96,12 @@

describe "#update_profile_background_image" do
before do
stub_post("/1/account/update_profile_background_image.json").
stub_post("/1.1/account/update_profile_background_image.json").
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.update_profile_background_image(fixture("we_concept_bg2.png"))
a_post("/1/account/update_profile_background_image.json").
a_post("/1.1/account/update_profile_background_image.json").
should have_been_made
end
it "returns a user" do
Expand All @@ -113,13 +113,13 @@

describe "#update_profile_colors" do
before do
stub_post("/1/account/update_profile_colors.json").
stub_post("/1.1/account/update_profile_colors.json").
with(:body => {:profile_background_color => "000000"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.update_profile_colors(:profile_background_color => "000000")
a_post("/1/account/update_profile_colors.json").
a_post("/1.1/account/update_profile_colors.json").
with(:body => {:profile_background_color => "000000"}).
should have_been_made
end
Expand All @@ -132,12 +132,12 @@

describe "#update_profile_image" do
before do
stub_post("/1/account/update_profile_image.json").
stub_post("/1.1/account/update_profile_image.json").
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.update_profile_image(fixture("me.jpeg"))
a_post("/1/account/update_profile_image.json").
a_post("/1.1/account/update_profile_image.json").
should have_been_made
end
it "returns a user" do
Expand All @@ -149,15 +149,15 @@

describe "#settings" do
before do
stub_get("/1/account/settings.json").
stub_get("/1.1/account/settings.json").
to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
stub_post("/1/account/settings.json").
stub_post("/1.1/account/settings.json").
with(:body => {:trend_location_woeid => "23424803"}).
to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource on GET" do
@client.settings
a_get("/1/account/settings.json").
a_get("/1.1/account/settings.json").
should have_been_made
end
it "returns settings" do
Expand All @@ -167,7 +167,7 @@
end
it "requests the correct resource on POST" do
@client.settings(:trend_location_woeid => "23424803")
a_post("/1/account/settings.json").
a_post("/1.1/account/settings.json").
with(:body => {:trend_location_woeid => "23424803"}).
should have_been_made
end
Expand Down
22 changes: 11 additions & 11 deletions spec/twitter/api/blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

describe "#blocking" do
before do
stub_get("/1/blocks/blocking.json").
stub_get("/1.1/blocks/blocking.json").
to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.blocking
a_get("/1/blocks/blocking.json").
a_get("/1.1/blocks/blocking.json").
should have_been_made
end
it "returns an array of user objects that the authenticating user is blocking" do
Expand All @@ -26,12 +26,12 @@

describe "#blocked_ids" do
before do
stub_get("/1/blocks/blocking/ids.json").
stub_get("/1.1/blocks/blocking/ids.json").
to_return(:body => fixture("ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.blocked_ids
a_get("/1/blocks/blocking/ids.json").
a_get("/1.1/blocks/blocking/ids.json").
should have_been_made
end
it "returns an array of numeric user IDs the authenticating user is blocking" do
Expand All @@ -43,16 +43,16 @@

describe "#block?" do
before do
stub_get("/1/blocks/exists.json").
stub_get("/1.1/blocks/exists.json").
with(:query => {:screen_name => "sferik"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
stub_get("/1/blocks/exists.json").
stub_get("/1.1/blocks/exists.json").
with(:query => {:screen_name => "pengwynn"}).
to_return(:body => fixture("not_found.json"), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.block?("sferik")
a_get("/1/blocks/exists.json").
a_get("/1.1/blocks/exists.json").
with(:query => {:screen_name => "sferik"}).
should have_been_made
end
Expand All @@ -68,13 +68,13 @@

describe "#block" do
before do
stub_post("/1/blocks/create.json").
stub_post("/1.1/blocks/create.json").
with(:body => {:screen_name => "sferik"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.block("sferik")
a_post("/1/blocks/create.json").
a_post("/1.1/blocks/create.json").
should have_been_made
end
it "returns an array of blocked users" do
Expand All @@ -87,13 +87,13 @@

describe "#unblock" do
before do
stub_delete("/1/blocks/destroy.json").
stub_delete("/1.1/blocks/destroy.json").
with(:query => {:screen_name => "sferik"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.unblock("sferik")
a_delete("/1/blocks/destroy.json").
a_delete("/1.1/blocks/destroy.json").
with(:query => {:screen_name => "sferik"}).
should have_been_made
end
Expand Down
28 changes: 14 additions & 14 deletions spec/twitter/api/direct_messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

describe "#direct_messages_received" do
before do
stub_get("/1/direct_messages.json").
stub_get("/1.1/direct_messages.json").
to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.direct_messages_received
a_get("/1/direct_messages.json").
a_get("/1.1/direct_messages.json").
should have_been_made
end
it "returns the 20 most recent direct messages sent to the authenticating user" do
Expand All @@ -26,12 +26,12 @@

describe "#direct_messages_sent" do
before do
stub_get("/1/direct_messages/sent.json").
stub_get("/1.1/direct_messages/sent.json").
to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.direct_messages_sent
a_get("/1/direct_messages/sent.json").
a_get("/1.1/direct_messages/sent.json").
should have_been_made
end
it "returns the 20 most recent direct messages sent by the authenticating user" do
Expand All @@ -44,12 +44,12 @@

describe "#direct_message_destroy" do
before do
stub_delete("/1/direct_messages/destroy/1825785544.json").
stub_delete("/1.1/direct_messages/destroy/1825785544.json").
to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.direct_message_destroy(1825785544)
a_delete("/1/direct_messages/destroy/1825785544.json").
a_delete("/1.1/direct_messages/destroy/1825785544.json").
should have_been_made
end
it "returns an array of deleted messages" do
Expand All @@ -62,13 +62,13 @@

describe "#direct_message_create" do
before do
stub_post("/1/direct_messages/new.json").
stub_post("/1.1/direct_messages/new.json").
with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"}).
to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.direct_message_create("pengwynn", "Creating a fixture for the Twitter gem")
a_post("/1/direct_messages/new.json").
a_post("/1.1/direct_messages/new.json").
with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"}).
should have_been_made
end
Expand All @@ -81,12 +81,12 @@

describe "#direct_message" do
before do
stub_get("/1/direct_messages/show/1825786345.json").
stub_get("/1.1/direct_messages/show/1825786345.json").
to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.direct_message(1825786345)
a_get("/1/direct_messages/show/1825786345.json").
a_get("/1.1/direct_messages/show/1825786345.json").
should have_been_made
end
it "returns the specified direct message" do
Expand All @@ -99,12 +99,12 @@
describe "#direct_messages" do
context "with ids passed" do
before do
stub_get("/1/direct_messages/show/1825786345.json").
stub_get("/1.1/direct_messages/show/1825786345.json").
to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.direct_messages(1825786345)
a_get("/1/direct_messages/show/1825786345.json").
a_get("/1.1/direct_messages/show/1825786345.json").
should have_been_made
end
it "returns an array of direct messages" do
Expand All @@ -116,12 +116,12 @@
end
context "without ids passed" do
before do
stub_get("/1/direct_messages.json").
stub_get("/1.1/direct_messages.json").
to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.direct_messages
a_get("/1/direct_messages.json").
a_get("/1.1/direct_messages.json").
should have_been_made
end
it "returns the 20 most recent direct messages sent to the authenticating user" do
Expand Down
Loading

0 comments on commit f55471a

Please sign in to comment.