Sha256: e5138cfe0343b4dad370089ec1ecf4a154b879a2ef6b76919621bb73e121993c

Contents?: true

Size: 1.22 KB

Versions: 20

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'


describe RTurk::Response do
  
  context "given an invalid response" do
  
    before(:each) do
      @bad_credentials_response = fake_response(File.read(File.join(SPEC_ROOT,'fake_responses','invalid_credentials.xml')))
    end
    
    it "should know it failed" do
      lambda{RTurk::Response.new(@bad_credentials_response)}.should raise_error RTurk::InvalidRequest
    end
    
    it "should know why" do
      begin
        RTurk::Response.new(@bad_credentials_response)
      rescue RTurk::InvalidRequest => e
        e.message.should eql("AWS.NotAuthorized: The identity contained in the request is not authorized to use this AWSAccessKeyId")
      end

    end
    
  end
  
  context "given a valid response" do
  
    before(:all) do
      @response = RTurk::Response.new(fake_response(File.read(File.join(SPEC_ROOT,'fake_responses','create_hit.xml'))))
    end
    
    it "should know it succeded" do
      @response.success?.should be_true
    end
    
    it "should not have errors attached" do
      @response.errors.should be_empty
    end
    
    it "should give back the xml as a hash" do
      @response.elements['CreateHITResponse']['HIT']['HITId'].should == 'GBHZVQX3EHXZ2AYDY2T0'
    end
    
  end
  
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rturk-2.12.1 spec/response_spec.rb
rturk-2.12.0 spec/response_spec.rb
rturk-2.11.3 spec/response_spec.rb
rturk-2.11.2 spec/response_spec.rb
rturk-2.11.1 spec/response_spec.rb
rturk-2.11.0 spec/response_spec.rb
rturk-2.10.3 spec/response_spec.rb
rturk-2.10.2 spec/response_spec.rb
rturk-2.10.1 spec/response_spec.rb
rturk-2.10.0 spec/response_spec.rb
rturk-2.9.0 spec/response_spec.rb
rturk-2.8.0 spec/response_spec.rb
rturk-2.7.0 spec/response_spec.rb
rturk-2.6.0 spec/response_spec.rb
rturk-2.5.2 spec/response_spec.rb
rturk-2.5.0 spec/response_spec.rb
rturk-2.4.1 spec/response_spec.rb
rturk-2.4.0 spec/response_spec.rb
rturk-2.3.6 spec/response_spec.rb
rturk-2.3.5 spec/response_spec.rb