Sha256: d62135ddb90ca4f93938845420c1b8cb3b2b26e64df0d714ae192329da4e550a

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

require "spec_helper"

module Sucker
  describe "Item lookup" do
    let(:worker) do
      worker = Sucker.new(
        :locale => "us",
        :key    => amazon["key"],
        :secret => amazon["secret"])

      worker << {
        "Operation"     => "ItemLookup",
        "IdType"        => "ASIN",
        "Condition"     => "All",
        "MerchantId"    => "All",
        "ResponseGroup" => ["ItemAttributes", "OfferFull"] }
      worker
    end

    context "single item" do
      use_vcr_cassette "integration/item_lookup/single", :record => :new_episodes

      let(:response) do
        worker << { "ItemId" => "0816614024" }
        worker.get
      end

      let(:item) { response.node("Item").first }

      it "returns an item" do
        item.should be_an_instance_of Hash
      end

      it "includes an ASIN string" do
        item["ASIN"].should eql "0816614024"
      end

      it "includes requested response groups" do
        item["ItemAttributes"].should be_an_instance_of Hash
        item["Offers"].should be_an_instance_of Hash
      end

      it "returns no errors" do
        response.node("Error").should be_empty
        response.node("Error").should be_an_instance_of Array
      end
    end

    context "multiple items" do
      use_vcr_cassette "integration/item_lookup/multiple", :record => :new_episodes

      let(:items) do
        worker << { "ItemId" => ["0816614024", "0143105825"] }
        worker.get.node("Item")
      end

      it "returns two items" do
        items.should be_an_instance_of Array
        items.size.should eql 2
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sucker-1.0.0.beta.2 spec/integration/item_lookup_spec.rb