1 require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
3 describe Twitter::Client, "#search" do
5 @twitter = client_context
6 @uris = Twitter::Client.class_eval("@@SEARCH_URIS")
7 @request = mas_net_http_get(:basic_auth => nil)
8 @response = mas_net_http_response(:success, "{\"results\": [], \"refresh_url\":\"?since_id=1768746401&q=blabla\"}")
9 @connection = mas_net_http(@response)
11 Twitter::Status.stub!(:unmarshal).and_return(@statuses)
13 @keywords = "twitter4r"
18 it "should create expected HTTP GET request using :to" do
19 @twitter.should_receive(:search_oauth_connect).with(:get, @uris[:basic], {:to => @to}).and_return(@response)
20 @twitter.search(:to => @to)
23 it "should bless the Array returned from Twitter for :to case" do
24 @twitter.should_receive(:bless_models).with(@statuses).and_return(@statuses)
25 @twitter.search(:to => @to)
28 it "should create expected HTTP GET request using :from" do
29 @twitter.should_receive(:search_oauth_connect).with(:get, @uris[:basic], {:from => @from}).and_return(@response)
30 @twitter.search(:from => @from)
33 it "should bless the Array returned from Twitter for :to case" do
34 @twitter.should_receive(:bless_models).with(@statuses).and_return(@statuses)
35 @twitter.search(:from => @from)
38 it "should create expected HTTP GET request using :keywords" do
39 @twitter.should_receive(:search_oauth_connect).with(:get, @uris[:basic], {:keywords => @keywords}).and_return(@response)
40 @twitter.search(:keywords => @keywords)
43 it "should bless the Array returned from Twitter for :keywords case" do
44 @twitter.should_receive(:bless_models).with(@statuses).and_return(@statuses)
45 @twitter.search(:keywords => @keywords)
48 it "should accept paging option" do
50 @twitter.search(:keywords => @keywords, :page => @page)
51 }.should_not raise_error(Exception)
54 it "should generate expected GET HTTP request for paging case" do
55 @twitter.should_receive(:search_oauth_connect).with(:get, @uris[:basic], {:page => @page}).and_return(@response)
56 @twitter.search(:page => @page)
59 it "should bless models for paging case" do
60 @twitter.should_receive(:bless_models).with(@statuses).and_return(@statuses)
61 @twitter.search(:page => @page)
65 nilize(@twitter, @uris, @request, @response, @connection, @statuses)