test/unit/test_envelope.rb in lolsoap-0.1.4 vs test/unit/test_envelope.rb in lolsoap-0.2.0

- old
+ new

@@ -1,11 +1,17 @@ require 'helper' require 'lolsoap/envelope' module LolSoap describe Envelope do - let(:wsdl) { OpenStruct.new(:type_namespaces => { 'foo' => 'http://example.com/foo' }) } + let(:wsdl) do + OpenStruct.new( + :type_namespaces => { 'foo' => 'http://example.com/foo' }, + :soap_version => '1.2' + ) + end + let(:operation) do OpenStruct.new(:input => OpenStruct.new(:prefix => 'foo', :name => 'WashHandsRequest')) end subject { Envelope.new(wsdl, operation) } @@ -14,11 +20,11 @@ let(:header) { doc.at_xpath('/soap:Envelope/soap:Header', doc.namespaces) } let(:input) { doc.at_xpath('/soap:Envelope/soap:Body/foo:WashHandsRequest', doc.namespaces) } it 'has a skeleton SOAP envelope structure when first created' do doc.namespaces.must_equal( - 'xmlns:soap' => Envelope::SOAP_NAMESPACE, + 'xmlns:soap' => Envelope::SOAP_1_2, 'xmlns:foo' => 'http://example.com/foo' ) header.wont_equal nil header.children.length.must_equal 0 @@ -82,11 +88,15 @@ end end describe '#to_xml' do it 'returns the xml of the doc' do - def subject.doc; OpenStruct.new(:to_xml => '<lol>'); end + def subject.doc + doc = Object.new + def doc.to_xml(options); '<lol>'; end + doc + end subject.to_xml.must_equal '<lol>' end end describe '#action' do @@ -104,9 +114,19 @@ describe '#output' do it "returns the operation's output" do operation.output = 'lol' subject.output_type.must_equal 'lol' + end + end + + describe '#soap_namespace' do + it 'returns the correct envelope namespace according to the SOAP version' do + wsdl.soap_version = '1.2' + subject.soap_namespace.must_equal Envelope::SOAP_1_2 + + wsdl.soap_version = '1.1' + subject.soap_namespace.must_equal Envelope::SOAP_1_1 end end end end