savon 2.5.1 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/lib/savon/builder.rb +6 -1
- data/lib/savon/header.rb +2 -2
- data/lib/savon/options.rb +37 -11
- data/lib/savon/request.rb +7 -2
- data/lib/savon/version.rb +1 -1
- data/savon.gemspec +1 -1
- data/spec/fixtures/wsdl/no_message_tag.xml +1267 -0
- data/spec/integration/email_example_spec.rb +1 -1
- data/spec/integration/random_quote_spec.rb +2 -2
- data/spec/integration/stockquote_example_spec.rb +1 -1
- data/spec/integration/zipcode_example_spec.rb +1 -1
- data/spec/savon/builder_spec.rb +5 -0
- data/spec/savon/client_spec.rb +1 -1
- data/spec/savon/core_ext/string_spec.rb +9 -9
- data/spec/savon/http_error_spec.rb +2 -2
- data/spec/savon/options_spec.rb +235 -53
- data/spec/savon/request_spec.rb +2 -2
- data/spec/savon/response_spec.rb +33 -31
- data/spec/savon/soap_fault_spec.rb +5 -5
- metadata +5 -4
data/spec/savon/response_spec.rb
CHANGED
@@ -7,16 +7,16 @@ describe Savon::Response do
|
|
7
7
|
|
8
8
|
describe ".new" do
|
9
9
|
it "should raise a Savon::Fault in case of a SOAP fault" do
|
10
|
-
|
10
|
+
expect { soap_fault_response }.to raise_error(Savon::SOAPFault)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should not raise a Savon::Fault in case the default is turned off" do
|
14
14
|
globals[:raise_errors] = false
|
15
|
-
|
15
|
+
expect { soap_fault_response }.not_to raise_error
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should raise a Savon::HTTP::Error in case of an HTTP error" do
|
19
|
-
|
19
|
+
expect { soap_response :code => 500 }.to raise_error(Savon::HTTPError)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should not raise a Savon::HTTP::Error in case the default is turned off" do
|
@@ -29,15 +29,15 @@ describe Savon::Response do
|
|
29
29
|
before { globals[:raise_errors] = false }
|
30
30
|
|
31
31
|
it "should return true if the request was successful" do
|
32
|
-
soap_response.
|
32
|
+
expect(soap_response).to be_a_success
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should return false if there was a SOAP fault" do
|
36
|
-
soap_fault_response.
|
36
|
+
expect(soap_fault_response).not_to be_a_success
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should return false if there was an HTTP error" do
|
40
|
-
http_error_response.
|
40
|
+
expect(http_error_response).not_to be_a_success
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -45,11 +45,11 @@ describe Savon::Response do
|
|
45
45
|
before { globals[:raise_errors] = false }
|
46
46
|
|
47
47
|
it "should not return true in case the response seems to be ok" do
|
48
|
-
soap_response.soap_fault
|
48
|
+
expect(soap_response.soap_fault?).to be_falsey
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should return true in case of a SOAP fault" do
|
52
|
-
soap_fault_response.soap_fault
|
52
|
+
expect(soap_fault_response.soap_fault?).to be_truthy
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -57,11 +57,11 @@ describe Savon::Response do
|
|
57
57
|
before { globals[:raise_errors] = false }
|
58
58
|
|
59
59
|
it "should return nil in case the response seems to be ok" do
|
60
|
-
soap_response.soap_fault.
|
60
|
+
expect(soap_response.soap_fault).to be_nil
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should return a SOAPFault in case of a SOAP fault" do
|
64
|
-
soap_fault_response.soap_fault.
|
64
|
+
expect(soap_fault_response.soap_fault).to be_a(Savon::SOAPFault)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -69,11 +69,11 @@ describe Savon::Response do
|
|
69
69
|
before { globals[:raise_errors] = false }
|
70
70
|
|
71
71
|
it "should not return true in case the response seems to be ok" do
|
72
|
-
soap_response.http_error
|
72
|
+
expect(soap_response.http_error?).not_to be_truthy
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should return true in case of an HTTP error" do
|
76
|
-
soap_response(:code => 500).http_error
|
76
|
+
expect(soap_response(:code => 500).http_error?).to be_truthy
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -81,18 +81,18 @@ describe Savon::Response do
|
|
81
81
|
before { globals[:raise_errors] = false }
|
82
82
|
|
83
83
|
it "should return nil in case the response seems to be ok" do
|
84
|
-
soap_response.http_error.
|
84
|
+
expect(soap_response.http_error).to be_nil
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should return a HTTPError in case of an HTTP error" do
|
88
|
-
soap_response(:code => 500).http_error.
|
88
|
+
expect(soap_response(:code => 500).http_error).to be_a(Savon::HTTPError)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe "#header" do
|
93
93
|
it "should return the SOAP response header as a Hash" do
|
94
94
|
response = soap_response :body => Fixture.response(:header)
|
95
|
-
response.header.
|
95
|
+
expect(response.header).to include(:session_number => "ABCD1234")
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'respects the global :strip_namespaces option' do
|
@@ -129,29 +129,30 @@ describe Savon::Response do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should throw an exception when the response header isn't parsable" do
|
132
|
-
|
132
|
+
expect { invalid_soap_response.header }.to raise_error Savon::InvalidResponseError
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
%w(body to_hash).each do |method|
|
137
137
|
describe "##{method}" do
|
138
138
|
it "should return the SOAP response body as a Hash" do
|
139
|
-
soap_response.send(method)[:authenticate_response][:return].
|
139
|
+
expect(soap_response.send(method)[:authenticate_response][:return]).to eq(
|
140
140
|
Fixture.response_hash(:authentication)[:authenticate_response][:return]
|
141
|
+
)
|
141
142
|
end
|
142
143
|
|
143
144
|
it "should return a Hash for a SOAP multiRef response" do
|
144
145
|
hash = soap_response(:body => Fixture.response(:multi_ref)).send(method)
|
145
146
|
|
146
|
-
hash[:list_response].
|
147
|
-
hash[:multi_ref].
|
147
|
+
expect(hash[:list_response]).to be_a(Hash)
|
148
|
+
expect(hash[:multi_ref]).to be_an(Array)
|
148
149
|
end
|
149
150
|
|
150
151
|
it "should add existing namespaced elements as an array" do
|
151
152
|
hash = soap_response(:body => Fixture.response(:list)).send(method)
|
152
153
|
|
153
|
-
hash[:multi_namespaced_entry_response][:history].
|
154
|
-
hash[:multi_namespaced_entry_response][:history][:case].
|
154
|
+
expect(hash[:multi_namespaced_entry_response][:history]).to be_a(Hash)
|
155
|
+
expect(hash[:multi_namespaced_entry_response][:history][:case]).to be_an(Array)
|
155
156
|
end
|
156
157
|
|
157
158
|
it 'respects the global :strip_namespaces option' do
|
@@ -177,25 +178,26 @@ describe Savon::Response do
|
|
177
178
|
describe "#to_array" do
|
178
179
|
context "when the given path exists" do
|
179
180
|
it "should return an Array containing the path value" do
|
180
|
-
soap_response.to_array(:authenticate_response, :return).
|
181
|
+
expect(soap_response.to_array(:authenticate_response, :return)).to eq(
|
181
182
|
[Fixture.response_hash(:authentication)[:authenticate_response][:return]]
|
183
|
+
)
|
182
184
|
end
|
183
185
|
|
184
186
|
it "should properly return FalseClass values [#327]" do
|
185
187
|
body = Gyoku.xml(:envelope => { :body => { :return => { :success => false } } })
|
186
|
-
soap_response(:body => body).to_array(:return, :success).
|
188
|
+
expect(soap_response(:body => body).to_array(:return, :success)).to eq([false])
|
187
189
|
end
|
188
190
|
end
|
189
191
|
|
190
192
|
context "when the given path returns nil" do
|
191
193
|
it "should return an empty Array" do
|
192
|
-
soap_response.to_array(:authenticate_response, :undefined).
|
194
|
+
expect(soap_response.to_array(:authenticate_response, :undefined)).to eq([])
|
193
195
|
end
|
194
196
|
end
|
195
197
|
|
196
198
|
context "when the given path does not exist at all" do
|
197
199
|
it "should return an empty Array" do
|
198
|
-
soap_response.to_array(:authenticate_response, :some, :undefined, :path).
|
200
|
+
expect(soap_response.to_array(:authenticate_response, :some, :undefined, :path)).to eq([])
|
199
201
|
end
|
200
202
|
end
|
201
203
|
end
|
@@ -203,26 +205,26 @@ describe Savon::Response do
|
|
203
205
|
describe "#hash" do
|
204
206
|
it "should return the complete SOAP response XML as a Hash" do
|
205
207
|
response = soap_response :body => Fixture.response(:header)
|
206
|
-
response.hash[:envelope][:header][:session_number].
|
208
|
+
expect(response.hash[:envelope][:header][:session_number]).to eq("ABCD1234")
|
207
209
|
end
|
208
210
|
end
|
209
211
|
|
210
212
|
describe "#to_xml" do
|
211
213
|
it "should return the raw SOAP response body" do
|
212
|
-
soap_response.to_xml.
|
214
|
+
expect(soap_response.to_xml).to eq(Fixture.response(:authentication))
|
213
215
|
end
|
214
216
|
end
|
215
217
|
|
216
218
|
describe "#doc" do
|
217
219
|
it "returns a Nokogiri::XML::Document for the SOAP response XML" do
|
218
|
-
soap_response.doc.
|
220
|
+
expect(soap_response.doc).to be_a(Nokogiri::XML::Document)
|
219
221
|
end
|
220
222
|
end
|
221
223
|
|
222
224
|
describe "#xpath" do
|
223
225
|
it "permits XPath access to elements in the request" do
|
224
|
-
soap_response.xpath("//client").first.inner_text.
|
225
|
-
soap_response.xpath("//ns2:authenticateResponse/return/success").first.inner_text.
|
226
|
+
expect(soap_response.xpath("//client").first.inner_text).to eq("radclient")
|
227
|
+
expect(soap_response.xpath("//ns2:authenticateResponse/return/success").first.inner_text).to eq("true")
|
226
228
|
end
|
227
229
|
end
|
228
230
|
|
@@ -237,7 +239,7 @@ describe Savon::Response do
|
|
237
239
|
|
238
240
|
describe "#http" do
|
239
241
|
it "should return the HTTPI::Response" do
|
240
|
-
soap_response.http.
|
242
|
+
expect(soap_response.http).to be_an(HTTPI::Response)
|
241
243
|
end
|
242
244
|
end
|
243
245
|
|
@@ -24,21 +24,21 @@ describe Savon::SOAPFault do
|
|
24
24
|
describe ".present?" do
|
25
25
|
it "returns true if the HTTP response contains a SOAP 1.1 fault" do
|
26
26
|
http = new_response(:body => Fixture.response(:soap_fault))
|
27
|
-
expect(Savon::SOAPFault.present? http).to
|
27
|
+
expect(Savon::SOAPFault.present? http).to be_truthy
|
28
28
|
end
|
29
29
|
|
30
30
|
it "returns true if the HTTP response contains a SOAP 1.2 fault" do
|
31
31
|
http = new_response(:body => Fixture.response(:soap_fault12))
|
32
|
-
expect(Savon::SOAPFault.present? http).to
|
32
|
+
expect(Savon::SOAPFault.present? http).to be_truthy
|
33
33
|
end
|
34
34
|
|
35
35
|
it "returns true if the HTTP response contains a SOAP fault with different namespaces" do
|
36
36
|
http = new_response(:body => Fixture.response(:another_soap_fault))
|
37
|
-
expect(Savon::SOAPFault.present? http).to
|
37
|
+
expect(Savon::SOAPFault.present? http).to be_truthy
|
38
38
|
end
|
39
39
|
|
40
40
|
it "returns false unless the HTTP response contains a SOAP fault" do
|
41
|
-
expect(Savon::SOAPFault.present? new_response).to
|
41
|
+
expect(Savon::SOAPFault.present? new_response).to be_falsey
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -68,7 +68,7 @@ describe Savon::SOAPFault do
|
|
68
68
|
|
69
69
|
describe "#to_hash" do
|
70
70
|
it "returns the SOAP response as a Hash unless a SOAP fault is present" do
|
71
|
-
expect(no_fault.to_hash[:authenticate_response][:return][:success]).to
|
71
|
+
expect(no_fault.to_hash[:authenticate_response][:return][:success]).to be_truthy
|
72
72
|
end
|
73
73
|
|
74
74
|
it "returns a SOAP 1.1 fault as a Hash" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: savon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Harrington
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nori
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.2.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.2.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: wasabi
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- spec/fixtures/wsdl/lower_camel.xml
|
266
266
|
- spec/fixtures/wsdl/multiple_namespaces.xml
|
267
267
|
- spec/fixtures/wsdl/multiple_types.xml
|
268
|
+
- spec/fixtures/wsdl/no_message_tag.xml
|
268
269
|
- spec/fixtures/wsdl/taxcloud.xml
|
269
270
|
- spec/fixtures/wsdl/team_software.xml
|
270
271
|
- spec/fixtures/wsdl/vies.xml
|