Sha256: 544567afc580169f72bf0826cfe3e917c0c7e49b43d8d1f88c357ea2c06af0ee

Contents?: true

Size: 1.21 KB

Versions: 13

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

module Kosher
  describe Request do
    let(:request) { Request.new(credentials) }

    describe ".new" do
      it "should define a batch request" do
        request.parameters['Operation'].should eql 'ItemLookup'
        request.parameters['ItemLookup.Shared.IdType'].should eql 'ASIN'
        request.parameters['ItemLookup.Shared.Condition'].should eql 'All'
        request.parameters['ItemLookup.Shared.MerchantId'].should eql 'All'
        request.parameters['ItemLookup.Shared.ResponseGroup'].should eql ['OfferFull', 'SalesRank']
      end
    end

    describe "#batchify" do
      it "should add up to 20 ASINs to the worker's parameters" do
        asins = (0..19).to_a
        request.batchify(asins)

        request.parameters['ItemLookup.1.ItemId'].should eql (0..9).to_a
        request.parameters['ItemLookup.2.ItemId'].should eql (10..19).to_a
      end
    end

    describe "#request" do
      before do
        VCR.http_stubbing_adapter.http_connections_allowed = true
      end

      it "should return an algorithm" do
        Kosher::Request.stub!(:get)

        request.locale = :us
        request.batchify('foo')

        request.get.should be_a Algorithm
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
kosher-0.1.12 spec/kosher/request_spec.rb
kosher-0.1.11 spec/kosher/request_spec.rb
kosher-0.1.10 spec/kosher/request_spec.rb
kosher-0.1.9 spec/kosher/request_spec.rb
kosher-0.1.8 spec/kosher/request_spec.rb
kosher-0.1.7 spec/kosher/request_spec.rb
kosher-0.1.6 spec/kosher/request_spec.rb
kosher-0.1.5 spec/kosher/request_spec.rb
kosher-0.1.4 spec/kosher/request_spec.rb
kosher-0.1.3 spec/kosher/request_spec.rb
kosher-0.1.2 spec/kosher/request_spec.rb
kosher-0.1.1 spec/kosher/request_spec.rb
kosher-0.1.0 spec/kosher/request_spec.rb