Sha256: f5f429a30c349c24d55f0d14c1ff99911658eaf1c6b87c06ffee9863ad3bf21a

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe RTurk::Requester do

  before(:all) do
    FakeWeb.clean_registry
    aws = YAML.load(File.open(File.join(SPEC_ROOT, 'mturk.yml')))
    RTurk.setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
  end

  it "should send the request to Amazon" do
    RestClient.should_receive(:get).with(/amazonaws.*Operation=GetHIT.*$/)
    RTurk::Requester.request(:Operation => 'GetHIT', 'HITId' => 'test')
  end

  it "should build a correct querystring with one value per key" do
    params = {
      :Operation => 'GetHIT',
      'Param1' => 'test1',
      'Param2' => 'test2'
    }
    RestClient.should_receive(:get).with(
      /(?=.*Operation=GetHIT)(?=.*Param1=test1)(?=.*Param2=test2)/)
    RTurk::Requester.request(params)
  end

  it "should build a correct querystring with two values per key" do
    params = {
      :Operation => 'GetHIT',
      'Param1' => 'test1',
      'Param2' => %w(test2a test2b)
    }
    RestClient.should_receive(:get).with(
      /(?=.*Operation=GetHIT)(?=.*Param1=test1)(?=.*Param2=test2a)(?=.*Param2=test2b)/)
    RTurk::Requester.request(params)
  end

  it "should build a correct querystring with a hash of values" do
    params = {
      :Operation => 'GetHIT',
      'Param1' => 'test1',
      'Param2' => {0 => 'test2a', 1 => 'test2b'}
    }
    RestClient.should_receive(:get).with(
      /(?=.*Operation=GetHIT)(?=.*Param1=test1)(?=.*Param2.0=test2a)(?=.*Param2.1=test2b)/)
    RTurk::Requester.request(params)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rturk-2.3.4 spec/requester_spec.rb
rturk-2.3.3 spec/requester_spec.rb