Skip to content

Commit

Permalink
Remove Twitter::Cursor#all
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jul 25, 2013
1 parent 8eeff57 commit 72be414
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 86 deletions.
2 changes: 1 addition & 1 deletion lib/twitter/api/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def block?(user, options={})
when Twitter::User
user.id
end
blocked_ids(options).all.map(&:to_i).include?(user_id)
blocked_ids(options).map(&:to_i).include?(user_id)
end

# Blocks the users specified by the authenticating user
Expand Down
4 changes: 0 additions & 4 deletions lib/twitter/cursor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ def initialize(attrs, collection_name, klass, client, request_method, path, opti
end
end

def all
map{|element| element}
end

# @return [Enumerator]
def each(&block)
return to_enum(:each) unless block_given?
Expand Down
56 changes: 28 additions & 28 deletions spec/twitter/api/friends_and_followers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
expect(friend_ids.ids).to be_an Array
expect(friend_ids.ids.first).to eq 14100886
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.friend_ids("sferik").all
@client.friend_ids("sferik").each{}
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"})).to have_been_made
end
Expand All @@ -40,12 +40,12 @@
@client.friend_ids(7505382)
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :user_id => "7505382"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.friend_ids(7505382).all
@client.friend_ids(7505382).each{}
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :user_id => "7505382"})).to have_been_made
end
Expand All @@ -67,12 +67,12 @@
expect(friend_ids.ids).to be_an Array
expect(friend_ids.ids.first).to eq 14100886
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.friend_ids.all
@client.friend_ids.each{}
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"})).to have_been_made
Expand All @@ -96,12 +96,12 @@
expect(follower_ids.ids).to be_an Array
expect(follower_ids.ids.first).to eq 14100886
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.follower_ids("sferik").all
@client.follower_ids("sferik").each{}
expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"})).to have_been_made
end
Expand All @@ -115,12 +115,12 @@
@client.follower_ids(7505382)
expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :user_id => "7505382"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.follower_ids(7505382).all
@client.follower_ids(7505382).each{}
expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :user_id => "7505382"})).to have_been_made
end
Expand All @@ -142,12 +142,12 @@
expect(follower_ids.ids).to be_an Array
expect(follower_ids.ids.first).to eq 14100886
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.follower_ids.all
@client.follower_ids.each{}
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"})).to have_been_made
Expand Down Expand Up @@ -262,12 +262,12 @@
expect(friendships_incoming.ids).to be_an Array
expect(friendships_incoming.ids.first).to eq 14100886
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/friendships/incoming.json").with(:query => {:cursor => "1305102810874389703"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.friendships_incoming.all
@client.friendships_incoming.each{}
expect(a_get("/1.1/friendships/incoming.json").with(:query => {:cursor => "1305102810874389703"})).to have_been_made
end
end
Expand All @@ -287,12 +287,12 @@
expect(friendships_outgoing.ids).to be_an Array
expect(friendships_outgoing.ids.first).to eq 14100886
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/friendships/outgoing.json").with(:query => {:cursor => "1305102810874389703"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.friendships_outgoing.all
@client.friendships_outgoing.each{}
expect(a_get("/1.1/friendships/outgoing.json").with(:query => {:cursor => "1305102810874389703"})).to have_been_made
end
end
Expand Down Expand Up @@ -533,12 +533,12 @@
expect(followers.users).to be_an Array
expect(followers.users.first).to be_a Twitter::User
end
context "with all" do
context "with each" do
before do
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 resource" do
@client.followers("sferik").all
@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
Expand All @@ -552,12 +552,12 @@
@client.followers(7505382)
expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :user_id => "7505382"}).to_return(:body => fixture("followers_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.followers(7505382).all
@client.followers(7505382).each{}
expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :user_id => "7505382"})).to have_been_made
end
Expand All @@ -579,12 +579,12 @@
expect(followers.users).to be_an Array
expect(followers.users.first).to be_a Twitter::User
end
context "with all" do
context "with each" do
before do
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 resource" do
@client.followers.all
@client.followers.each{}
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
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
Expand All @@ -608,12 +608,12 @@
expect(friends.users).to be_an Array
expect(friends.users.first).to be_a Twitter::User
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :screen_name => "sferik"}).to_return(:body => fixture("friends_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.friends("sferik").all
@client.friends("sferik").each{}
expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :screen_name => "sferik"})).to have_been_made
end
Expand All @@ -627,12 +627,12 @@
@client.friends(7505382)
expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :user_id => "7505382"}).to_return(:body => fixture("friends_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.friends(7505382).all
@client.friends(7505382).each{}
expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :user_id => "7505382"})).to have_been_made
end
Expand All @@ -654,12 +654,12 @@
expect(friends.users).to be_an Array
expect(friends.users.first).to be_a Twitter::User
end
context "with all" do
context "with each" do
before do
stub_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :screen_name => "sferik"}).to_return(:body => fixture("friends_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.friends.all
@client.friends.each{}
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :screen_name => "sferik"})).to have_been_made
Expand Down
Loading

0 comments on commit 72be414

Please sign in to comment.