Sha256: f0951b8cc0db1ab449d73ed4a0c7f65154dbea63d51a8efa9f1ebe74b75bc06d

Contents?: true

Size: 1.46 KB

Versions: 13

Compression:

Stored size: 1.46 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

13 entries across 13 versions & 1 rubygems

Version Path
rturk-2.3.3 spec/operations/get_assignments_spec.rb
rturk-2.3.2 spec/operations/get_assignments_spec.rb
rturk-2.3.1 spec/operations/get_assignments_spec.rb
rturk-2.3.0 spec/operations/get_assignments_spec.rb
rturk-2.2.1 spec/operations/get_assignments_spec.rb
rturk-2.2.0 spec/operations/get_assignments_spec.rb
rturk-2.1.1 spec/operations/get_assignments_spec.rb
rturk-2.1.0 spec/operations/get_assignments_spec.rb
rturk-2.0.5 spec/operations/get_assignments_spec.rb
rturk-2.0.4 spec/operations/get_assignments_spec.rb
rturk-2.0.3 spec/operations/get_assignments_spec.rb
rturk-2.0.2 spec/operations/get_assignments_spec.rb
rturk-2.0.1 spec/operations/get_assignments_spec.rb