savon 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -1
- data/CHANGELOG.md +69 -27
- data/Gemfile +5 -0
- data/lib/savon/client.rb +3 -1
- data/lib/savon/soap/request.rb +6 -2
- data/lib/savon/soap/response.rb +16 -1
- data/lib/savon/soap/xml.rb +16 -7
- data/lib/savon/version.rb +1 -1
- data/savon.gemspec +0 -1
- data/spec/fixtures/response/taxcloud.xml +1 -0
- data/spec/fixtures/wsdl/taxcloud.xml +934 -0
- data/spec/savon/client_spec.rb +29 -1
- data/spec/savon/soap/request_spec.rb +15 -11
- data/spec/savon/soap/response_spec.rb +13 -0
- data/spec/savon/soap/xml_spec.rb +22 -1
- metadata +7 -19
data/spec/savon/client_spec.rb
CHANGED
@@ -198,6 +198,7 @@ describe Savon::Client do
|
|
198
198
|
client.http.headers.expects(:[]=).with("Cookie", anything).never
|
199
199
|
client.http.headers.stubs(:[]=).with("SOAPAction", '"authenticate"')
|
200
200
|
client.http.headers.stubs(:[]=).with("Content-Type", "text/xml;charset=UTF-8")
|
201
|
+
client.http.headers.stubs(:[]=).with("Content-Length", "384")
|
201
202
|
|
202
203
|
client.request :authenticate
|
203
204
|
end
|
@@ -213,6 +214,7 @@ describe Savon::Client do
|
|
213
214
|
client.http.headers.expects(:[]=).with("Cookie", "some-cookie")
|
214
215
|
client.http.headers.stubs(:[]=).with("SOAPAction", '"authenticate"')
|
215
216
|
client.http.headers.stubs(:[]=).with("Content-Type", "text/xml;charset=UTF-8")
|
217
|
+
client.http.headers.stubs(:[]=).with("Content-Length", "384")
|
216
218
|
|
217
219
|
client.request :authenticate
|
218
220
|
end
|
@@ -240,7 +242,7 @@ describe Savon::Client do
|
|
240
242
|
end
|
241
243
|
|
242
244
|
context "with a local WSDL document" do
|
243
|
-
let(:client) { Savon::Client.new { wsdl.document = "spec/fixtures/wsdl/authentication.xml" } }
|
245
|
+
let(:client) { Savon::Client.new { wsdl.document = "spec/fixtures/wsdl/authentication.xml" } }
|
244
246
|
|
245
247
|
before { HTTPI.expects(:get).never }
|
246
248
|
|
@@ -362,6 +364,32 @@ describe Savon::Client do
|
|
362
364
|
end
|
363
365
|
end
|
364
366
|
|
367
|
+
context "with an Array of namespaced items" do
|
368
|
+
let(:client) { Savon::Client.new { wsdl.document = "spec/fixtures/wsdl/taxcloud.xml" } }
|
369
|
+
|
370
|
+
before do
|
371
|
+
HTTPI.stubs(:get).returns(new_response(:body => Fixture.wsdl(:taxcloud)))
|
372
|
+
HTTPI.stubs(:post).returns(new_response)
|
373
|
+
end
|
374
|
+
|
375
|
+
it "should namespaces each Array item as expected" do
|
376
|
+
HTTPI::Request.any_instance.expects(:body=).with do |value|
|
377
|
+
value.include?("<ins0:cartItems><ins0:CartItem>") && value.include?("<wsdl:ItemID>SKU-TEST</wsdl:ItemID>")
|
378
|
+
end
|
379
|
+
|
380
|
+
address = { "Address1" => "888 6th Ave", "Address2" => nil, "City" => "New York", "State" => "NY", "Zip5" => "10001", "Zip4" => nil }
|
381
|
+
cart_item = { "Index" => 0, "ItemID" => "SKU-TEST", "TIC" => "00000", "Price" => 50.0, "Qty" => 1 }
|
382
|
+
|
383
|
+
client.request :lookup, :body => {
|
384
|
+
"customerID" => 123,
|
385
|
+
"cartID" => 456,
|
386
|
+
"cartItems" => { "CartItem" => [cart_item] },
|
387
|
+
"origin" => address,
|
388
|
+
"destination" => address
|
389
|
+
}
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
365
393
|
context "without a WSDL document" do
|
366
394
|
let(:client) do
|
367
395
|
Savon::Client.new do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Savon::SOAP::Request do
|
4
|
-
let(:
|
4
|
+
let(:soap_request) { Savon::SOAP::Request.new HTTPI::Request.new, soap }
|
5
5
|
let(:soap) { Savon::SOAP::XML.new Endpoint.soap, [nil, :get_user, {}], :id => 1 }
|
6
6
|
|
7
7
|
it "contains the content type for each supported SOAP version" do
|
@@ -20,33 +20,37 @@ describe Savon::SOAP::Request do
|
|
20
20
|
|
21
21
|
describe ".new" do
|
22
22
|
it "uses the SOAP endpoint for the request" do
|
23
|
-
|
23
|
+
soap_request.request.url.should == URI(soap.endpoint)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "sets the SOAP body for the request" do
|
27
|
-
|
27
|
+
soap_request.request.body.should == soap.to_xml
|
28
28
|
end
|
29
29
|
|
30
|
-
it "sets the
|
31
|
-
|
30
|
+
it "sets the Content-Type header for SOAP 1.1" do
|
31
|
+
soap_request.request.headers["Content-Type"].should == Savon::SOAP::Request::ContentType[1]
|
32
32
|
end
|
33
33
|
|
34
|
-
it "sets the
|
34
|
+
it "sets the Content-Type header for SOAP 1.2" do
|
35
35
|
soap.version = 2
|
36
|
-
|
36
|
+
soap_request.request.headers["Content-Type"].should == Savon::SOAP::Request::ContentType[2]
|
37
37
|
end
|
38
38
|
|
39
|
-
it "does not set the
|
39
|
+
it "does not set the Content-Type header if it's already specified" do
|
40
40
|
headers = { "Content-Type" => "text/plain" }
|
41
|
-
|
42
|
-
|
41
|
+
soap_request = Savon::SOAP::Request.new HTTPI::Request.new(:headers => headers), soap
|
42
|
+
soap_request.request.headers["Content-Type"].should == headers["Content-Type"]
|
43
|
+
end
|
44
|
+
|
45
|
+
it "sets the Content-Length header" do
|
46
|
+
soap_request.request.headers["Content-Length"].should == soap.to_xml.length.to_s
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
46
50
|
describe "#response" do
|
47
51
|
it "executes an HTTP POST request and returns a Savon::SOAP::Response" do
|
48
52
|
HTTPI.expects(:post).returns(HTTPI::Response.new 200, {}, Fixture.response(:authentication))
|
49
|
-
|
53
|
+
soap_request.response.should be_a(Savon::SOAP::Response)
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
@@ -187,6 +187,19 @@ describe Savon::SOAP::Response do
|
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
|
+
describe "#doc" do
|
191
|
+
it "returns a Nokogiri::XML::Document for the SOAP response XML" do
|
192
|
+
soap_response.doc.should be_a(Nokogiri::XML::Document)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "#xpath" do
|
197
|
+
it "permits XPath access to elements in the request" do
|
198
|
+
soap_response.xpath("//client").first.inner_text.should == "radclient"
|
199
|
+
soap_response.xpath("//ns2:authenticateResponse/return/success").first.inner_text.should == "true"
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
190
203
|
describe "#http" do
|
191
204
|
it "should return the HTTPI::Response" do
|
192
205
|
soap_response.http.should be_an(HTTPI::Response)
|
data/spec/savon/soap/xml_spec.rb
CHANGED
@@ -110,10 +110,18 @@ describe Savon::SOAP::XML do
|
|
110
110
|
xml.to_xml.should include("<id>1</id>")
|
111
111
|
end
|
112
112
|
|
113
|
-
it "should
|
113
|
+
it "should accepts an XML String" do
|
114
114
|
xml.body = "<id>1</id>"
|
115
115
|
xml.to_xml.should include("<id>1</id>")
|
116
116
|
end
|
117
|
+
|
118
|
+
it "should accept a block" do
|
119
|
+
xml.body do |body|
|
120
|
+
body.user { body.id 1 }
|
121
|
+
end
|
122
|
+
|
123
|
+
xml.to_xml.should include("<authenticate><user><id>1</id></user></authenticate>")
|
124
|
+
end
|
117
125
|
end
|
118
126
|
|
119
127
|
describe "#xml" do
|
@@ -126,6 +134,19 @@ describe Savon::SOAP::XML do
|
|
126
134
|
xml.xml { |xml| xml.using("Builder") }
|
127
135
|
xml.to_xml.should == '<?xml version="1.0" encoding="UTF-8"?><using>Builder</using>'
|
128
136
|
end
|
137
|
+
|
138
|
+
it "accepts options to pass to the Builder::XmlMarkup instruct!" do
|
139
|
+
xml.xml :xml, :aaa => :bbb do |xml|
|
140
|
+
xml.using("Builder")
|
141
|
+
end
|
142
|
+
|
143
|
+
xml.to_xml.should == '<?xml version="1.0" encoding="UTF-8" aaa="bbb"?><using>Builder</using>'
|
144
|
+
end
|
145
|
+
|
146
|
+
it "can change encoding to UTF-16" do
|
147
|
+
xml.xml(:xml, :encoding => "UTF-16") { |xml| xml.using("Builder") }
|
148
|
+
xml.to_xml.should == '<?xml version="1.0" encoding="UTF-16"?><using>Builder</using>'
|
149
|
+
end
|
129
150
|
end
|
130
151
|
|
131
152
|
describe "#to_xml" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: savon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 53
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 7
|
10
|
+
version: 0.9.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Harrington
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-25 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: builder
|
@@ -189,20 +189,6 @@ dependencies:
|
|
189
189
|
version: 0.3.5
|
190
190
|
type: :development
|
191
191
|
version_requirements: *id011
|
192
|
-
- !ruby/object:Gem::Dependency
|
193
|
-
name: autotest
|
194
|
-
prerelease: false
|
195
|
-
requirement: &id012 !ruby/object:Gem::Requirement
|
196
|
-
none: false
|
197
|
-
requirements:
|
198
|
-
- - ">="
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
hash: 3
|
201
|
-
segments:
|
202
|
-
- 0
|
203
|
-
version: "0"
|
204
|
-
type: :development
|
205
|
-
version_requirements: *id012
|
206
192
|
description: Ruby's heavy metal SOAP client
|
207
193
|
email: me@rubiii.com
|
208
194
|
executables: []
|
@@ -244,10 +230,12 @@ files:
|
|
244
230
|
- spec/fixtures/response/multi_ref.xml
|
245
231
|
- spec/fixtures/response/soap_fault.xml
|
246
232
|
- spec/fixtures/response/soap_fault12.xml
|
233
|
+
- spec/fixtures/response/taxcloud.xml
|
247
234
|
- spec/fixtures/wsdl/authentication.xml
|
248
235
|
- spec/fixtures/wsdl/lower_camel.xml
|
249
236
|
- spec/fixtures/wsdl/multiple_namespaces.xml
|
250
237
|
- spec/fixtures/wsdl/multiple_types.xml
|
238
|
+
- spec/fixtures/wsdl/taxcloud.xml
|
251
239
|
- spec/savon/client_spec.rb
|
252
240
|
- spec/savon/core_ext/object_spec.rb
|
253
241
|
- spec/savon/core_ext/string_spec.rb
|
@@ -291,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
279
|
requirements: []
|
292
280
|
|
293
281
|
rubyforge_project: savon
|
294
|
-
rubygems_version: 1.8.
|
282
|
+
rubygems_version: 1.8.6
|
295
283
|
signing_key:
|
296
284
|
specification_version: 3
|
297
285
|
summary: Heavy metal Ruby SOAP client
|