Sha256: 83c9e813bf848043eb9e793823d34c49aec36e4d329a3cd904862c9fec2e5c35

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

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

    describe ".new" do
      it "defines 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 "adds 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 "#get" do
      before do
        VCR.http_stubbing_adapter.http_connections_allowed = true
      end

      it "returns an algorithm" do
        Request.stub!(:get)

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

        request.get.should be_a Response
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fassbinder-0.0.8 spec/fassbinder/request_spec.rb
fassbinder-0.0.7 spec/fassbinder/request_spec.rb
fassbinder-0.0.6 spec/fassbinder/request_spec.rb
fassbinder-0.0.5 spec/fassbinder/request_spec.rb
fassbinder-0.0.4 spec/fassbinder/request_spec.rb