Sha256: 022417fc92d5ae9e41880238eb65cb041dfa0f4480bdcba644c4400f09b983c1

Contents?: true

Size: 1.69 KB

Versions: 11

Compression:

Stored size: 1.69 KB

Contents

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

describe Savon::Message do

  before do
    @server = IntegrationServer.run
  end

  after do
    @server.stop
  end

  let(:client_config) {
    {
      :endpoint => @server.url(:repeat),
      :namespace => 'http://example.com',
      :log => false,

      :element_form_default => :qualified,
      :convert_request_keys_to => :camelcase,

      :convert_response_tags_to => nil
    }
  }

  let(:client) { Savon.client(client_config) }

  context "with a qualified message" do
    let(:message) {
      {
       :email_count => 3,
       :user_name   => 'josh',
       :order!      => [:user_name, :email_count]
      }
    }

    let(:converted_keys) {
      '<wsdl:UserName>josh</wsdl:UserName><wsdl:EmailCount>3</wsdl:EmailCount>'
    }
    it "converts request Hash keys for which there is not namespace" do
      response = client.call(:something, :message => message)
      expect(response.xml).to include(converted_keys)
    end
  end

  context 'use_wsa_headers' do
    let(:client_config) { super().merge(use_wsa_headers: true) }

    context 'headers' do
      [ 'wsa:Action', 'wsa:To', 'wsa:MessageID' ].each do |header|
        it "should include #{header} header" do
          response = client.call(:something, message: {})
          expect(response.xml).to include(header)
        end
      end
    end

    context 'wsa:MessageID' do
      let(:message_id_tag) {
        '<wsa:MessageID xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">'
      }
      it 'should include xmlns:wsa attribute' do
        response = client.call(:something, message: {})
        expect(response.xml).to include(message_id_tag)
      end
    end
  end

end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
savon-2.12.1 spec/savon/message_spec.rb
savon-2.12.0 spec/savon/message_spec.rb
savon-2.11.2 spec/savon/message_spec.rb
savon-SU-2.11.1b spec/savon/message_spec.rb
savon-SU-2.11.1 spec/savon/message_spec.rb
savon-2.11.1 spec/savon/message_spec.rb
savon-2.11.0 spec/savon/message_spec.rb
savon-2.10.1 spec/savon/message_spec.rb
savon-2.10.0 spec/savon/message_spec.rb
savon-2.9.0 spec/savon/message_spec.rb
savon-2.8.1 spec/savon/message_spec.rb