Sha256: 3a7db7589245dd5daac578f96d56c99b9027cc43f4f40f0d9f812c78fbc4b3fc

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

require "spec_helper"

describe SearchTerms::Extractor do
  context "non-search engine" do
    it "returns nil for search terms even if they are present" do
      uri = URI("http://andylindeman.com/?q=how+to+do+everything")
      uri.search_string.should be_nil
    end

    it "returns nil for search terms if they are not present" do
      uri = URI("http://andylindeman.com/")
      uri.search_string.should be_nil
    end
  end

  context "google" do
    it "returns search terms from query string" do
      uri = URI("http://google.com/?q=how+to+extract+search+terms")
      uri.search_string.should == "how to extract search terms"
    end

    it "returns search terms from query fragment" do
      uri = URI("http://google.com/#q=how+to+extract+search+terms")
      uri.search_string.should == "how to extract search terms"
    end
  end

  context "yahoo" do
    it "returns search terms from query string" do
      uri = URI("http://search.yahoo.com/search;_ylt=abc123?p=how+to+extract+search+terms")
      uri.search_string.should == "how to extract search terms"
    end
  end

  context "bing" do
    it "returns search terms from query string" do
      uri = URI("http://www.bing.com/search?q=how+to+extract+search+terms")
      uri.search_string.should == "how to extract search terms"
    end
  end

  context "aol" do
    it "returns search terms from query string" do
      uri = URI("http://search.aol.com/aol/search?q=how+to+extract+search+terms")
      uri.search_string.should == "how to extract search terms"
    end
  end

  context "duckduckgo" do
    it "returns search terms from query string" do
      uri = URI("http://duckduckgo.com/?q=how+to+extract+search+terms")
      uri.search_string.should == "how to extract search terms"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
search_terms-0.0.1 spec/search_terms_spec.rb