Sha256: aa24cba2d4bc060f5ab7a7becb51d53dd5a237b28535ca54358da5ebddec8960

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

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


describe RTurk::Response do
  
  context "given an invalid response" do
  
    before(:all) do
      @invalid_credentials_xml = File.read(File.join(SPEC_ROOT,'fake_responses','invalid_credentials.xml'))
      
    end
    
    it "should know it failed" do
      lambda{RTurk::Response.new(@invalid_credentials_xml)}.should raise_error RTurk::InvalidRequest
    end
    
    it "should know why" do
      begin
        RTurk::Response.new(@invalid_credentials_xml)
      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(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

6 entries across 6 versions & 1 rubygems

Version Path
rturk-2.0.5 spec/response_spec.rb
rturk-2.0.4 spec/response_spec.rb
rturk-2.0.3 spec/response_spec.rb
rturk-2.0.2 spec/response_spec.rb
rturk-2.0.1 spec/response_spec.rb
rturk-2.0.0 spec/response_spec.rb