<commit_before><commit_msg>A new spec that toys with threading<commit_after># 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",
        "Condition"     => "All",
        "MerchantId"    => "All",
        "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.each do |thread|
        thread.join
        item = thread[:response].node("Item").first
        bindings << item["ItemAttributes"]["Binding"]
      end

      bindings.uniq.should =~ %w{ Paperback Taschenbuch Broché ペーパーバック }
    end
  end
end
{'fraction_non_alphanumeric': 0.1227154046997389, 'fraction_numerical': 0.009573542210617928, 'mean_word_length': 2.0748663101604277, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5383634', 'n_tokens_mistral': 355, 'n_tokens_neox': 345, 'n_words': 85}