Skip to content
This repository
Browse code

Improve specs for undocumented

  • Loading branch information...
commit 690116baac002b438340030235fab38b87a17c92 1 parent 2259a17
Erik Michaels-Ober authored
2  lib/twitter/api/undocumented.rb
@@ -68,7 +68,7 @@ def activity_by_friends(options={})
68 68 def following_followers_of(*args)
69 69 options = extract_options!(args)
70 70 merge_default_cursor!(options)
71   - merge_user!(options, args.pop || screen_name)
  71 + merge_user!(options, args.pop || screen_name) unless options[:user_id] || options[:screen_name]
72 72 cursor_from_response(:users, Twitter::User, :get, "/users/following_followers_of.json", options)
73 73 end
74 74
34 spec/twitter/api/undocumented_spec.rb
@@ -49,6 +49,16 @@
49 49 expect(following_followers_of.users).to be_an Array
50 50 expect(following_followers_of.users.first).to be_a Twitter::User
51 51 end
  52 + context "with all" do
  53 + before do
  54 + 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"})
  55 + end
  56 + it "requests the correct resource" do
  57 + @client.following_followers_of("sferik").all
  58 + expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
  59 + expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :screen_name => "sferik"})).to have_been_made
  60 + end
  61 + end
52 62 end
53 63 context "with a user ID passed" do
54 64 before do
@@ -58,11 +68,15 @@
58 68 @client.following_followers_of(7505382)
59 69 expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
60 70 end
61   - it "returns an array of numeric IDs for every user following the specified user" do
62   - following_followers_of = @client.following_followers_of(7505382)
63   - expect(following_followers_of).to be_a Twitter::Cursor
64   - expect(following_followers_of.users).to be_an Array
65   - expect(following_followers_of.users.first).to be_a Twitter::User
  71 + context "with all" do
  72 + before do
  73 + 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"})
  74 + end
  75 + it "requests the correct resource" do
  76 + @client.following_followers_of(7505382).all
  77 + expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
  78 + expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :user_id => "7505382"})).to have_been_made
  79 + end
66 80 end
67 81 end
68 82 context "without arguments passed" do
@@ -81,6 +95,16 @@
81 95 expect(following_followers_of.users).to be_an Array
82 96 expect(following_followers_of.users.first).to be_a Twitter::User
83 97 end
  98 + context "with all" do
  99 + before do
  100 + 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"})
  101 + end
  102 + it "requests the correct resource" do
  103 + @client.following_followers_of.all
  104 + expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
  105 + expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :screen_name => "sferik"})).to have_been_made
  106 + end
  107 + end
84 108 end
85 109 end
86 110

0 comments on commit 690116b

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