Sha256: d81cdcbb77fd97ae724ede2a4d97a6ba2508b3889d180593624f40fdee6295c5

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Cafepress::Search::SearchResultSet do
  before(:all) do
    @result_xml = File.read(File.join(File.dirname(__FILE__), '..', 'data', 'dog_search.xml'))
  end
  
  before(:each) do
    @results = Cafepress::Search::SearchResultSet.parse(@result_xml)
  end

  it "should load the results" do
    @results.results.each { |result| result.is_a?(Cafepress::Search::SearchResult).should be_true }
  end

  it "the number of results loaded should match the given result set size" do
    @results.results.size.should == @results.size
  end

  it "should load the result set size" do
    @results.size.should == 60
  end
  
  it "should know the total number of designs for this query" do
    @results.total_designs.should == 553352
  end

  it "should know the total number of products for this query" do
    @results.total_products.should == 17744462
  end
  
  it "should load the starting result index" do
    @results.start_index.should == 0
  end

  it "should load the sort type" do
    @results.sort.should == 'by_score_desc'
  end

  it "should load the topics" do
    @results.topics.should == [
      'pets',
      'pet',
      'canine',
      'puppy',
      'gifts',
      'animals',
      'art',
      'breeds',
      'breed',
      'humor'
    ]
  end
  
  it "should know the query used to generate the result set" do
    @results.query.should == "dog"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cafepress-search-1.0.2 spec/cafepress-search/search_result_set_spec.rb
cafepress-search-1.0.1 spec/cafepress-search/search_result_set_spec.rb
cafepress-search-1.0.0 spec/cafepress-search/search_result_set_spec.rb