Permalink
Browse files

Fixed search api calls to go to search.twitter.com instead of api.twi…

…tter.com
  • Loading branch information...
1 parent 190f5d5 commit f9c7af99b4560f39b3542582934ae07955b6c9cc @secobarbital secobarbital committed Mar 30, 2010
Showing with 16 additions and 16 deletions.
  1. +2 −2 lib/twitter/search.rb
  2. +14 −14 test/twitter/search_test.rb
View
@@ -2,7 +2,7 @@ module Twitter
class Search
include HTTParty
include Enumerable
- base_uri "api.twitter.com/#{API_VERSION}/search"
+ base_uri "search.twitter.com/search"
format :json
attr_reader :result, :query
@@ -149,7 +149,7 @@ def fetch_next_page
protected
def perform_get(query)
- response = self.class.get("http://api.twitter.com/#{API_VERSION}/search.json", :query => query, :format => :json, :headers => {"User-Agent" => user_agent})
+ response = self.class.get("#{self.class.base_uri}.json", :query => query, :format => :json, :headers => {"User-Agent" => user_agent})
@fetch = Twitter.mash(response)
end
@@ -21,7 +21,7 @@ class SearchTest < Test::Unit::TestCase
end
should "pass user agent along with headers when making request" do
- Twitter::Search.expects(:get).with('http://api.twitter.com/1/search.json', {:format => :json, :query => {:q => 'foo'}, :headers => {'User-Agent' => 'Foobar'}})
+ Twitter::Search.expects(:get).with('http://search.twitter.com/search.json', {:format => :json, :query => {:q => 'foo'}, :headers => {'User-Agent' => 'Foobar'}})
Twitter::Search.new('foo', :user_agent => 'Foobar').fetch()
end
@@ -75,61 +75,61 @@ class SearchTest < Test::Unit::TestCase
should "should be able to specify the language" do
@search.lang('en')
- @search.class.expects(:get).with('http://api.twitter.com/1/search.json', :query => {:lang => 'en', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:lang => 'en', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
@search.fetch()
end
should "should be able to specify the number of results per page" do
@search.per_page(25)
- @search.class.expects(:get).with('http://api.twitter.com/1/search.json', :query => {:rpp => 25, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:rpp => 25, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
@search.fetch()
end
should "should be able to specify the page number" do
@search.page(20)
- @search.class.expects(:get).with('http://api.twitter.com/1/search.json', :query => {:page => 20, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:page => 20, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
@search.fetch()
end
should "should be able to specify only returning results greater than an id" do
@search.since(1234)
- @search.class.expects(:get).with('http://api.twitter.com/1/search.json', :query => {:since_id => 1234, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:since_id => 1234, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
@search.fetch()
end
should "should be able to specify since a date" do
@search.since_date('2009-04-14')
- @search.class.expects(:get).with('http://api.twitter.com/1/search.json', :query => { :since => '2009-04-14', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({ 'foo' => 'bar'})
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => { :since => '2009-04-14', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({ 'foo' => 'bar'})
@search.fetch
end
should "should be able to specify until a date" do
@search.until_date('2009-04-14')
- @search.class.expects(:get).with('http://api.twitter.com/1/search.json', :query => { :until => '2009-04-14', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({ 'foo' => 'bar'})
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => { :until => '2009-04-14', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({ 'foo' => 'bar'})
@search.fetch
end
should "should be able to specify geo coordinates" do
@search.geocode('40.757929', '-73.985506', '25mi')
- @search.class.expects(:get).with('http://api.twitter.com/1/search.json', :query => {:geocode => '40.757929,-73.985506,25mi', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:geocode => '40.757929,-73.985506,25mi', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
@search.fetch()
end
should "should be able to specify max id" do
@search.max(1234)
- @search.class.expects(:get).with('http://api.twitter.com/1/search.json', :query => {:max_id => 1234, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:max_id => 1234, :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
@search.fetch()
end
should "should be able to set the phrase" do
@search.phrase("Who Dat")
- @search.class.expects(:get).with('http://api.twitter.com/1/search.json', :query => {:phrase => "Who Dat", :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:phrase => "Who Dat", :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
@search.fetch()
end
should "should be able to set the result type" do
@search.result_type("popular")
- @search.class.expects(:get).with('http://api.twitter.com/1/search.json', :query => {:result_type => 'popular', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
+ @search.class.expects(:get).with('http://search.twitter.com/search.json', :query => {:result_type => 'popular', :q => ''}, :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
@search.fetch()
end
@@ -149,7 +149,7 @@ class SearchTest < Test::Unit::TestCase
context "fetching" do
setup do
- stub_get('http://api.twitter.com:80/1/search.json?q=%40jnunemaker', 'search.json')
+ stub_get('http://search.twitter.com:80/search.json?q=%40jnunemaker', 'search.json')
@search = Twitter::Search.new('@jnunemaker')
@response = @search.fetch
end
@@ -179,14 +179,14 @@ class SearchTest < Test::Unit::TestCase
end
should "be able to fetch the next page" do
- Twitter::Search.expects(:get).with('http://api.twitter.com/1/search.json', :query => 'page=2&max_id=1446791544&q=%40jnunemaker', :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
+ Twitter::Search.expects(:get).with('http://search.twitter.com/search.json', :query => 'page=2&max_id=1446791544&q=%40jnunemaker', :format => :json, :headers => {'User-Agent' => 'Ruby Twitter Gem'}).returns({'foo' => 'bar'})
@search.fetch_next_page
end
end
context "iterating over results" do
setup do
- stub_get('http://api.twitter.com:80/1/search.json?q=from%3Ajnunemaker', 'search_from_jnunemaker.json')
+ stub_get('http://search.twitter.com:80/search.json?q=from%3Ajnunemaker', 'search_from_jnunemaker.json')
@search.from('jnunemaker')
end

0 comments on commit f9c7af9

Please sign in to comment.