spec/search/ajax_query_spec.rb in gscraper-0.2.4 vs spec/search/ajax_query_spec.rb in gscraper-0.3.0
- old
+ new
@@ -1,25 +1,26 @@
require 'spec_helper'
+require 'helpers/query'
require 'has_pages_examples'
require 'page_has_results_examples'
require 'search/page_has_results_examples'
require 'gscraper/search/ajax_query'
describe GScraper::Search::AJAXQuery do
+ include Helpers
before(:all) do
- @query = GScraper::Search::AJAXQuery.new(:query => DEFAULT_QUERY)
+ @query = GScraper::Search::AJAXQuery.new(:query => Helpers::DEFAULT_QUERY)
@page = @query.first_page
end
it_should_behave_like "has Pages"
it_should_behave_like "Page has Results"
it_should_behave_like "Page has Search Results"
describe "Search URL" do
-
before(:all) do
@uri = @query.search_url
end
it "should be a valid HTTP URI" do
@@ -55,11 +56,11 @@
it "should have a default 'gss' query-param of '.com'" do
@uri.query_params['gss'].should == '.com'
end
it "should have a 'q' query-param" do
- @uri.query_params['q'].should == DEFAULT_QUERY
+ @uri.query_params['q'].should == Helpers::DEFAULT_QUERY
end
it "should have a default 'sig' query-param" do
sig = @uri.query_params['sig']
sig.should == GScraper::Search::AJAXQuery::DEFAULT_SIG
@@ -72,33 +73,29 @@
it "should have a default 'v' query-param" do
v = @uri.query_params['v']
v.should == GScraper::Search::AJAXQuery::DEFAULT_VERSION
end
-
end
describe "page specific URLs" do
-
before(:all) do
@uri = @query.page_url(2)
end
it "should have a 'start' query-param" do
@uri.query_params['start'].should == @query.results_per_page
end
-
end
describe "queries from AJAX search URLs" do
-
before(:all) do
@version = '1.0'
@language = 'en'
@sig = '582c1116317355adf613a6a843f19ece'
@key = 'notsupplied'
- @query = GScraper::Search::AJAXQuery.from_url("http://www.google.com/uds/GwebSearch?v=#{@version}&lstkp=0&rsz=large&hl=#{@language}&callback=google.search.WebSearch.RawCompletion&sig=#{@sig}&q=#{DEFAULT_QUERY}&gss=.com&context=0&key=#{@key}")
+ @query = GScraper::Search::AJAXQuery.from_url("http://www.google.com/uds/GwebSearch?v=#{@version}&lstkp=0&rsz=large&hl=#{@language}&callback=google.search.WebSearch.RawCompletion&sig=#{@sig}&q=#{Helpers::DEFAULT_QUERY}&gss=.com&context=0&key=#{@key}")
end
it "should have a version" do
@query.version.should == @version
end
@@ -114,11 +111,9 @@
it "should have a key" do
@query.key.should == @key
end
it "should have a query" do
- @query.query.should == DEFAULT_QUERY
+ @query.query.should == Helpers::DEFAULT_QUERY
end
-
end
-
end