Sha256: a6e832ddd55f526ab6a5806d7b7ab82f420474eb261370fe4779dbab109c3e50

Contents?: true

Size: 1.52 KB

Versions: 6

Compression:

Stored size: 1.52 KB

Contents

require "spec_helper"

describe Savon::Wasabi::Document do

  context "with a remote document" do
    before do
      response = HTTPI::Response.new 200, {}, Fixture.wsdl(:authentication)
      HTTPI.stubs(:get).returns(response)
    end

    it "should resolve via HTTP" do
      wsdl = Savon::Wasabi::Document.new("http://example.com?wsdl")
      wsdl.xml.should == Fixture.wsdl(:authentication)
    end

    it "should resolve via HTTPS" do
      wsdl = Savon::Wasabi::Document.new("https://example.com?wsdl")
      wsdl.xml.should == Fixture.wsdl(:authentication)
    end

  end

  context "with an inaccessible remote document" do
    before do
      response = HTTPI::Response.new 401, {}, Fixture.wsdl(:authentication)
      HTTPI.stubs(:get).returns(response)
    end

    it "should raise an error when authentication fails" do
      wsdl = Savon::Wasabi::Document.new("http://example.com?wsdl")
      expect { wsdl.xml }.to raise_error(Savon::HTTP::Error)
    end
  end

  context "with a local document" do
    before do
      HTTPI.expects(:get).never
    end

    it "should read the file" do
      wsdl = Savon::Wasabi::Document.new("spec/fixtures/wsdl/authentication.xml")
      wsdl.xml.should == Fixture.wsdl(:authentication)
    end
  end

  context "with raw XML" do
    before do
      HTTPI.expects(:get).never
      File.expects(:read).never
    end

    it "should use the raw XML" do
      wsdl = Savon::Wasabi::Document.new Fixture.wsdl(:authentication)
      wsdl.xml.should == Fixture.wsdl(:authentication)
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
savon-1.1.0 spec/savon/wasabi/document_spec.rb
savon-1.0.0 spec/savon/wasabi/document_spec.rb
savon-0.9.14 spec/savon/wasabi/document_spec.rb
savon-0.9.11 spec/savon/wasabi/document_spec.rb
savon-0.9.10 spec/savon/wasabi/document_spec.rb
savon-0.9.9 spec/savon/wasabi/document_spec.rb