savon 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. data/CHANGELOG +112 -0
  2. data/README.textile +42 -35
  3. data/Rakefile +28 -33
  4. data/lib/savon/client.rb +42 -19
  5. data/lib/savon/core_ext/hash.rb +35 -22
  6. data/lib/savon/core_ext/net_http.rb +20 -0
  7. data/lib/savon/core_ext/object.rb +7 -0
  8. data/lib/savon/core_ext/string.rb +1 -1
  9. data/lib/savon/core_ext.rb +2 -2
  10. data/lib/savon/request.rb +73 -33
  11. data/lib/savon/response.rb +23 -36
  12. data/lib/savon/soap.rb +63 -30
  13. data/lib/savon/wsdl.rb +82 -35
  14. data/lib/savon/wsse.rb +41 -35
  15. data/lib/savon.rb +3 -2
  16. data/spec/basic_spec_helper.rb +12 -0
  17. data/spec/endpoint_helper.rb +22 -0
  18. data/spec/fixtures/response/response_fixture.rb +36 -0
  19. data/spec/fixtures/response/xml/authentication.xml +14 -0
  20. data/spec/fixtures/response/xml/multi_ref.xml +39 -0
  21. data/spec/fixtures/response/xml/soap_fault12.xml +18 -0
  22. data/spec/fixtures/wsdl/wsdl_fixture.rb +37 -0
  23. data/spec/fixtures/wsdl/xml/authentication.xml +63 -0
  24. data/spec/fixtures/wsdl/xml/namespaced_actions.xml +307 -0
  25. data/spec/fixtures/wsdl/xml/no_namespace.xml +115 -0
  26. data/spec/http_stubs.rb +17 -19
  27. data/spec/integration/http_basic_auth_spec.rb +12 -0
  28. data/spec/integration/server.rb +51 -0
  29. data/spec/savon/client_spec.rb +52 -44
  30. data/spec/savon/core_ext/datetime_spec.rb +2 -2
  31. data/spec/savon/core_ext/hash_spec.rb +34 -31
  32. data/spec/savon/core_ext/net_http_spec.rb +38 -0
  33. data/spec/savon/core_ext/object_spec.rb +16 -2
  34. data/spec/savon/core_ext/string_spec.rb +4 -4
  35. data/spec/savon/core_ext/symbol_spec.rb +1 -1
  36. data/spec/savon/core_ext/uri_spec.rb +1 -1
  37. data/spec/savon/request_spec.rb +49 -63
  38. data/spec/savon/response_spec.rb +48 -51
  39. data/spec/savon/savon_spec.rb +12 -19
  40. data/spec/savon/soap_spec.rb +81 -90
  41. data/spec/savon/wsdl_spec.rb +62 -30
  42. data/spec/savon/wsse_spec.rb +58 -84
  43. data/spec/spec_helper.rb +3 -13
  44. metadata +29 -15
  45. data/VERSION +0 -1
  46. data/spec/fixtures/multiple_user_response.xml +0 -22
  47. data/spec/fixtures/user_fixture.rb +0 -54
  48. data/spec/fixtures/user_response.xml +0 -15
  49. data/spec/fixtures/user_wsdl.xml +0 -124
  50. data/spec/spec_helper_methods.rb +0 -33
  51. /data/spec/fixtures/{soap_fault.xml → response/xml/soap_fault.xml} +0 -0
@@ -1,92 +1,78 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Savon::Request do
4
- before { @request = some_request_instance }
4
+ before { @request = Savon::Request.new EndpointHelper.wsdl_endpoint }
5
5
 
6
- def some_request_instance
7
- Savon::Request.new SpecHelper.some_endpoint
6
+ it "contains the ContentType for each supported SOAP version" do
7
+ Savon::SOAPVersions.each do |soap_version|
8
+ Savon::Request::ContentType[soap_version].should be_a(String)
9
+ Savon::Request::ContentType[soap_version].should_not be_empty
10
+ end
8
11
  end
9
12
 
10
- def some_soap_instance(options = {})
11
- Savon::SOAP.new UserFixture.soap_actions[:find_user]
12
- end
13
+ # defaults to log request and response. disabled for spec execution
13
14
 
14
- describe "ContentType" do
15
- it "contains the ContentType for each supported SOAP version" do
16
- Savon::SOAPVersions.each do |soap_version|
17
- Savon::Request::ContentType[soap_version].should be_a String
18
- Savon::Request::ContentType[soap_version].should_not be_empty
19
- end
20
- end
15
+ it "has both getter and setter for whether to log (global setting)" do
16
+ Savon::Request.log = true
17
+ Savon::Request.log?.should be_true
18
+ Savon::Request.log = false
19
+ Savon::Request.log?.should be_false
21
20
  end
22
21
 
23
- describe "@log" do
24
- # It defaults to true, but it's turned off for spec execution.
22
+ it "defaults to use a Logger instance for logging" do
23
+ Savon::Request.logger.should be_a(Logger)
24
+ end
25
25
 
26
- it "has accessor methods" do
27
- Savon::Request.log = true
28
- Savon::Request.log?.should be_true
29
- Savon::Request.log = false
30
- Savon::Request.log?.should be_false
31
- end
26
+ it "has both getter and setter for the logger to use (global setting)" do
27
+ Savon::Request.logger = nil
28
+ Savon::Request.logger.should be_nil
29
+ Savon::Request.logger = Logger.new STDOUT
32
30
  end
33
31
 
34
- describe "@logger" do
35
- it "defaults to Logger" do
36
- Savon::Request.logger.should be_a Logger
37
- end
32
+ it "defaults to :debug for logging" do
33
+ Savon::Request.log_level.should == :debug
34
+ end
38
35
 
39
- it "has accessor methods" do
40
- Savon::Request.logger = nil
41
- Savon::Request.logger.should be_nil
42
- Savon::Request.logger = Logger.new STDOUT
43
- end
36
+ it "has both getter and setter for the log level to use (global setting)" do
37
+ Savon::Request.log_level = :info
38
+ Savon::Request.log_level.should == :info
39
+ Savon::Request.log_level = :debug
44
40
  end
45
41
 
46
- describe "@log_level" do
47
- it "defaults to :debug" do
48
- Savon::Request.log_level.should == :debug
49
- end
42
+ it "is initialized with a SOAP endpoint String" do
43
+ Savon::Request.new EndpointHelper.wsdl_endpoint
44
+ end
50
45
 
51
- it "has accessor methods" do
52
- Savon::Request.log_level = :info
53
- Savon::Request.log_level.should == :info
54
- Savon::Request.log_level = :debug
55
- end
46
+ it "has a getter for the SOAP endpoint URI" do
47
+ @request.endpoint.should == URI(EndpointHelper.wsdl_endpoint)
56
48
  end
57
49
 
58
- describe "initialize" do
59
- it "expects a SOAP endpoint String" do
60
- some_request_instance
61
- end
50
+ it "should have a getter for the proxy URI" do
51
+ @request.proxy.should == URI("")
52
+ end
62
53
 
63
- it "raises an ArgumentError in case of an invaluid endpoint" do
64
- lambda { Savon::Request.new "invalid" }.should raise_error ArgumentError
65
- end
54
+ it "should return the Net::HTTP object" do
55
+ @request.http.should be_kind_of(Net::HTTP)
66
56
  end
67
57
 
68
- describe "endpoint" do
69
- it "returns the SOAP endpoint URI" do
70
- @request.endpoint.should == SpecHelper.some_endpoint_uri
71
- end
58
+ it "should have a method for setting HTTP basic auth credentials" do
59
+ @request.basic_auth "user", "password"
72
60
  end
73
61
 
74
- describe "wsdl" do
75
- it "retrieves the WSDL document and returns the Net::HTTPResponse" do
76
- wsdl_response = @request.wsdl
62
+ it "retrieves the WSDL document and returns the Net::HTTP response" do
63
+ wsdl_response = @request.wsdl
77
64
 
78
- wsdl_response.should be_a Net::HTTPResponse
79
- wsdl_response.body.should == UserFixture.user_wsdl
80
- end
65
+ wsdl_response.should be_a(Net::HTTPResponse)
66
+ wsdl_response.body.should == WSDLFixture.authentication
81
67
  end
82
68
 
83
- describe "soap" do
84
- it "executes a SOAP request and returns the Net::HTTPResponse" do
85
- soap_response = @request.soap some_soap_instance
69
+ it "executes a SOAP request and returns the Net::HTTP response" do
70
+ soap = Savon::SOAP.new
71
+ soap.endpoint = URI EndpointHelper.wsdl_endpoint
72
+ soap_response = @request.soap soap
86
73
 
87
- soap_response.should be_a Net::HTTPResponse
88
- soap_response.body.should == UserFixture.user_response
89
- end
74
+ soap_response.should be_a(Net::HTTPResponse)
75
+ soap_response.body.should == ResponseFixture.authentication
90
76
  end
91
77
 
92
- end
78
+ end
@@ -1,54 +1,40 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Savon::Response do
4
- before { @response = some_response_instance }
4
+ before { @response = Savon::Response.new http_response_mock }
5
5
 
6
- def some_response_instance
7
- Savon::Response.new http_response_mock
6
+ it "defaults to raises both Savon::SOAPFault and Savon::HTTPError" do
7
+ Savon::Response.raise_errors?.should be_true
8
8
  end
9
9
 
10
- def soap_fault_response_instance
11
- Savon::Response.new http_response_mock(200, UserFixture.soap_fault)
12
- end
13
-
14
- def http_error_response_instance
15
- Savon::Response.new http_response_mock(404, "", "Not found")
16
- end
17
-
18
- describe "@raise_errors" do
19
- it "defaults to true" do
20
- Savon::Response.raise_errors?.should be_true
21
- end
22
-
23
- it "has accessor methods" do
24
- Savon::Response.raise_errors = false
25
- Savon::Response.raise_errors?.should == false
26
- Savon::Response.raise_errors = true
27
- end
10
+ it "has both getter and setter for whether to raise errors (global setting)" do
11
+ Savon::Response.raise_errors = false
12
+ Savon::Response.raise_errors?.should == false
13
+ Savon::Response.raise_errors = true
28
14
  end
29
15
 
30
16
  describe "initialize" do
31
17
  it "expects a Net::HTTPResponse" do
32
- some_response_instance
18
+ Savon::Response.new http_response_mock
33
19
  end
34
20
 
35
21
  it "raises a Savon::SOAPFault in case of a SOAP fault" do
36
- lambda { soap_fault_response_instance }.should raise_error Savon::SOAPFault
22
+ lambda { savon_response_with :soap_fault }.should raise_error(Savon::SOAPFault)
37
23
  end
38
24
 
39
25
  it "does not raise a Savon::SOAPFault in case the default is turned off" do
40
26
  Savon::Response.raise_errors = false
41
- soap_fault_response_instance
27
+ savon_response_with :soap_fault
42
28
  Savon::Response.raise_errors = true
43
29
  end
44
30
 
45
31
  it "raises a Savon::HTTPError in case of an HTTP error" do
46
- lambda { http_error_response_instance }.should raise_error Savon::HTTPError
32
+ lambda { savon_response_with :http_error }.should raise_error(Savon::HTTPError)
47
33
  end
48
34
 
49
35
  it "does not raise a Savon::HTTPError in case the default is turned off" do
50
36
  Savon::Response.raise_errors = false
51
- http_error_response_instance
37
+ savon_response_with :http_error
52
38
  Savon::Response.raise_errors = true
53
39
  end
54
40
  end
@@ -61,8 +47,7 @@ describe Savon::Response do
61
47
  end
62
48
 
63
49
  it "returns true in case of a SOAP fault" do
64
- response = soap_fault_response_instance
65
- response.soap_fault?.should be_true
50
+ savon_response_with(:soap_fault).soap_fault?.should be_true
66
51
  end
67
52
 
68
53
  after { Savon::Response.raise_errors = true }
@@ -72,8 +57,13 @@ describe Savon::Response do
72
57
  before { Savon::Response.raise_errors = false }
73
58
 
74
59
  it "returns the SOAP fault message in case of a SOAP fault" do
75
- response = soap_fault_response_instance
76
- response.soap_fault.should == "(soap:Server) Fault occurred while processing."
60
+ savon_response_with(:soap_fault).soap_fault.
61
+ should == "(soap:Server) Fault occurred while processing."
62
+ end
63
+
64
+ it "returns the SOAP fault message in case of a SOAP 1.2 fault" do
65
+ savon_response_with(:soap_fault12).soap_fault.
66
+ should == "(soap:Sender) Sender Timeout"
77
67
  end
78
68
 
79
69
  after { Savon::Response.raise_errors = true }
@@ -87,8 +77,7 @@ describe Savon::Response do
87
77
  end
88
78
 
89
79
  it "returns true in case of an HTTP error" do
90
- response = http_error_response_instance
91
- response.http_error?.should be_true
80
+ savon_response_with(:http_error).http_error?.should be_true
92
81
  end
93
82
 
94
83
  after { Savon::Response.raise_errors = true }
@@ -98,36 +87,44 @@ describe Savon::Response do
98
87
  before { Savon::Response.raise_errors = false }
99
88
 
100
89
  it "returns the HTTP error message in case of an HTTP error" do
101
- response = http_error_response_instance
102
- response.http_error.should == "Not found (404)"
90
+ savon_response_with(:http_error).http_error.should == "Not found (404)"
103
91
  end
104
92
 
105
93
  after { Savon::Response.raise_errors = true }
106
94
  end
107
95
 
108
- describe "to_hash" do
109
- it "returns the SOAP response body as a Hash" do
110
- @response.to_hash.should == UserFixture.response_hash
111
- end
96
+ it "should return the SOAP response body as a Hash" do
97
+ @response.to_hash[:authenticate_response][:return].should ==
98
+ ResponseFixture.authentication(:to_hash)
112
99
  end
113
100
 
114
- describe "to_xml" do
115
- it "returns the SOAP response body" do
116
- @response.to_xml.should == UserFixture.user_response
117
- end
101
+ it "should return a Hash for a SOAP multiRef response" do
102
+ @response = Savon::Response.new http_response_mock(200, ResponseFixture.multi_ref, "OK")
103
+
104
+ @response.to_hash[:list_response].should be_a(Hash)
105
+ @response.to_hash[:multi_ref].should be_an(Array)
106
+ end
107
+
108
+ it "should return the raw SOAP response body" do
109
+ @response.to_xml.should == ResponseFixture.authentication
110
+ @response.to_s.should == ResponseFixture.authentication
118
111
  end
119
112
 
120
- describe "to_s (alias)" do
121
- it "returns the SOAP response body" do
122
- @response.to_s.should == UserFixture.user_response
113
+ def savon_response_with(error_type)
114
+ mock = case error_type
115
+ when :soap_fault then http_response_mock 200, ResponseFixture.soap_fault
116
+ when :soap_fault12 then http_response_mock 200, ResponseFixture.soap_fault12
117
+ when :http_error then http_response_mock 404, "", "Not found"
123
118
  end
119
+ Savon::Response.new mock
124
120
  end
125
121
 
126
- def http_response_mock(code = 200, body = UserFixture.user_response, message = "OK")
127
- http_response_mock = mock "Net::HTTPResponse"
128
- http_response_mock.stubs :code => code.to_s, :message => message,
129
- :content_type => "text/html", :body => body
130
- http_response_mock
122
+ def http_response_mock(code = 200, body = nil, message = "OK")
123
+ body ||= ResponseFixture.authentication
124
+ mock = mock "Net::HTTPResponse"
125
+ mock.stubs :code => code.to_s, :message => message,
126
+ :content_type => "text/html", :body => body
127
+ mock
131
128
  end
132
129
 
133
- end
130
+ end
@@ -2,29 +2,22 @@ require "spec_helper"
2
2
 
3
3
  describe Savon do
4
4
 
5
- describe "SOAPVersions" do
6
- it "contains an Array of supported SOAP versions" do
7
- Savon::SOAPVersions.should be_an Array
8
- Savon::SOAPVersions.should_not be_empty
9
- end
5
+ it "contains an Array of supported SOAP versions" do
6
+ Savon::SOAPVersions.should be_an(Array)
7
+ Savon::SOAPVersions.should_not be_empty
10
8
  end
11
9
 
12
- describe "SOAPDateTimeFormat" do
13
- it "contains the xs:dateTime format" do
14
- Savon::SOAPDateTimeFormat.should be_a String
15
- Savon::SOAPDateTimeFormat.should_not be_empty
10
+ it "contains the xs:dateTime format" do
11
+ Savon::SOAPDateTimeFormat.should be_a(String)
12
+ Savon::SOAPDateTimeFormat.should_not be_empty
16
13
 
17
- UserFixture.datetime_object.strftime(Savon::SOAPDateTimeFormat).
18
- should == UserFixture.datetime_string
19
- end
14
+ DateTime.new(2012, 03, 22, 16, 22, 33).strftime(Savon::SOAPDateTimeFormat).
15
+ should == "2012-03-22T16:22:33"
20
16
  end
21
17
 
22
- describe "SOAPDateTimeRegexp" do
23
- it "contains a Regexp matching the xs:dateTime format" do
24
- Savon::SOAPDateTimeRegexp.should be_a Regexp
25
- (Savon::SOAPDateTimeRegexp === UserFixture.datetime_string).
26
- should be_true
27
- end
18
+ it "contains a Regexp matching the xs:dateTime format" do
19
+ Savon::SOAPDateTimeRegexp.should be_a(Regexp)
20
+ (Savon::SOAPDateTimeRegexp === "2012-03-22T16:22:33").should be_true
28
21
  end
29
22
 
30
- end
23
+ end
@@ -1,140 +1,131 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Savon::SOAP do
4
- before { @soap = some_soap_instance }
5
-
6
- def some_soap_instance
7
- Savon::SOAP.new UserFixture.soap_actions[:find_user]
4
+ before do
5
+ @soap = Savon::SOAP.new
6
+ @soap.action = WSDLFixture.authentication(:operations)[:authenticate][:action]
8
7
  end
9
8
 
10
- describe "SOAPNamespace" do
11
- it "contains the SOAP namespace for each supported SOAP version" do
12
- Savon::SOAPVersions.each do |soap_version|
13
- Savon::SOAP::SOAPNamespace[soap_version].should be_a String
14
- Savon::SOAP::SOAPNamespace[soap_version].should_not be_empty
15
- end
9
+ it "contains the SOAP namespace for each supported SOAP version" do
10
+ Savon::SOAPVersions.each do |soap_version|
11
+ Savon::SOAP::SOAPNamespace[soap_version].should be_a(String)
12
+ Savon::SOAP::SOAPNamespace[soap_version].should_not be_empty
16
13
  end
17
14
  end
18
15
 
19
- describe "ContentType" do
20
- it "contains the Content-Types for each supported SOAP version" do
21
- Savon::SOAPVersions.each do |soap_version|
22
- Savon::SOAP::ContentType[soap_version].should be_a String
23
- Savon::SOAP::ContentType[soap_version].should_not be_empty
24
- end
16
+ it "contains the Content-Types for each supported SOAP version" do
17
+ Savon::SOAPVersions.each do |soap_version|
18
+ Savon::SOAP::ContentType[soap_version].should be_a(String)
19
+ Savon::SOAP::ContentType[soap_version].should_not be_empty
25
20
  end
26
21
  end
27
22
 
28
- describe "@version" do
29
- it "defaults to 1" do
30
- Savon::SOAP.version.should == 1
31
- end
32
-
33
- it "has accessor methods" do
34
- [2, 1].each do |soap_version|
35
- Savon::SOAP.version = soap_version
36
- Savon::SOAP.version.should == soap_version
37
- end
38
- end
23
+ it "defaults to SOAP 1.1" do
24
+ Savon::SOAP.version.should == 1
39
25
  end
40
26
 
41
- describe "initialize" do
42
- it "expects a SOAP action map" do
43
- some_soap_instance
27
+ it "has both getter and setter for the SOAP version to use (global setting)" do
28
+ [2, 1].each do |soap_version|
29
+ Savon::SOAP.version = soap_version
30
+ Savon::SOAP.version.should == soap_version
44
31
  end
45
32
  end
46
33
 
47
- describe "wsse" do
48
- it "expects a Savon::WSSE" do
49
- @soap.wsse = Savon::WSSE.new
50
- end
34
+ it "has a setter for the Savon::WSSE" do
35
+ @soap.wsse = Savon::WSSE.new
51
36
  end
52
37
 
53
- describe "action" do
54
- it "is an accessor for the SOAP action" do
55
- @soap.action.should == UserFixture.soap_actions[:find_user][:name]
38
+ it "is has both getter and setter for the SOAP action" do
39
+ @soap.action.should == WSDLFixture.authentication(:operations)[:authenticate][:action]
56
40
 
57
- action = "someAction"
58
- @soap.action = action
59
- @soap.action.should == action
60
- end
41
+ @soap.action = "someAction"
42
+ @soap.action.should == "someAction"
61
43
  end
62
44
 
63
- describe "header" do
64
- it "is an accessor for the SOAP header" do
65
- @soap.header.should be_a Hash
66
- @soap.header.should be_empty
45
+ it "has a setter for the SOAP input" do
46
+ @soap.input = "FindUserRequest"
47
+ end
67
48
 
68
- header = { "specialAuthKey" => "secret" }
69
- @soap.header = header
70
- @soap.header.should == header
71
- end
49
+ it "has both getter and setter for the SOAP header" do
50
+ @soap.header.should be_a(Hash)
51
+ @soap.header.should be_empty
52
+
53
+ @soap.header = { "specialAuthKey" => "secret" }
54
+ @soap.header.should == { "specialAuthKey" => "secret" }
72
55
  end
73
56
 
74
- describe "body" do
75
- it "expects a SOAP-translatable Hash or an XML String" do
76
- @soap.body = { :id => 666 }
77
- @soap.body = "<id>666</id>"
78
- end
57
+ it "has a getter for the SOAP body, expecting a Hash or an XML String" do
58
+ @soap.body = { :id => 666 }
59
+ @soap.body = "<id>666</id>"
60
+ end
61
+
62
+ it "has a setter for specifying a Hash of namespaces" do
63
+ namespaces = { "xmlns:env" => "http://example.com" }
64
+ @soap.namespaces = namespaces
65
+ @soap.namespaces.should == namespaces
79
66
  end
80
67
 
81
- describe "namespaces" do
82
- it "defaults to a Hash with xmlns:env set to SOAP 1.1" do
83
- soap = some_soap_instance
84
- soap.namespaces.should == { "xmlns:env" => Savon::SOAP::SOAPNamespace[1] }
68
+ describe "has a getter for namespaces" do
69
+ it "which defaults to include the SOAP 1.1 namespace" do
70
+ @soap.namespaces.should == { "xmlns:env" => Savon::SOAP::SOAPNamespace[1] }
85
71
  end
86
72
 
87
- it "contains the xmlns:env for SOAP 1.2 if specified" do
88
- soap = some_soap_instance
89
- soap.version = 2
90
- soap.namespaces.should == { "xmlns:env" => Savon::SOAP::SOAPNamespace[2] }
73
+ it "which contains the SOAP 1.2 namespace if specified" do
74
+ @soap.version = 2
75
+ @soap.namespaces.should == { "xmlns:env" => Savon::SOAP::SOAPNamespace[2] }
91
76
  end
92
77
  end
93
78
 
94
- describe "version" do
95
- it "returns the SOAP version from options" do
96
- soap = some_soap_instance
97
- soap.version = 2
98
- soap.version.should == 2
99
- end
79
+ it "has a convenience method for setting the 'xmlns:wsdl' namespace" do
80
+ @soap.namespaces.should == { "xmlns:env" => "http://schemas.xmlsoap.org/soap/envelope/" }
100
81
 
101
- it "returns the default SOAP version otherwise" do
102
- @soap.version.should == Savon::SOAP.version
103
- end
82
+ @soap.namespace = "http://example.com"
83
+ @soap.namespaces.should include("xmlns:env" => "http://schemas.xmlsoap.org/soap/envelope/")
84
+ @soap.namespaces.should include("xmlns:wsdl" => "http://example.com")
85
+ end
86
+
87
+ it "has both getter and setter for the SOAP endpoint" do
88
+ @soap.endpoint.should be_nil
89
+
90
+ soap_endpoint = URI EndpointHelper.soap_endpoint
91
+ @soap.endpoint = soap_endpoint
92
+ @soap.endpoint.should == soap_endpoint
93
+ end
94
+
95
+ it "has a getter for the SOAP version to use which defaults to SOAP 1.1" do
96
+ @soap.version.should == Savon::SOAP.version
97
+ end
98
+
99
+ it "has a setter for specifying the SOAP version to use" do
100
+ @soap.version = 2
101
+ @soap.version.should == 2
104
102
  end
105
103
 
106
104
  describe "to_xml" do
107
- before { Savon::SOAP.version = 1 }
105
+ after { Savon::SOAP.version = 1 }
108
106
 
109
107
  it "returns the XML for a SOAP request" do
110
- soap = some_soap_instance
111
- soap.namespaces["xmlns:wsdl"] = "http://v1_0.ws.user.example.com"
112
- soap.body = { :id => 666 }
113
- soap.to_xml.should == soap_body
108
+ @soap.namespaces["xmlns:wsdl"] = "http://v1_0.ws.auth.order.example.com/"
109
+ @soap.body = { :id => 666 }
110
+
111
+ @soap.to_xml.should include('xmlns:wsdl="http://v1_0.ws.auth.order.example.com/"')
112
+ @soap.to_xml.should include('xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"')
113
+ @soap.to_xml.should include('<wsdl:authenticate><id>666</id></wsdl:authenticate>')
114
114
  end
115
115
 
116
116
  it "caches the XML, returning the same Object every time" do
117
117
  @soap.to_xml.object_id.should == @soap.to_xml.object_id
118
118
  end
119
119
 
120
- it "uses the SOAP namespace for the SOAP version passed in via options" do
121
- soap = some_soap_instance
122
- soap.version = 2
123
- soap.to_xml.should include Savon::SOAP::SOAPNamespace[2]
120
+ it "uses the SOAP namespace for the specified SOAP version" do
121
+ @soap.version = 2
122
+ @soap.to_xml.should include(Savon::SOAP::SOAPNamespace[2])
124
123
  end
125
124
 
126
125
  it "uses the SOAP namespace for the default SOAP version otherwise" do
127
126
  Savon::SOAP.version = 2
128
- @soap.to_xml.should include Savon::SOAP::SOAPNamespace[2]
129
- end
130
-
131
- def soap_body
132
- "<env:Envelope xmlns:wsdl=\"http://v1_0.ws.user.example.com\" " <<
133
- "xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">" <<
134
- "<env:Header></env:Header>" <<
135
- "<env:Body><wsdl:findUser><id>666</id></wsdl:findUser></env:Body>" <<
136
- "</env:Envelope>"
127
+ @soap.to_xml.should include(Savon::SOAP::SOAPNamespace[2])
137
128
  end
138
129
  end
139
130
 
140
- end
131
+ end