Sha256: a88c065bd3da1f27a080cf848a7f9eea92233356e2ed483857ca692144f94c68

Contents?: true

Size: 1.43 KB

Versions: 28

Compression:

Stored size: 1.43 KB

Contents

require "spec_helper"

describe Savon::HTTP::Error do
  let(:http_error) { Savon::HTTP::Error.new new_response(:code => 404, :body => "Not Found") }
  let(:no_error) { Savon::HTTP::Error.new new_response }

  it "should be a Savon::Error" do
    Savon::HTTP::Error.should < Savon::Error
  end

  describe "#http" do
    it "should return the HTTPI::Response" do
      http_error.http.should be_an(HTTPI::Response)
    end
  end

  describe "#present?" do
    it "should return true if there was an HTTP error" do
      http_error.should be_present
    end

    it "should return false unless there was an HTTP error" do
      no_error.should_not be_present
    end
  end

  [:message, :to_s].each do |method|
    describe "##{method}" do
      it "should return an empty String unless an HTTP error is present" do
        no_error.send(method).should == ""
      end

      it "should return the HTTP error message" do
        http_error.send(method).should == "HTTP error (404): Not Found"
      end
    end
  end

  describe "#to_hash" do
    it "should return the HTTP response details as a Hash" do
      http_error.to_hash.should == { :code => 404, :headers => {}, :body => "Not Found" }
    end
  end

  def new_response(options = {})
    defaults = { :code => 200, :headers => {}, :body => Fixture.response(:authentication) }
    response = defaults.merge options
    
    HTTPI::Response.new response[:code], response[:headers], response[:body]
  end

end

Version data entries

28 entries across 28 versions & 6 rubygems

Version Path
savon-0.9.0 spec/savon/http/error_spec.rb
savon-0.8.6 spec/savon/http/error_spec.rb
savon-0.8.5 spec/savon/http/error_spec.rb
savon-0.8.4 spec/savon/http/error_spec.rb
savon-0.8.3 spec/savon/http/error_spec.rb
savon-0.8.2 spec/savon/http/error_spec.rb
savon-0.8.1 spec/savon/http/error_spec.rb
savon-0.8.0 spec/savon/http/error_spec.rb