Sha256: f82615991cc3a14f7e43ab11a006318eda334bbd77d58dee53dd65f9d0e6a1e0

Contents?: true

Size: 999 Bytes

Versions: 2

Compression:

Stored size: 999 Bytes

Contents

# encoding: utf-8
require "spec_helper"

module Sucker
  describe "Multiple locales" do
    use_vcr_cassette "integration/multiple_locales", :record => :new_episodes

    it "threads multiple requests" do
      locales = %w{us uk de ca fr jp}

      params = {
        "Operation"     => "ItemLookup",
        "IdType"        => "ASIN",
        "ResponseGroup" => "ItemAttributes",
        "ItemId"        => "0816614024" }

      threads = locales.map do |locale|
        Thread.new do
          worker = Sucker.new(
            :locale => locale,
            :key    => amazon["key"],
            :secret => amazon["secret"])
          worker << params
          Thread.current[:response] = worker.get
        end
      end

      bindings = threads.map do |thread|
        thread.join
        item = thread[:response].find("Item").first
        item["ItemAttributes"]["Binding"]
      end

      bindings.uniq.should =~ %w{ Paperback Taschenbuch Broché ペーパーバック }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sucker-1.0.0.beta.4 spec/integration/multiple_locales_spec.rb
sucker-1.0.0.beta.3 spec/integration/multiple_locales_spec.rb