Permalink
Browse files

add failing test for iterating over followers

  • Loading branch information...
nbraem committed Dec 20, 2012
1 parent dde9281 commit 09bc8120a5832382acc0e05024bf13e28758914b
Showing with 26 additions and 0 deletions.
  1. +1 −0 spec/fixtures/followers_list2.json
  2. +1 −0 spec/fixtures/nbraem.json
  3. +24 −0 spec/twitter/api/friends_and_followers_spec.rb

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1 @@
+{"id":16234978,"id_str":"16234978","name":"Nicolas Braem","screen_name":"nbraem","location":"Belgium","description":null,"url":null,"entities":{"description":{"urls":[]}},"protected":false,"followers_count":103,"friends_count":194,"listed_count":0,"created_at":"Thu Sep 11 05:44:01 +0000 2008","favourites_count":10,"utc_offset":-28800,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":false,"statuses_count":420,"lang":"en","status":{"created_at":"Thu Dec 20 09:36:54 +0000 2012","id":281694656159416322,"id_str":"281694656159416322","text":"@tompeej daar kan ik maar 1 ding op zeggen: http://t.co/ZrZCS2G6","source":"web","truncated":false,"in_reply_to_status_id":279704432663486465,"in_reply_to_status_id_str":"279704432663486465","in_reply_to_user_id":16823456,"in_reply_to_user_id_str":"16823456","in_reply_to_screen_name":"tompeej","geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"entities":{"hashtags":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false},"contributors_enabled":false,"is_translator":false,"profile_background_color":"000000","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/665875854\/bb0b3653dcf0644e344823e0a2eb3382.png","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/665875854\/bb0b3653dcf0644e344823e0a2eb3382.png","profile_background_tile":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1759857427\/image1326743606_normal.png","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1759857427\/image1326743606_normal.png","profile_banner_url":"https:\/\/si0.twimg.com\/profile_banners\/7505382\/1348266581","profile_link_color":"0084B4","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false}
@@ -438,6 +438,18 @@
expect(followers.users).to be_an Array
expect(followers.users.first).to be_a Twitter::User
end
+ context "when requesting someone else's followers" do
+ before do
+ stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("nbraem.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ stub_get("/1.1/followers/list.json").with(:query => {:cursor => "-1", :screen_name => "sferik"}).to_return(:body => fixture("followers_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ stub_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :screen_name => "sferik"}).to_return(:body => fixture("followers_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ it "requests the correct resources" do
+ @client.followers("sferik").each{}
+ expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
+ expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :screen_name => "sferik"})).to have_been_made
+ end
+ end
end
context "with a user ID passed" do
before do
@@ -453,6 +465,18 @@
expect(followers.users).to be_an Array
expect(followers.users.first).to be_a Twitter::User
end
+ context "when requesting someone else's followers" do
+ before do
+ stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("nbraem.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ stub_get("/1.1/followers/list.json").with(:query => {:cursor => "-1", :user_id => "14100886"}).to_return(:body => fixture("followers_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ stub_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :user_id => "14100886"}).to_return(:body => fixture("followers_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ it "requests the correct resources" do
+ @client.followers(14100886).each{}
+ expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
+ expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :screen_name => "sferik"})).to have_been_made
+ end
+ end
end
context "without arguments passed" do
before do

0 comments on commit 09bc812

Please sign in to comment.