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
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/savon-0.9.5/spec/savon/http/error_spec.rb
savon-1.1.0 spec/savon/http/error_spec.rb
savon-1.0.0 spec/savon/http/error_spec.rb
savon-0.9.14 spec/savon/http/error_spec.rb
savon-0.9.11 spec/savon/http/error_spec.rb
savon-0.9.10 spec/savon/http/error_spec.rb
savon-0.9.9 spec/savon/http/error_spec.rb
savon-0.9.8 spec/savon/http/error_spec.rb
they-savon-0.9.7.1 spec/savon/http/error_spec.rb
regenersis-savon-1.0.0 spec/savon/http/error_spec.rb
they-savon-0.9.7 spec/savon/http/error_spec.rb
savon-0.9.7 spec/savon/http/error_spec.rb
savon-0.9.6 spec/savon/http/error_spec.rb
savon-0.9.5 spec/savon/http/error_spec.rb
savon-0.9.4 spec/savon/http/error_spec.rb
savon-0.9.3 spec/savon/http/error_spec.rb
search_biomodel-1.0.0 search_biomodel/ruby/1.8/gems/savon-0.9.2/spec/savon/http/error_spec.rb
savon-0.9.2 spec/savon/http/error_spec.rb
s-savon-0.8.6 spec/savon/http/error_spec.rb
savon-0.9.1 spec/savon/http/error_spec.rb