Sha256: 502073acb9f5fb126608a70d4e289cb5781b51a12220c720a02be411a194cc45

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

require "spec_helper"
require "integration/support/server"

describe Savon::Operation do

  let(:globals) { Savon::GlobalOptions.new(:endpoint => @server.url(:repeat), :log => false) }
  let(:wsdl)    { Wasabi::Document.new Fixture.wsdl(:authentication) }
  let(:no_wsdl) { Wasabi::Document.new }

  before :all do
    @server = IntegrationServer.run
  end

  after :all do
    @server.stop
  end

  describe ".create with a WSDL" do
    it "returns a new operation" do
      operation = Savon::Operation.create(:authenticate, wsdl, globals)
      expect(operation).to be_a(Savon::Operation)
    end

    it "raises if the operation name is not a Symbol" do
      expect { Savon::Operation.create("not a symbol", wsdl, globals) }.
        to raise_error(ArgumentError, /Expected the first parameter \(the name of the operation to call\) to be a symbol/)
    end

    it "raises if the operation is not available for the service" do
      expect { Savon::Operation.create(:no_such_operation, wsdl, globals) }.
        to raise_error(ArgumentError, /Unable to find SOAP operation: :no_such_operation/)
    end
  end

  describe ".create without a WSDL" do
    it "returns a new operation" do
      operation = Savon::Operation.create(:authenticate, no_wsdl, globals)
      expect(operation).to be_a(Savon::Operation)
    end
  end

  describe "#call" do
    it "returns a response object" do
      operation = Savon::Operation.create(:authenticate, wsdl, globals)
      expect(operation.call).to be_a(Savon::Response)
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
savon-2.0.3 spec/savon/operation_spec.rb
savon-2.0.2 spec/savon/operation_spec.rb
savon-2.0.1 spec/savon/operation_spec.rb
savon-2.0.0 spec/savon/operation_spec.rb