Sha256: 26ea4968addc59651d2fa7b44bc57e80e5d0b93c3203870616cf88aaf0b2ef2c

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))

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

  it "should ensure required params" do
    lambda{RTurk::GetAssignmentsForHIT(:page_number => 5)}.should raise_error RTurk::MissingParameters
  end

  it "should successfully request an assignment" do
    RTurk::Requester.should_receive(:request).once.with(
    hash_including('Operation' => 'GetAssignmentsForHIT'))
    RTurk::GetAssignmentsForHIT(:hit_id => "abcd") rescue RTurk::InvalidRequest
  end

  context "an HIT with one assignment" do
    before(:all) do
      FakeWeb.clean_registry
      faker('get_assignments', :operation => 'GetAssignmentsForHIT')
    end

    it "should parse and return and answer" do
      assignments = RTurk::GetAssignmentsForHIT(:hit_id => "abcd").assignments
      assignments.first.answers['tweet'].should eql("This is my tweet!")
    end
  end

  context "an HIT with multiple assignment" do

    before(:all) do
      FakeWeb.clean_registry
      faker('get_assignments_multiple', :operation => 'GetAssignmentsForHIT')
    end

    it "should parse and return and answer" do
      assignments = RTurk::GetAssignmentsForHIT(:hit_id => "abcd").assignments
      assignments.first.answers['tweet'].should eql("This is my tweet!")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rturk-2.3.6 spec/operations/get_assignments_spec.rb
rturk-2.3.5 spec/operations/get_assignments_spec.rb
rturk-2.3.4 spec/operations/get_assignments_spec.rb