Sha256: 95da3f431a07a96e5f8ef75ccd8f9bb3bd4ca879d73cefaaadafd703117ac792
Contents?: true
Size: 1.98 KB
Versions: 2
Compression:
Stored size: 1.98 KB
Contents
require 'spec_helper' module Binged module Search describe "Web" do include AnyFilter include AnyPageable before(:each) do @client = Binged::Client.new(:api_key => 'binged') @search = Web.new(@client) end it "should initialize with a search term" do Web.new(@client, 'binged').query[:Query].should include('binged') end it "should be able to set a file type" do @search.file_type(:pdf) @search.query['Web.FileType'].should == :pdf end context "fetching" do before(:each) do stub_get("http://api.bing.net/json.aspx?Web.Offset=0&Sources=web&AppId=binged&Query=ruby&JsonType=raw&Version=2.2&Web.Count=20", 'web.json') @search.containing("ruby") @response = @search.fetch end it "should cache fetch to eliminate multiple calls to the api" do Web.should_not_receive(:perform) @search.fetch end it "should return the results of the search" do @response.results.size.should == 20 end it "should support dot notation" do result = @response.results.first result.title.should == "Ruby Programming Language" result.description.should == "Ruby is… A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is ..." result.url.should == "http://www.ruby-lang.org/en/" end end context "iterating over results" do before(:each) do stub_get("http://api.bing.net/json.aspx?Web.Offset=0&Sources=Web&AppId=binged&Query=ruby&JsonType=raw&Version=2.2&Web.Count=20", 'web.json') @search.containing("ruby") end it "should be able to iterate over results" do @search.respond_to?(:each).should be_true end it "should have items" do @search.each {|item| item.should_not be_nil } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
binged-0.3.0 | spec/binged/search/web_spec.rb |
binged-0.2.0 | spec/binged/search/web_spec.rb |