Permalink
Browse files

Improve specs for undocumented

  • Loading branch information...
1 parent 2259a17 commit 690116baac002b438340030235fab38b87a17c92 @sferik committed Dec 20, 2012
Showing with 30 additions and 6 deletions.
  1. +1 −1 lib/twitter/api/undocumented.rb
  2. +29 −5 spec/twitter/api/undocumented_spec.rb
View
2 lib/twitter/api/undocumented.rb
@@ -68,7 +68,7 @@ def activity_by_friends(options={})
def following_followers_of(*args)
options = extract_options!(args)
merge_default_cursor!(options)
- merge_user!(options, args.pop || screen_name)
+ merge_user!(options, args.pop || screen_name) unless options[:user_id] || options[:screen_name]
cursor_from_response(:users, Twitter::User, :get, "/users/following_followers_of.json", options)
end
View
34 spec/twitter/api/undocumented_spec.rb
@@ -49,6 +49,16 @@
expect(following_followers_of.users).to be_an Array
expect(following_followers_of.users.first).to be_a Twitter::User
end
+ context "with all" do
+ before do
+ stub_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :screen_name => "sferik"}).to_return(:body => fixture("users_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ it "requests the correct resource" do
+ @client.following_followers_of("sferik").all
+ expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
+ expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :screen_name => "sferik"})).to have_been_made
+ end
+ end
end
context "with a user ID passed" do
before do
@@ -58,11 +68,15 @@
@client.following_followers_of(7505382)
expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
end
- it "returns an array of numeric IDs for every user following the specified user" do
- following_followers_of = @client.following_followers_of(7505382)
- expect(following_followers_of).to be_a Twitter::Cursor
- expect(following_followers_of.users).to be_an Array
- expect(following_followers_of.users.first).to be_a Twitter::User
+ context "with all" do
+ before do
+ stub_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :user_id => "7505382"}).to_return(:body => fixture("users_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ it "requests the correct resource" do
+ @client.following_followers_of(7505382).all
+ expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
+ expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :user_id => "7505382"})).to have_been_made
+ end
end
end
context "without arguments passed" do
@@ -81,6 +95,16 @@
expect(following_followers_of.users).to be_an Array
expect(following_followers_of.users.first).to be_a Twitter::User
end
+ context "with all" do
+ before do
+ stub_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :screen_name => "sferik"}).to_return(:body => fixture("users_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ it "requests the correct resource" do
+ @client.following_followers_of.all
+ expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
+ expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :screen_name => "sferik"})).to have_been_made
+ end
+ end
end
end

0 comments on commit 690116b

Please sign in to comment.