savon 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/CHANGELOG +11 -0
  2. data/README.rdoc +5 -3
  3. data/Rakefile +2 -0
  4. data/lib/savon.rb +1 -0
  5. data/lib/savon/client.rb +54 -13
  6. data/lib/savon/core_ext.rb +0 -0
  7. data/lib/savon/core_ext/array.rb +20 -6
  8. data/lib/savon/core_ext/datetime.rb +0 -0
  9. data/lib/savon/core_ext/hash.rb +36 -15
  10. data/lib/savon/core_ext/net_http.rb +1 -2
  11. data/lib/savon/core_ext/object.rb +1 -3
  12. data/lib/savon/core_ext/string.rb +9 -2
  13. data/lib/savon/core_ext/symbol.rb +0 -0
  14. data/lib/savon/core_ext/uri.rb +1 -1
  15. data/lib/savon/logger.rb +56 -0
  16. data/lib/savon/request.rb +42 -50
  17. data/lib/savon/response.rb +62 -9
  18. data/lib/savon/soap.rb +157 -42
  19. data/lib/savon/wsdl.rb +71 -6
  20. data/lib/savon/wsdl_stream.rb +2 -2
  21. data/lib/savon/wsse.rb +36 -5
  22. data/spec/basic_spec_helper.rb +0 -0
  23. data/spec/endpoint_helper.rb +0 -0
  24. data/spec/fixtures/response/response_fixture.rb +0 -0
  25. data/spec/fixtures/response/xml/authentication.xml +0 -0
  26. data/spec/fixtures/response/xml/multi_ref.xml +0 -0
  27. data/spec/fixtures/response/xml/soap_fault.xml +0 -0
  28. data/spec/fixtures/response/xml/soap_fault12.xml +0 -0
  29. data/spec/fixtures/wsdl/wsdl_fixture.rb +0 -0
  30. data/spec/fixtures/wsdl/xml/authentication.xml +0 -0
  31. data/spec/fixtures/wsdl/xml/geotrust.xml +0 -0
  32. data/spec/fixtures/wsdl/xml/namespaced_actions.xml +0 -0
  33. data/spec/fixtures/wsdl/xml/no_namespace.xml +0 -0
  34. data/spec/http_stubs.rb +0 -0
  35. data/spec/integration/http_basic_auth_spec.rb +0 -0
  36. data/spec/integration/server.rb +0 -0
  37. data/spec/savon/client_spec.rb +5 -1
  38. data/spec/savon/core_ext/array_spec.rb +0 -0
  39. data/spec/savon/core_ext/datetime_spec.rb +0 -0
  40. data/spec/savon/core_ext/hash_spec.rb +10 -1
  41. data/spec/savon/core_ext/net_http_spec.rb +0 -0
  42. data/spec/savon/core_ext/object_spec.rb +0 -0
  43. data/spec/savon/core_ext/string_spec.rb +6 -2
  44. data/spec/savon/core_ext/symbol_spec.rb +0 -0
  45. data/spec/savon/core_ext/uri_spec.rb +4 -0
  46. data/spec/savon/request_spec.rb +5 -4
  47. data/spec/savon/response_spec.rb +0 -0
  48. data/spec/savon/soap_spec.rb +124 -130
  49. data/spec/savon/wsdl_spec.rb +0 -0
  50. data/spec/savon/wsse_spec.rb +0 -0
  51. data/spec/spec_helper.rb +0 -0
  52. metadata +55 -37
  53. data/readme/client.rdoc +0 -18
  54. data/readme/errors.rdoc +0 -11
  55. data/readme/logging.rdoc +0 -11
  56. data/readme/participate.rdoc +0 -21
  57. data/readme/request.rdoc +0 -37
  58. data/readme/response.rdoc +0 -46
  59. data/readme/soap.rdoc +0 -71
  60. data/readme/value_mapping.rdoc +0 -49
  61. data/readme/wsdl.rdoc +0 -39
  62. data/readme/wsse.rdoc +0 -28
@@ -1,8 +1,8 @@
1
1
  module Savon
2
2
 
3
- # Savon::WSDLStream
3
+ # = Savon::WSDLStream
4
4
  #
5
- # Stream listener for parsing the WSDL document.
5
+ # Savon::WSDLStream serves as a stream listener for parsing the WSDL document.
6
6
  class WSDLStream
7
7
 
8
8
  # The main sections of a WSDL document.
@@ -1,8 +1,39 @@
1
1
  module Savon
2
2
 
3
- # Savon::WSSE
3
+ # = Savon::WSSE
4
4
  #
5
- # Represents parameters for WSSE authentication.
5
+ # Savon::WSSE represents WSSE authentication. Pass a block to your SOAP call and the WSSE object
6
+ # is passed to it as the second argument. The object allows setting the WSSE username, password
7
+ # and whether to use digest authentication.
8
+ #
9
+ # == Credentials
10
+ #
11
+ # By default, Savon does not use WSSE authentication. Simply specify a username and password to
12
+ # change this.
13
+ #
14
+ # response = client.get_all_users do |soap, wsse|
15
+ # wsse.username = "eve"
16
+ # wsse.password = "secret"
17
+ # end
18
+ #
19
+ # == Digest
20
+ #
21
+ # To use WSSE digest authentication, just use the digest method and set it to +true+.
22
+ #
23
+ # response = client.get_all_users do |soap, wsse|
24
+ # wsse.username = "eve"
25
+ # wsse.password = "secret"
26
+ # wsse.digest = true
27
+ # end
28
+ #
29
+ # == Default to WSSE
30
+ #
31
+ # In case all you're services require WSSE authentication, you can set your credentials and whether
32
+ # to use WSSE digest for every request:
33
+ #
34
+ # Savon::WSSE.username = "eve"
35
+ # Savon::WSSE.password = "secret"
36
+ # Savon::WSSE.digest = true
6
37
  class WSSE
7
38
 
8
39
  # Base address for WSSE docs.
@@ -82,13 +113,13 @@ module Savon
82
113
  # Sets whether to use WSSE digest per request.
83
114
  attr_writer :digest
84
115
 
85
- # Returns whether to use WSSE digest. Defaults to the global setting.
116
+ # Returns whether to use WSSE digest. Defaults to the global setting.
86
117
  def digest?
87
118
  @digest || self.class.digest?
88
119
  end
89
120
 
90
- # Returns the XML for a WSSE header or an empty String unless both
91
- # username and password were specified.
121
+ # Returns the XML for a WSSE header or an empty String unless both username and password
122
+ # were specified.
92
123
  def header
93
124
  return "" unless username && password
94
125
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -70,8 +70,12 @@ describe Savon::Client do
70
70
  end
71
71
  end
72
72
 
73
+ it "should have a call method that forwards to method_missing for SOAP actions named after existing methods" do
74
+ @client.call(:authenticate) { |soap| soap.should be_a(Savon::SOAP) }
75
+ end
76
+
73
77
  it "should raise a NoMethodError when the method does not match an available SOAP action or method" do
74
78
  lambda { @client.some_undefined_method }.should raise_error(NoMethodError)
75
79
  end
76
80
 
77
- end
81
+ end
File without changes
File without changes
@@ -73,7 +73,6 @@ describe Hash do
73
73
 
74
74
  it "should call to_s on Strings even if they respond to to_datetime" do
75
75
  object = "gorilla"
76
- object.expects(:to_s).returns object
77
76
  object.expects(:to_datetime).never
78
77
 
79
78
  hash, result = { :name => object }, "<name>gorilla</name>"
@@ -113,6 +112,16 @@ describe Hash do
113
112
  soap_xml = hash.to_soap_xml
114
113
  soap_xml.should include('id="666"', 'city="Hamburg"')
115
114
  end
115
+
116
+ it "should add attributes to duplicate Hash keys specified through :attributes!" do
117
+ hash = { :find_user => { :person => ["Lucy", "Anna"], :attributes! => { :person => { :id => [1, 3] } } } }
118
+ result = '<findUser><person id="1">Lucy</person><person id="3">Anna</person></findUser>'
119
+ hash.to_soap_xml.should == result
120
+
121
+ hash = { :find_user => { :person => ["Lucy", "Anna"], :attributes! => { :person => { :active => "true" } } } }
122
+ result = '<findUser><person active="true">Lucy</person><person active="true">Anna</person></findUser>'
123
+ hash.to_soap_xml.should == result
124
+ end
116
125
  end
117
126
 
118
127
  describe "map_soap_response" do
File without changes
File without changes
@@ -75,8 +75,12 @@ describe String do
75
75
  end
76
76
 
77
77
  describe "to_soap_value" do
78
- it "calls to_s, bypassing Rails to_datetime extension for Strings" do
79
- "string".to_soap_value.should == "string".to_s
78
+ it "should return the string value and escape special characters" do
79
+ "string".to_soap_value.should == "string"
80
+ "<tag>".to_soap_value.should == "&lt;tag&gt;"
81
+ "at&t".to_soap_value.should == "at&amp;t"
82
+ '"quotes"'.to_soap_value.should == "&quot;quotes&quot;"
83
+ "'apos'".to_soap_value.should == "&apos;apos&apos;"
80
84
  end
81
85
  end
82
86
 
File without changes
@@ -10,6 +10,10 @@ describe URI::HTTP do
10
10
  it "returns false for non-https URI's" do
11
11
  URI("http://example.com").ssl?.should be_false
12
12
  end
13
+
14
+ it "returns nil for invalid URI's without a scheme" do
15
+ URI("example").ssl?.should be_nil
16
+ end
13
17
  end
14
18
 
15
19
  end
@@ -22,8 +22,8 @@ describe Savon::Request do
22
22
  end
23
23
 
24
24
  it "has both getter and setter for the logger to use (global setting)" do
25
- Savon::Request.logger = nil
26
- Savon::Request.logger.should be_nil
25
+ Savon::Request.logger = {}
26
+ Savon::Request.logger.should be_a(Hash)
27
27
  Savon::Request.logger = Logger.new STDOUT
28
28
  end
29
29
 
@@ -76,8 +76,9 @@ describe Savon::Request do
76
76
  end
77
77
 
78
78
  it "executes a SOAP request and returns the Net::HTTP response" do
79
- some_operation = WSDLFixture.authentication(:operations)[:authenticate]
80
- soap = Savon::SOAP.new some_operation, EndpointHelper.soap_endpoint
79
+ operation = WSDLFixture.authentication(:operations)[:authenticate]
80
+ action, input = operation[:action], operation[:input]
81
+ soap = Savon::SOAP.new action, input, EndpointHelper.soap_endpoint
81
82
  soap_response = @request.soap soap
82
83
 
83
84
  soap_response.should be_a(Net::HTTPResponse)
File without changes
@@ -2,30 +2,31 @@ require "spec_helper"
2
2
 
3
3
  describe Savon::SOAP do
4
4
  before do
5
- @authenticate_operation = WSDLFixture.authentication(:operations)[:authenticate]
6
- @soap = Savon::SOAP.new @authenticate_operation, EndpointHelper.soap_endpoint
5
+ @operation = WSDLFixture.authentication(:operations)[:authenticate]
6
+ @action, @input = @operation[:action], @operation[:input]
7
+ @soap = Savon::SOAP.new @action, @input, EndpointHelper.soap_endpoint
7
8
  end
8
9
 
9
- it "contains the SOAP namespace for each supported SOAP version" do
10
+ it "should contain the SOAP namespace for each supported SOAP version" do
10
11
  Savon::SOAP::Versions.each do |soap_version|
11
12
  Savon::SOAP::Namespace[soap_version].should be_a(String)
12
13
  Savon::SOAP::Namespace[soap_version].should_not be_empty
13
14
  end
14
15
  end
15
16
 
16
- it "contains the Content-Types for each supported SOAP version" do
17
+ it "should contain the Content-Types for each supported SOAP version" do
17
18
  Savon::SOAP::Versions.each do |soap_version|
18
19
  Savon::SOAP::ContentType[soap_version].should be_a(String)
19
20
  Savon::SOAP::ContentType[soap_version].should_not be_empty
20
21
  end
21
22
  end
22
23
 
23
- it "contains an Array of supported SOAP versions" do
24
+ it "should contain an Array of supported SOAP versions" do
24
25
  Savon::SOAP::Versions.should be_an(Array)
25
26
  Savon::SOAP::Versions.should_not be_empty
26
27
  end
27
28
 
28
- it "contains the xs:dateTime format" do
29
+ it "should contain the xs:dateTime format" do
29
30
  Savon::SOAP::DateTimeFormat.should be_a(String)
30
31
  Savon::SOAP::DateTimeFormat.should_not be_empty
31
32
 
@@ -33,175 +34,168 @@ describe Savon::SOAP do
33
34
  should == "2012-03-22T16:22:33Z"
34
35
  end
35
36
 
36
- it "contains a Regexp matching the xs:dateTime format" do
37
+ it "should contain a Regexp matching the xs:dateTime format" do
37
38
  Savon::SOAP::DateTimeRegexp.should be_a(Regexp)
38
39
  (Savon::SOAP::DateTimeRegexp === "2012-03-22T16:22:33").should be_true
39
40
  end
40
41
 
41
- it "defaults to SOAP 1.1" do
42
+ it "should default to SOAP 1.1" do
42
43
  Savon::SOAP.version.should == 1
43
44
  end
44
45
 
45
- it "has both getter and setter for the SOAP version to use (global setting)" do
46
- [2, 1].each do |soap_version|
47
- Savon::SOAP.version = soap_version
48
- Savon::SOAP.version.should == soap_version
46
+ describe "xml returned via to_xml" do
47
+ before do
48
+ @xml_declaration = '<?xml version="1.0" encoding="UTF-8"?>'
49
+ @namespace = { "xmlns:ns" => "http://example.com" }
50
+ @namespace_string = 'xmlns:ns="http://example.com"'
51
+ @namespaces = { "xmlns:ns" => "http://ns.example.com", "xmlns:ns2" => "http://ns2.example.com" }
52
+
53
+ # reset to defaults
54
+ Savon::SOAP.version = 1
55
+ Savon::SOAP.header = {}
56
+ Savon::SOAP.namespaces = {}
49
57
  end
50
- end
51
-
52
- it "has a setter for the Savon::WSSE" do
53
- @soap.wsse = Savon::WSSE.new
54
- end
55
-
56
- it "has both getter and setter for the SOAP action" do
57
- @soap.action.should == @authenticate_operation[:action]
58
-
59
- @soap.action = "someAction"
60
- @soap.action.should == "someAction"
61
- end
62
-
63
- it "has both getter and setter for the SOAP input" do
64
- @soap.input.should == @authenticate_operation[:input]
65
-
66
- @soap.input = "whatever"
67
- @soap.input.should == "whatever"
68
-
69
- args = "FindUserRequest", { "username" => "auser", "anotherAttr" => "someVal" }
70
- @soap.input = *args
71
- @soap.input.should == [*args]
72
- end
73
-
74
- it "has both getter and setter for global SOAP headers" do
75
- header = { "some" => "header" }
76
- Savon::SOAP.header = header
77
- Savon::SOAP.header.should == header
78
58
 
79
- Savon::SOAP.header = {}
80
- end
81
-
82
- it "has both getter and setter for the SOAP header" do
83
- @soap.header.should be_a(Hash)
84
- @soap.header.should be_empty
85
-
86
- @soap.header = { "specialAuthKey" => "secret" }
87
- @soap.header.should == { "specialAuthKey" => "secret" }
88
- end
59
+ it "should contain an xml declaration" do
60
+ @soap.to_xml.should include(@xml_declaration)
61
+ end
89
62
 
90
- it "has a getter for the SOAP body, expecting a Hash or an XML String" do
91
- @soap.body = { :id => 666 }
92
- @soap.body = "<id>666</id>"
93
- end
63
+ # namespaces
94
64
 
95
- it "has a setter for specifying a Hash of namespaces" do
96
- namespaces = { "xmlns:env" => "http://example.com" }
97
- @soap.namespaces = namespaces
98
- @soap.namespaces.should == namespaces
99
- end
65
+ it "should contain the namespace for SOAP 1.1" do
66
+ @soap.to_xml.should include('xmlns:env="' + Savon::SOAP::Namespace[1] + '"')
67
+ end
100
68
 
101
- describe "has a getter for namespaces" do
102
- it "which defaults to include the SOAP 1.1 namespace" do
103
- @soap.namespaces.should == { "xmlns:env" => Savon::SOAP::Namespace[1] }
69
+ it "should contain the namespace for SOAP 1.2 when defined globally" do
70
+ Savon::SOAP.version = 2
71
+ @soap.to_xml.should include('xmlns:env="' + Savon::SOAP::Namespace[2] + '"')
104
72
  end
105
73
 
106
- it "which contains the SOAP 1.2 namespace if specified" do
74
+ it "should contain the namespace for SOAP 1.2 when defined per request" do
107
75
  @soap.version = 2
108
- @soap.namespaces.should == { "xmlns:env" => Savon::SOAP::Namespace[2] }
76
+ @soap.to_xml.should include('xmlns:env="' + Savon::SOAP::Namespace[2] + '"')
109
77
  end
110
- end
111
78
 
112
- it "has both getter and setter for global namespaces" do
113
- namespaces = { "some" => "namespace" }
114
- Savon::SOAP.namespaces = namespaces
115
- Savon::SOAP.namespaces.should == namespaces
79
+ it "should containg a xmlns:wsdl namespace defined via the :namespace shortcut method" do
80
+ @soap.namespace = "http://wsdl.example.com"
81
+ @soap.to_xml.should include('xmlns:wsdl="http://wsdl.example.com"')
82
+ end
116
83
 
117
- Savon::SOAP.namespaces = {}
118
- end
84
+ it "should accept custom namespaces when defined globally" do
85
+ Savon::SOAP.namespaces = @namespace
86
+ @soap.to_xml.should include("<env:Envelope " + @namespace_string)
87
+ end
119
88
 
120
- it "has a convenience method for setting the 'xmlns:wsdl' namespace" do
121
- @soap.namespaces.should == { "xmlns:env" => "http://schemas.xmlsoap.org/soap/envelope/" }
89
+ it "should accept custom namespaces when defined per request" do
90
+ @soap.namespaces = @namespace
91
+ @soap.to_xml.should include("<env:Envelope " + @namespace_string)
92
+ end
122
93
 
123
- @soap.namespace = "http://example.com"
124
- @soap.namespaces.should include("xmlns:env" => "http://schemas.xmlsoap.org/soap/envelope/")
125
- @soap.namespaces.should include("xmlns:wsdl" => "http://example.com")
126
- end
94
+ it "should merge global and per request namespaces" do
95
+ Savon::SOAP.namespaces = @namespaces
96
+ @soap.namespaces = @namespace
97
+ @soap.to_xml.should include(
98
+ 'xmlns:ns="http://example.com"',
99
+ 'xmlns:ns2="http://ns2.example.com"'
100
+ )
101
+ end
127
102
 
128
- it "has both getter and setter for the SOAP endpoint" do
129
- soap_endpoint = URI EndpointHelper.soap_endpoint
103
+ # header
130
104
 
131
- @soap.endpoint = soap_endpoint
132
- @soap.endpoint.should == soap_endpoint
133
- end
105
+ it "should not contain a header tag unless specified" do
106
+ @soap.to_xml.should_not include("<env:Header>")
107
+ end
134
108
 
135
- it "has a getter for the SOAP version to use which defaults to SOAP 1.1" do
136
- @soap.version.should == Savon::SOAP.version
137
- end
109
+ it "should accept a custom (String) header defined globally" do
110
+ Savon::SOAP.header = "<key>value</key>"
111
+ @soap.to_xml.should include("<env:Header><key>value</key></env:Header>")
112
+ end
138
113
 
139
- it "has a setter for specifying the SOAP version to use" do
140
- @soap.version = 2
141
- @soap.version.should == 2
142
- end
114
+ it "should accept a custom (Hash) header defined globally" do
115
+ Savon::SOAP.header[:key] = "value"
116
+ @soap.to_xml.should include("<env:Header><key>value</key></env:Header>")
117
+ end
143
118
 
144
- describe "to_xml" do
145
- after { Savon::SOAP.version = 1 }
119
+ it "should accept a custom (String) header defined per request" do
120
+ @soap.header = "<key>value</key>"
121
+ @soap.to_xml.should include("<env:Header><key>value</key></env:Header>")
122
+ end
146
123
 
147
- it "returns the XML for a SOAP request" do
148
- @soap.namespaces["xmlns:wsdl"] = "http://v1_0.ws.auth.order.example.com/"
149
- @soap.body = { :id => 666 }
124
+ it "should accept a custom (Hash) header defined per request" do
125
+ @soap.header[:key] = "value"
126
+ @soap.to_xml.should include("<env:Header><key>value</key></env:Header>")
127
+ end
150
128
 
151
- xml = @soap.to_xml
152
- xml.should include('xmlns:wsdl="http://v1_0.ws.auth.order.example.com/"')
153
- xml.should include('xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"')
154
- xml.should include('<wsdl:authenticate><id>666</id></wsdl:authenticate>')
129
+ it "should merge global and per request headers defined as Strings" do
130
+ Savon::SOAP.header = "<key2>other value</key2>"
131
+ @soap.header = "<key>value</key>"
132
+ @soap.to_xml.should include(
133
+ "<env:Header><key2>other value</key2><key>value</key></env:Header>"
134
+ )
155
135
  end
156
136
 
157
- it "does not include an empty header tag" do
158
- @soap.to_xml.should_not include('env:Header')
137
+ it "should merge global and per request headers defined as Hashes" do
138
+ Savon::SOAP.header = { :key => "value", :key2 => "global value" }
139
+ @soap.header[:key2] = "request value"
140
+ @soap.to_xml.should include(
141
+ "<env:Header><key>value</key><key2>request value</key2></env:Header>"
142
+ )
159
143
  end
160
-
161
- it "returns the appropriate XML for a SOAP Body's root node when parameters are present" do
162
- @soap.input = "authenticate", { "protocol" => "tls", "version" => "1.2" }
163
- @soap.body = { :id => 666 }
164
144
 
165
- @soap.to_xml.should include('<wsdl:authenticate protocol="tls" version="1.2"><id>666</id></wsdl:authenticate>')
145
+ it "should use the :header method from a given WSSE object to include a WSSE header" do
146
+ wsse = "some compliant object"
147
+ wsse.stubs(:header).returns("<wsse>authentication</wsse>")
148
+
149
+ @soap.wsse = wsse
150
+ @soap.to_xml.should include("<env:Header><wsse>authentication</wsse></env:Header>")
166
151
  end
167
152
 
168
- it "caches the XML, returning the same Object every time" do
169
- @soap.to_xml.object_id.should == @soap.to_xml.object_id
153
+ # input tag
154
+
155
+ it "should contain a :wsdl namespaced input tag matching the :input property on instantiation" do
156
+ @soap = Savon::SOAP.new "someAction", "someInput", EndpointHelper.soap_endpoint
157
+ @soap.to_xml.should include('<wsdl:someInput>')
170
158
  end
171
159
 
172
- it "uses the SOAP namespace for the specified SOAP version" do
173
- @soap.version = 2
174
- @soap.to_xml.should include(Savon::SOAP::Namespace[2])
160
+ it "should fall back to using the :action property whem :input is blank" do
161
+ @soap = Savon::SOAP.new "someAction", "", EndpointHelper.soap_endpoint
162
+ @soap.to_xml.should include('<wsdl:someAction>')
175
163
  end
176
164
 
177
- it "uses the SOAP namespace for the default SOAP version otherwise" do
178
- Savon::SOAP.version = 2
179
- @soap.to_xml.should include(Savon::SOAP::Namespace[2])
165
+ it "should containg namespaces defined via an input tag Array containing the tag name and a Hash of namespaces" do
166
+ input = ["someInput", { "otherNs" => "http://otherns.example.com" }]
167
+ @soap = Savon::SOAP.new "someAction", input, EndpointHelper.soap_endpoint
168
+ @soap.to_xml.should include('<wsdl:someInput otherNs="http://otherns.example.com">')
180
169
  end
181
170
 
182
- it "merges global and per request headers defined as Hashes" do
183
- Savon::SOAP.header = { "API-KEY" => "secret", "SOME-KEY" => "something" }
184
- @soap.header["SOME-KEY"] = "somethingelse"
171
+ # xml body
185
172
 
186
- @soap.to_xml.should include("<API-KEY>secret</API-KEY>")
187
- @soap.to_xml.should include("<SOME-KEY>somethingelse</SOME-KEY>")
173
+ it "should contain the SOAP body defined as a Hash" do
174
+ @soap.body = { :someTag => "some value" }
175
+ @soap.to_xml.should include("<someTag>some value</someTag>")
188
176
  end
189
177
 
190
- it "joins global and per request headers defined as Strings" do
191
- Savon::SOAP.header = "<API-KEY>secret</API-KEY>"
192
- @soap.header = "<SOME-KEY>somethingelse</SOME-KEY>"
178
+ it "should contain the SOAP body defined as an Object responding to :to_s" do
179
+ @soap.body = "<someTag>some value</someTag>"
180
+ @soap.to_xml.should include(@soap.body)
181
+ end
193
182
 
194
- @soap.to_xml.should include("<API-KEY>secret</API-KEY>")
195
- @soap.to_xml.should include("<SOME-KEY>somethingelse</SOME-KEY>")
183
+ # xml
184
+
185
+ it "should be a completely custom XML when specified" do
186
+ @soap.xml = "custom SOAP body"
187
+ @soap.to_xml.should == @soap.xml
196
188
  end
197
189
 
198
- it "merges the global and per request namespaces" do
199
- Savon::SOAP.namespaces = { "xmlns:wsdl" => "namespace", "xmlns:v1" => "v1namespace" }
200
- @soap.namespaces["xmlns:v1"] = "newV1namespace"
190
+ # safety check
201
191
 
202
- @soap.to_xml.should include('xmlns:wsdl="namespace"')
203
- @soap.to_xml.should include('xmlns:v1="newV1namespace"')
192
+ it "should be a valid SOAP request" do
193
+ @soap.to_xml.should include(
194
+ @xml_declaration +
195
+ '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">' <<
196
+ '<env:Body><wsdl:authenticate></wsdl:authenticate></env:Body>' <<
197
+ '</env:Envelope>'
198
+ )
204
199
  end
205
200
  end
206
-
207
- end
201
+ end