Skip to content

Commit

Permalink
Adding support for inlink BOSS queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Pignata committed Oct 21, 2009
1 parent a677d23 commit 51496f0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/bossman/search.rb
Expand Up @@ -2,11 +2,11 @@ module BOSSMan
class Search
DEFAULT_COUNT = 10
DEFAULT_START = 0

VALID_METHODS = [:web, :images, :news, :spelling, :se_inlink]
class << self
def method_missing(*args)
method, query, options = args
super unless [:web, :images, :news, :spelling].include?(method)
super unless VALID_METHODS.include?(method)
options = {} if options.nil?
boss = BOSS.new(method, query, options_defaults.merge!(options))
boss.get
Expand Down
25 changes: 25 additions & 0 deletions spec/bossman_spec.rb
Expand Up @@ -127,6 +127,30 @@
end
end

context "Inlink Search" do
before(:all) do
include BOSSMan
set_boss_api_key
@result = boss_search("se_inlink", "www.rubyonrails.org").results[2]
end

it "contains a description of each site linking to the site in the query" do
@result.abstract.should match(/Personal weblog for David Heinemeier Hansson/)
end

it "contains a click URL for each site linking to the site in the query" do
@result.clickurl.should match(/lrd.yahooapis.com/)
end

it "contains a URL for each site linking to the site in the query" do
@result.url.should == "http://www.loudthinking.com/"
end

it "contains a title for each site linking to the site in the query" do
@result.title.should == "Loud Thinking by David Heinemeier Hansson"
end
end

context "Image Search" do
before(:all) do
include BOSSMan
Expand Down Expand Up @@ -189,6 +213,7 @@
it "contains a thumbnail image width for each result" do
@result.thumbnail_width.should == "130"
end

end
end

2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -32,5 +32,5 @@ def boss_url(method, query, options = {})
end

def fakeweb_file(method, query)
"#{File.dirname(__FILE__)}/support/fakeweb/#{method}.#{query.gsub(" ", "_")}.json"
"#{File.dirname(__FILE__)}/support/fakeweb/#{method}.#{query.gsub(/[ \.]/, "_")}.json"
end

0 comments on commit 51496f0

Please sign in to comment.