Sha256: b5ee34742571fc18865b21f1bc2770646b07678d69fbf1f1b3de06f5403ad324

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

module Amazon
  module Associates
    describe Item do
      before(:all) do
        @item = Amazon::Associates::item_lookup("0545010225").item
      end

      it "should equal anything with the same #asin" do
        asin = @item.asin
        @item.should == Struct.new(:asin).new(asin)
      end

      shared_examples_for "query for items" do
        it "should return a list of items" do
          @result.should have_at_least(10).items
          @result.each {|item| item.should be_an_instance_of(Item) }
        end
      end

      shared_examples_for "query for related items" do
        it_should_behave_like "query for items"
        it "should not include the item related to the result" do
          @result.should_not include(@item)
        end
      end

      describe ".similar" do
        before(:all) do
          @result = Item.similar(@item.asin)
        end
        it_should_behave_like "query for related items"
      end

      describe ".all" do
        before(:all) do
          @result = Item.all("search_index"=>"Blended", "keywords"=>"potter")
        end
        it_should_behave_like "query for items"

        it "should handle hashes with indifferent access" do
          Item.all(HashWithIndifferentAccess.new("search_index"=>"Blended", "keywords"=>"hello")).should_not == nil
        end
      end

      describe "#similar" do
        before(:all) do
          @result = @item.similar
        end
        it_should_behave_like "query for related items"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amazon-associates-0.7.2 spec/types/item_spec.rb