Sha256: c69fecbd0793abbbc9e6db70a6b61096372085d503c98dccf6ca24dcce9916db

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require 'helper'
require 'lolsoap/envelope'
require 'lolsoap/wsdl'

module LolSoap
  describe Envelope do
    let(:wsdl) { WSDL.parse(File.read(TEST_ROOT + '/fixtures/stock_quote.wsdl')) }
    subject { Envelope.new(wsdl, wsdl.operations['GetLastTradePrice']) }

    let(:doc) { subject.doc }

    it 'creates an empty envelope' do
      body = doc.at_xpath('/soap:Envelope/soap:Body/ns0:tradePriceRequest', doc.namespaces)
      body.wont_equal nil
    end

    it 'creates some input' do
      subject.body do |b|
        b.tickerSymbol 'LOCO2'
        b.specialTickerSymbol do |s|
          s.name 'LOCOLOCOLOCO'
        end
        b.lol
        b.id 42
      end

      el = doc.at_xpath('//ns0:tradePriceRequest/ns0:tickerSymbol', doc.namespaces)
      el.wont_equal nil
      el.text.to_s.must_equal 'LOCO2'

      el = doc.at_xpath('//ns0:tradePriceRequest/ns0:specialTickerSymbol/ns1:name', doc.namespaces)
      el.wont_equal nil
      el.text.to_s.must_equal 'LOCOLOCOLOCO'

      attr = doc.at_xpath('//ns0:tradePriceRequest/@id', doc.namespaces)
      attr.to_s.must_equal "42"
    end

    it 'creates some header' do
      subject.header do |h|
        h['ns0'].username 'LOCO2'
      end

      el = doc.at_xpath('/soap:Envelope/soap:Header/ns0:tradePriceRequestHeader/ns0:username', doc.namespaces)
      el.wont_equal nil
      el.text.to_s.must_equal 'LOCO2'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lolsoap-0.6.1 test/integration/test_envelope.rb
lolsoap-0.6.0 test/integration/test_envelope.rb