Skip to content

Commit

Permalink
Phrase search from @Zagari
Browse files Browse the repository at this point in the history
  • Loading branch information
pengwynn committed Feb 11, 2010
1 parent f09b312 commit e3e8f7e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions History
@@ -1,3 +1,6 @@
0.8.4 - February 11, 2010
* Added membership query options // thanks ming yeow ng
* Added support for a phrase search (instead of a group of words) from @zagari
0.8.3 - January 29, 2010
* Added patch for unauthenticated list timelines from @spastorino
0.8.2 - January 21, 2010
Expand Down
6 changes: 6 additions & 0 deletions lib/twitter/search.rb
Expand Up @@ -43,6 +43,12 @@ def hashed(tag)
@query[:q] << "##{tag}"
self
end

# Search for a phrase instead of a group of words
def phrase(phrase)
@query[:phrase] = phrase
self
end

# lang must be ISO 639-1 code ie: en, fr, de, ja, etc.
#
Expand Down
6 changes: 6 additions & 0 deletions test/twitter/search_test.rb
Expand Up @@ -104,6 +104,12 @@ class SearchTest < Test::Unit::TestCase
@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://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 clear the filters set" do
@search.from('jnunemaker').to('oaknd1')
Expand Down

0 comments on commit e3e8f7e

Please sign in to comment.