1 require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
3 describe Twitter::Client, "#graph(:friends...)" do
5 @twitter = client_context
7 @screen_name = 'dummylogin'
8 @friend = Twitter::User.new(:id => @id, :screen_name => @screen_name)
9 @uris = Twitter::Client.class_eval("@@GRAPH_URIS")
10 @request = mas_net_http_get(:basic_auth => nil)
11 @response = mas_net_http_response(:success)
12 @response.stub!(:body).and_return("[1, 2, 3, 4, 5, 6]")
13 @connection = mas_net_http(@response)
14 Twitter::User.stub!(:unmarshal).and_return(@friend)
17 def create_uri(action)
18 "#{@uris[action]}.json"
21 it "should create expected HTTP GET request for :friends case using integer user ID" do
22 # the integer user ID scenario...
23 @twitter.should_receive(:rest_oauth_connect).with(:get, create_uri(:friends), :id => @id).and_return(@response)
24 @twitter.graph(:friends, @id)
27 it "should create expected HTTP GET request for :friends case using screen name" do
28 # the screen name scenario...
29 @twitter.should_receive(:rest_oauth_connect).with(:get, create_uri(:friends), :id => @screen_name).and_return(@response)
30 @twitter.graph(:friends, @screen_name)
33 it "should create expected HTTP GET request for :friends case using Twitter::User object" do
34 # the Twitter::User object scenario...
35 @twitter.should_receive(:rest_oauth_connect).with(:get, create_uri(:friends), :id => @friend.to_i).and_return(@response)
36 @twitter.graph(:friends, @friend)
39 it "should create expected HTTP GET request for :followers case using integer user ID" do
40 # the integer user ID scenario...
41 @twitter.should_receive(:rest_oauth_connect).with(:get, create_uri(:followers), :id => @id).and_return(@response)
42 @twitter.graph(:followers, @id)
45 it "should create expected HTTP GET request for :followers case using screen name" do
46 # the screen name scenario...
47 @twitter.should_receive(:rest_oauth_connect).with(:get, create_uri(:followers), :id => @screen_name).and_return(@response)
48 @twitter.graph(:followers, @screen_name)
51 it "should create expected HTTP GET request for :followers case using Twitter::User object" do
52 # the Twitter::User object scenario...
53 @twitter.should_receive(:rest_oauth_connect).with(:get, create_uri(:followers), :id => @friend.to_i).and_return(@response)
54 @twitter.graph(:followers, @friend)
57 it "should raise ArgumentError if action given is not valid" do
59 @twitter.graph(:crap, @friend)
60 }.should raise_error(ArgumentError)
64 nilize(@twitter, @id, @uris, @request, @response, @connection)