Sha256: b399da50c224fc72ea5acff4f113d6391c8c19104127d279ed1ef9ae3c918c77

Contents?: true

Size: 1.36 KB

Versions: 1

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/xsd1: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('//xsd1:TradePriceRequest/xsd1:tickerSymbol', doc.namespaces)
      el.wont_equal nil
      el.text.to_s.must_equal 'LOCO2'

      el = doc.at_xpath('//xsd1:TradePriceRequest/xsd1:specialTickerSymbol/xsd2:name', doc.namespaces)
      el.wont_equal nil
      el.text.to_s.must_equal 'LOCOLOCOLOCO'

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

    it 'creates some header' do
      subject.header do |h|
        h['xsd1'].verySpecialBoolean true
      end

      el = doc.at_xpath('/soap:Envelope/soap:Header/xsd1:verySpecialBoolean', doc.namespaces)
      el.wont_equal nil
      el.text.to_s.must_equal 'true'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lolsoap-0.2.0 test/integration/test_envelope.rb