savon 0.6.0 → 0.6.4
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.
- data/CHANGELOG +56 -0
- data/README.textile +39 -37
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/savon/client.rb +23 -5
- data/lib/savon/core_ext/string.rb +1 -1
- data/lib/savon/request.rb +6 -1
- data/lib/savon/response.rb +1 -1
- data/lib/savon/soap.rb +22 -8
- data/lib/savon/wsdl.rb +66 -36
- data/lib/savon/wsse.rb +6 -2
- data/spec/fixtures/user_fixture.rb +8 -4
- data/spec/http_stubs.rb +15 -17
- data/spec/savon/client_spec.rb +46 -47
- data/spec/savon/request_spec.rb +44 -64
- data/spec/savon/response_spec.rb +34 -51
- data/spec/savon/savon_spec.rb +13 -19
- data/spec/savon/soap_spec.rb +64 -89
- data/spec/savon/wsdl_spec.rb +19 -34
- data/spec/savon/wsse_spec.rb +48 -74
- data/spec/spec_helper.rb +1 -1
- data/spec/{spec_helper_methods.rb → spec_helper_classes.rb} +32 -4
- metadata +5 -4
data/spec/savon/client_spec.rb
CHANGED
|
@@ -1,69 +1,68 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Savon::Client do
|
|
4
|
-
before { @client =
|
|
4
|
+
before { @client = Savon::Client.new EndpointHelper.wsdl_endpoint }
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
Savon::Client.new
|
|
6
|
+
it "is initialized with a SOAP endpoint String" do
|
|
7
|
+
Savon::Client.new EndpointHelper.wsdl_endpoint
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
10
|
+
it "raises an ArgumentError when initialized with an invalid endpoint" do
|
|
11
|
+
lambda { Savon::Client.new "invalid" }.should raise_error ArgumentError
|
|
12
|
+
end
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
end
|
|
14
|
+
it "has a getter for accessing the Savon::WSDL" do
|
|
15
|
+
@client.wsdl.should be_a Savon::WSDL
|
|
18
16
|
end
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@client.wsdl.should be_a Savon::WSDL
|
|
23
|
-
end
|
|
18
|
+
it "has a getter for accessing the Savon::Request" do
|
|
19
|
+
@client.request.should be_a Savon::Request
|
|
24
20
|
end
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@client.respond_to?(UserFixture.soap_actions.keys.first).
|
|
29
|
-
should be_true
|
|
30
|
-
end
|
|
22
|
+
it "has a getter for returning whether to use the Savon::WSDL (global setting)" do
|
|
23
|
+
@client.wsdl?.should be_true
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
Savon::Client.wsdl = false
|
|
26
|
+
@client.wsdl?.should be_false
|
|
27
|
+
Savon::Client.wsdl = true
|
|
28
|
+
|
|
29
|
+
@client.wsdl = false
|
|
30
|
+
@client.wsdl?.should be_false
|
|
36
31
|
end
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
it "responds to SOAP actions while still behaving as usual otherwise" do
|
|
34
|
+
@client.respond_to?(UserFixture.soap_actions.first).should be_true
|
|
35
|
+
@client.respond_to?(:object_id).should be_true
|
|
36
|
+
@client.respond_to?(:some_undefined_method).should be_false
|
|
37
|
+
end
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
end
|
|
39
|
+
it "dispatches SOAP calls via method_missing and returns the Savon::Response" do
|
|
40
|
+
@client.find_user.should be_a Savon::Response
|
|
41
|
+
end
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
it "raises a Savon::SOAPFault in case of a SOAP fault" do
|
|
44
|
+
client = Savon::Client.new EndpointHelper.wsdl_endpoint(:soap_fault)
|
|
45
|
+
lambda { client.find_user }.should raise_error Savon::SOAPFault
|
|
46
|
+
end
|
|
52
47
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
it "raises a Savon::HTTPError in case of an HTTP error" do
|
|
49
|
+
client = Savon::Client.new EndpointHelper.wsdl_endpoint(:http_error)
|
|
50
|
+
lambda { client.find_user }.should raise_error Savon::HTTPError
|
|
51
|
+
end
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
wsse.should be_a Savon::WSSE
|
|
61
|
-
end
|
|
62
|
-
end
|
|
53
|
+
it "yields the SOAP object to a block when it expects one argument" do
|
|
54
|
+
@client.find_user { |soap| soap.should be_a Savon::SOAP }
|
|
55
|
+
end
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
it "yields the SOAP and WSSE object to a block when it expects two argument" do
|
|
58
|
+
@client.find_user do |soap, wsse|
|
|
59
|
+
soap.should be_a Savon::SOAP
|
|
60
|
+
wsse.should be_a Savon::WSSE
|
|
66
61
|
end
|
|
67
62
|
end
|
|
68
63
|
|
|
69
|
-
|
|
64
|
+
it "still raises a NoMethodError for undefined methods" do
|
|
65
|
+
lambda { @client.some_undefined_method }.should raise_error NoMethodError
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
data/spec/savon/request_spec.rb
CHANGED
|
@@ -1,92 +1,72 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Savon::Request do
|
|
4
|
-
before { @request =
|
|
4
|
+
before { @request = Savon::Request.new EndpointHelper.wsdl_endpoint }
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
Savon::
|
|
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
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
|
22
|
+
it "defaults to use a Logger instance for logging" do
|
|
23
|
+
Savon::Request.logger.should be_a Logger
|
|
32
24
|
end
|
|
33
25
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
30
|
+
end
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Savon::Request.logger.should be_nil
|
|
42
|
-
Savon::Request.logger = Logger.new STDOUT
|
|
43
|
-
end
|
|
32
|
+
it "defaults to :debug for logging" do
|
|
33
|
+
Savon::Request.log_level.should == :debug
|
|
44
34
|
end
|
|
45
35
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
40
|
+
end
|
|
50
41
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Savon::Request.log_level.should == :info
|
|
54
|
-
Savon::Request.log_level = :debug
|
|
55
|
-
end
|
|
42
|
+
it "is initialized with a SOAP endpoint String" do
|
|
43
|
+
Savon::Request.new EndpointHelper.wsdl_endpoint
|
|
56
44
|
end
|
|
57
45
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
end
|
|
46
|
+
it "raises an ArgumentError when initialized with an invalid endpoint" do
|
|
47
|
+
lambda { Savon::Request.new "invalid" }.should raise_error ArgumentError
|
|
48
|
+
end
|
|
62
49
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
end
|
|
50
|
+
it "has a getter for the SOAP endpoint URI" do
|
|
51
|
+
@request.endpoint.should == URI(EndpointHelper.wsdl_endpoint)
|
|
66
52
|
end
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
@request.endpoint.should == SpecHelper.some_endpoint_uri
|
|
71
|
-
end
|
|
54
|
+
it "has a setter for specifying a read_timeout" do
|
|
55
|
+
@request.read_timeout = 30
|
|
72
56
|
end
|
|
73
57
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
wsdl_response = @request.wsdl
|
|
58
|
+
it "retrieves the WSDL document and returns the Net::HTTPResponse" do
|
|
59
|
+
wsdl_response = @request.wsdl
|
|
77
60
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
end
|
|
61
|
+
wsdl_response.should be_a Net::HTTPResponse
|
|
62
|
+
wsdl_response.body.should == UserFixture.user_wsdl
|
|
81
63
|
end
|
|
82
64
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
soap_response = @request.soap some_soap_instance
|
|
65
|
+
it "executes a SOAP request and returns the Net::HTTPResponse" do
|
|
66
|
+
soap_response = @request.soap Savon::SOAP.new
|
|
86
67
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
end
|
|
68
|
+
soap_response.should be_a Net::HTTPResponse
|
|
69
|
+
soap_response.body.should == UserFixture.user_response
|
|
90
70
|
end
|
|
91
71
|
|
|
92
|
-
end
|
|
72
|
+
end
|
data/spec/savon/response_spec.rb
CHANGED
|
@@ -1,54 +1,40 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Savon::Response do
|
|
4
|
-
before { @response =
|
|
4
|
+
before { @response = Savon::Response.new http_response_mock }
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
Savon::Response.
|
|
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
|
-
|
|
11
|
-
Savon::Response.
|
|
12
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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,8 @@ 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
|
-
|
|
76
|
-
|
|
60
|
+
savon_response_with(:soap_fault).soap_fault.
|
|
61
|
+
should == "(soap:Server) Fault occurred while processing."
|
|
77
62
|
end
|
|
78
63
|
|
|
79
64
|
after { Savon::Response.raise_errors = true }
|
|
@@ -87,8 +72,7 @@ describe Savon::Response do
|
|
|
87
72
|
end
|
|
88
73
|
|
|
89
74
|
it "returns true in case of an HTTP error" do
|
|
90
|
-
|
|
91
|
-
response.http_error?.should be_true
|
|
75
|
+
savon_response_with(:http_error).http_error?.should be_true
|
|
92
76
|
end
|
|
93
77
|
|
|
94
78
|
after { Savon::Response.raise_errors = true }
|
|
@@ -98,36 +82,35 @@ describe Savon::Response do
|
|
|
98
82
|
before { Savon::Response.raise_errors = false }
|
|
99
83
|
|
|
100
84
|
it "returns the HTTP error message in case of an HTTP error" do
|
|
101
|
-
|
|
102
|
-
response.http_error.should == "Not found (404)"
|
|
85
|
+
savon_response_with(:http_error).http_error.should == "Not found (404)"
|
|
103
86
|
end
|
|
104
87
|
|
|
105
88
|
after { Savon::Response.raise_errors = true }
|
|
106
89
|
end
|
|
107
90
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
@response.to_hash.should == UserFixture.response_hash
|
|
111
|
-
end
|
|
91
|
+
it "can return the SOAP response body as a Hash" do
|
|
92
|
+
@response.to_hash.should == UserFixture.response_hash
|
|
112
93
|
end
|
|
113
94
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
end
|
|
95
|
+
it "can return the raw SOAP response body" do
|
|
96
|
+
@response.to_xml.should == UserFixture.user_response
|
|
97
|
+
@response.to_s.should == UserFixture.user_response
|
|
118
98
|
end
|
|
119
99
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
100
|
+
def savon_response_with(error_type)
|
|
101
|
+
mock = case error_type
|
|
102
|
+
when :soap_fault then http_response_mock(200, UserFixture.soap_fault)
|
|
103
|
+
when :http_error then http_response_mock(404, "", "Not found")
|
|
123
104
|
end
|
|
105
|
+
Savon::Response.new mock
|
|
124
106
|
end
|
|
125
107
|
|
|
126
|
-
def http_response_mock(code = 200, body =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
108
|
+
def http_response_mock(code = 200, body = nil, message = "OK")
|
|
109
|
+
body ||= UserFixture.user_response
|
|
110
|
+
mock = mock "Net::HTTPResponse"
|
|
111
|
+
mock.stubs :code => code.to_s, :message => message,
|
|
112
|
+
:content_type => "text/html", :body => body
|
|
113
|
+
mock
|
|
131
114
|
end
|
|
132
115
|
|
|
133
|
-
end
|
|
116
|
+
end
|
data/spec/savon/savon_spec.rb
CHANGED
|
@@ -2,29 +2,23 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe Savon do
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
14
|
+
UserFixture.datetime_object.strftime(Savon::SOAPDateTimeFormat).
|
|
15
|
+
should == UserFixture.datetime_string
|
|
20
16
|
end
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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 === UserFixture.datetime_string).
|
|
21
|
+
should be_true
|
|
28
22
|
end
|
|
29
23
|
|
|
30
|
-
end
|
|
24
|
+
end
|
data/spec/savon/soap_spec.rb
CHANGED
|
@@ -1,140 +1,115 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Savon::SOAP do
|
|
4
|
-
before
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Savon::SOAP.new UserFixture.soap_actions[:find_user]
|
|
4
|
+
before do
|
|
5
|
+
@soap = Savon::SOAP.new
|
|
6
|
+
@soap.action = UserFixture.operations[:find_user][:action]
|
|
8
7
|
end
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Savon::
|
|
13
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
Savon::
|
|
22
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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 == UserFixture.operations[:find_user][:action]
|
|
56
40
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
@soap.action.should == action
|
|
60
|
-
end
|
|
41
|
+
@soap.action = "someAction"
|
|
42
|
+
@soap.action.should == "someAction"
|
|
61
43
|
end
|
|
62
44
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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>"
|
|
79
60
|
end
|
|
80
61
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
|
66
|
+
end
|
|
67
|
+
|
|
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
|
|
88
|
-
soap =
|
|
89
|
-
soap.
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
soap.version = 2
|
|
98
|
-
soap.version.should == 2
|
|
99
|
-
end
|
|
79
|
+
it "has a getter for the SOAP version to use which defaults to SOAP 1.1" do
|
|
80
|
+
@soap.version.should == Savon::SOAP.version
|
|
81
|
+
end
|
|
100
82
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
83
|
+
it "has a setter for specifying the SOAP version to use" do
|
|
84
|
+
@soap.version = 2
|
|
85
|
+
@soap.version.should == 2
|
|
104
86
|
end
|
|
105
87
|
|
|
106
88
|
describe "to_xml" do
|
|
107
|
-
|
|
89
|
+
after { Savon::SOAP.version = 1 }
|
|
108
90
|
|
|
109
91
|
it "returns the XML for a SOAP request" do
|
|
110
|
-
soap =
|
|
111
|
-
soap.
|
|
112
|
-
|
|
113
|
-
soap.to_xml.should
|
|
92
|
+
@soap.namespaces["xmlns:wsdl"] = "http://v1_0.ws.user.example.com"
|
|
93
|
+
@soap.body = { :id => 666 }
|
|
94
|
+
|
|
95
|
+
@soap.to_xml.should include 'xmlns:wsdl="http://v1_0.ws.user.example.com"'
|
|
96
|
+
@soap.to_xml.should include 'xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"'
|
|
97
|
+
@soap.to_xml.should include '<wsdl:findUser><id>666</id></wsdl:findUser>'
|
|
114
98
|
end
|
|
115
99
|
|
|
116
100
|
it "caches the XML, returning the same Object every time" do
|
|
117
101
|
@soap.to_xml.object_id.should == @soap.to_xml.object_id
|
|
118
102
|
end
|
|
119
103
|
|
|
120
|
-
it "uses the SOAP namespace for the SOAP version
|
|
121
|
-
soap =
|
|
122
|
-
soap.
|
|
123
|
-
soap.to_xml.should include Savon::SOAP::SOAPNamespace[2]
|
|
104
|
+
it "uses the SOAP namespace for the specified SOAP version" do
|
|
105
|
+
@soap.version = 2
|
|
106
|
+
@soap.to_xml.should include Savon::SOAP::SOAPNamespace[2]
|
|
124
107
|
end
|
|
125
108
|
|
|
126
109
|
it "uses the SOAP namespace for the default SOAP version otherwise" do
|
|
127
110
|
Savon::SOAP.version = 2
|
|
128
111
|
@soap.to_xml.should include Savon::SOAP::SOAPNamespace[2]
|
|
129
112
|
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>"
|
|
137
|
-
end
|
|
138
113
|
end
|
|
139
114
|
|
|
140
|
-
end
|
|
115
|
+
end
|