savon 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/savon.gemspec CHANGED
@@ -10,20 +10,21 @@ Gem::Specification.new do |s|
10
10
  s.email = "me@rubiii.com"
11
11
  s.homepage = "http://savonrb.com"
12
12
  s.summary = "Heavy metal Ruby SOAP client"
13
- s.description = "Savon is the heavy metal Ruby SOAP client"
13
+ s.description = "Ruby's heavy metal SOAP client"
14
14
 
15
15
  s.rubyforge_project = s.name
16
16
 
17
17
  s.add_dependency "builder", ">= 2.1.2"
18
- s.add_dependency "nori", ">= 0.2.0"
19
- s.add_dependency "httpi", ">= 0.7.8"
18
+ s.add_dependency "nori", "~> 1.0"
19
+ s.add_dependency "httpi", "~> 0.9"
20
20
  s.add_dependency "gyoku", ">= 0.4.0"
21
21
  s.add_dependency "nokogiri", ">= 1.4.0"
22
22
 
23
- s.add_development_dependency "rspec", "~> 2.4.0"
24
- s.add_development_dependency "autotest"
23
+ s.add_development_dependency "rake", "~> 0.8.7"
24
+ s.add_development_dependency "rspec", "~> 2.5.0"
25
25
  s.add_development_dependency "mocha", "~> 0.9.8"
26
26
  s.add_development_dependency "timecop", "~> 0.3.5"
27
+ s.add_development_dependency "autotest"
27
28
 
28
29
  s.files = `git ls-files`.split("\n")
29
30
  s.require_path = "lib"
@@ -3,8 +3,30 @@ require "spec_helper"
3
3
  describe String do
4
4
 
5
5
  describe "snakecase" do
6
- it "converts a lowerCamelCase String to snakecase" do
7
- "lowerCamelCase".snakecase.should == "lower_camel_case"
6
+ it "lowercases one word CamelCase" do
7
+ "Merb".snakecase.should == "merb"
8
+ end
9
+
10
+ it "makes one underscore snakecase two word CamelCase" do
11
+ "MerbCore".snakecase.should == "merb_core"
12
+ end
13
+
14
+ it "handles CamelCase with more than 2 words" do
15
+ "SoYouWantContributeToMerbCore".snakecase.should == "so_you_want_contribute_to_merb_core"
16
+ end
17
+
18
+ it "handles CamelCase with more than 2 capital letter in a row" do
19
+ "CNN".snakecase.should == "cnn"
20
+ "CNNNews".snakecase.should == "cnn_news"
21
+ "HeadlineCNNNews".snakecase.should == "headline_cnn_news"
22
+ end
23
+
24
+ it "does NOT change one word lowercase" do
25
+ "merb".snakecase.should == "merb"
26
+ end
27
+
28
+ it "leaves snake_case as is" do
29
+ "merb_core".snakecase.should == "merb_core"
8
30
  end
9
31
 
10
32
  it "converts period characters to underscores" do
@@ -25,33 +47,4 @@ describe String do
25
47
  end
26
48
  end
27
49
 
28
- describe "strip_namespace" do
29
- it "strips the namespace from a namespaced String" do
30
- "ns:customer".strip_namespace.should == "customer"
31
- end
32
-
33
- it "returns the original String for a String without namespace" do
34
- "customer".strip_namespace.should == "customer"
35
- end
36
- end
37
-
38
- describe "map_soap_response" do
39
- it "returns a DateTime Object for Strings matching the xs:dateTime format" do
40
- "2012-03-22T16:22:33".map_soap_response.should ==
41
- DateTime.new(2012, 03, 22, 16, 22, 33)
42
- end
43
-
44
- it "returns true for Strings matching 'true'" do
45
- "true".map_soap_response.should be_true
46
- end
47
-
48
- it "returns false for Strings matching 'false'" do
49
- "false".map_soap_response.should be_false
50
- end
51
-
52
- it "defaults to return the original value" do
53
- "whatever".map_soap_response.should == "whatever"
54
- end
55
- end
56
-
57
50
  end
@@ -10,25 +10,33 @@ describe Savon::SOAP::Request do
10
10
  content_type[2].should == "application/soap+xml;charset=UTF-8"
11
11
  end
12
12
 
13
+ describe ".execute" do
14
+ it "executes a SOAP request and returns the response" do
15
+ HTTPI.expects(:post).returns(HTTPI::Response.new 200, {}, Fixture.response(:authentication))
16
+ response = Savon::SOAP::Request.execute HTTPI::Request.new, soap
17
+ response.should be_a(Savon::SOAP::Response)
18
+ end
19
+ end
20
+
13
21
  describe ".new" do
14
- it "should use the SOAP endpoint for the request" do
22
+ it "uses the SOAP endpoint for the request" do
15
23
  request.request.url.should == URI(soap.endpoint)
16
24
  end
17
25
 
18
- it "should set the SOAP body for the request" do
26
+ it "sets the SOAP body for the request" do
19
27
  request.request.body.should == soap.to_xml
20
28
  end
21
29
 
22
- it "should set the 'Content-Type' header for SOAP 1.1" do
30
+ it "sets the 'Content-Type' header for SOAP 1.1" do
23
31
  request.request.headers["Content-Type"].should == Savon::SOAP::Request::ContentType[1]
24
32
  end
25
33
 
26
- it "should set the 'Content-Type' header for SOAP 1.2" do
34
+ it "sets the 'Content-Type' header for SOAP 1.2" do
27
35
  soap.version = 2
28
36
  request.request.headers["Content-Type"].should == Savon::SOAP::Request::ContentType[2]
29
37
  end
30
38
 
31
- it "should not set the 'Content-Type' header if it's already specified" do
39
+ it "does not set the 'Content-Type' header if it's already specified" do
32
40
  headers = { "Content-Type" => "text/plain" }
33
41
  request = Savon::SOAP::Request.new HTTPI::Request.new(:headers => headers), soap
34
42
  request.request.headers["Content-Type"].should == headers["Content-Type"]
@@ -36,7 +44,7 @@ describe Savon::SOAP::Request do
36
44
  end
37
45
 
38
46
  describe "#response" do
39
- it "should execute an HTTP POST request and return a Savon::SOAP::Response" do
47
+ it "executes an HTTP POST request and returns a Savon::SOAP::Response" do
40
48
  HTTPI.expects(:post).returns(HTTPI::Response.new 200, {}, Fixture.response(:authentication))
41
49
  request.response.should be_a(Savon::SOAP::Response)
42
50
  end
@@ -116,6 +116,13 @@ describe Savon::SOAP::Response do
116
116
  end
117
117
  end
118
118
 
119
+ describe "#[]" do
120
+ it "should return the SOAP response body as a Hash" do
121
+ soap_response[:authenticate_response][:return].should ==
122
+ Fixture.response_hash(:authentication)[:authenticate_response][:return]
123
+ end
124
+ end
125
+
119
126
  describe "#header" do
120
127
  it "should return the SOAP response header as a Hash" do
121
128
  response = soap_response :body => Fixture.response(:header)
@@ -123,31 +130,54 @@ describe Savon::SOAP::Response do
123
130
  end
124
131
  end
125
132
 
126
- describe "#[]" do
127
- it "should return the SOAP response body as a Hash" do
128
- soap_response[:authenticate_response][:return].should ==
129
- Fixture.response_hash(:authentication)[:authenticate_response][:return]
130
- end
131
- end
133
+ %w(body to_hash).each do |method|
134
+ describe "##{method}" do
135
+ it "should return the SOAP response body as a Hash" do
136
+ soap_response.send(method)[:authenticate_response][:return].should ==
137
+ Fixture.response_hash(:authentication)[:authenticate_response][:return]
138
+ end
132
139
 
133
- describe "#to_hash" do
134
- it "should return the SOAP response body as a Hash" do
135
- soap_response.to_hash[:authenticate_response][:return].should ==
136
- Fixture.response_hash(:authentication)[:authenticate_response][:return]
140
+ it "should return a Hash for a SOAP multiRef response" do
141
+ hash = soap_response(:body => Fixture.response(:multi_ref)).send(method)
142
+
143
+ hash[:list_response].should be_a(Hash)
144
+ hash[:multi_ref].should be_an(Array)
145
+ end
146
+
147
+ it "should add existing namespaced elements as an array" do
148
+ hash = soap_response(:body => Fixture.response(:list)).send(method)
149
+
150
+ hash[:multi_namespaced_entry_response][:history].should be_a(Hash)
151
+ hash[:multi_namespaced_entry_response][:history][:case].should be_an(Array)
152
+ end
137
153
  end
138
154
  end
139
155
 
140
156
  describe "#to_array" do
141
- it "should delegate to Savon::SOAP::XML.to_array" do
142
- Savon::SOAP::XML.expects(:to_array).with(soap_response.to_hash, :authenticate_response, :return)
143
- soap_response.to_array :authenticate_response, :return
157
+ context "when the given path exists" do
158
+ it "should return an Array containing the path value" do
159
+ soap_response.to_array(:authenticate_response, :return).should ==
160
+ [Fixture.response_hash(:authentication)[:authenticate_response][:return]]
161
+ end
162
+ end
163
+
164
+ context "when the given path returns nil" do
165
+ it "should return an empty Array" do
166
+ soap_response.to_array(:authenticate_response, :undefined).should == []
167
+ end
168
+ end
169
+
170
+ context "when the given path does not exist at all" do
171
+ it "should return an empty Array" do
172
+ soap_response.to_array(:authenticate_response, :some, :undefined, :path).should == []
173
+ end
144
174
  end
145
175
  end
146
176
 
147
- describe "#basic_hash" do
177
+ describe "#hash" do
148
178
  it "should return the complete SOAP response XML as a Hash" do
149
179
  response = soap_response :body => Fixture.response(:header)
150
- response.basic_hash["soap:Envelope"]["soap:Header"]["SessionNumber"].should == "ABCD1234"
180
+ response.hash[:envelope][:header][:session_number].should == "ABCD1234"
151
181
  end
152
182
  end
153
183
 
@@ -3,64 +3,6 @@ require "spec_helper"
3
3
  describe Savon::SOAP::XML do
4
4
  let(:xml) { Savon::SOAP::XML.new Endpoint.soap, :authenticate, :id => 1 }
5
5
 
6
- describe ".to_hash" do
7
- it "should return a given SOAP response body as a Hash" do
8
- hash = Savon::SOAP::XML.to_hash Fixture.response(:authentication)
9
- hash[:authenticate_response][:return].should == {
10
- :success => true,
11
- :authentication_value => {
12
- :token_hash => "AAAJxA;cIedoT;mY10ExZwG6JuKgp2OYKxow==",
13
- :token => "a68d1d6379b62ff339a0e0c69ed4d9cf",
14
- :client => "radclient"
15
- }
16
- }
17
- end
18
-
19
- it "should return a Hash for a SOAP multiRef response" do
20
- hash = Savon::SOAP::XML.to_hash Fixture.response(:multi_ref)
21
-
22
- hash[:list_response].should be_a(Hash)
23
- hash[:multi_ref].should be_an(Array)
24
- end
25
-
26
- it "should add existing namespaced elements as an array" do
27
- hash = Savon::SOAP::XML.to_hash Fixture.response(:list)
28
-
29
- hash[:multi_namespaced_entry_response][:history].should be_a(Hash)
30
- hash[:multi_namespaced_entry_response][:history][:case].should be_an(Array)
31
- end
32
- end
33
-
34
- describe ".parse" do
35
- it "should convert the given XML into a Hash" do
36
- hash = Savon::SOAP::XML.parse Fixture.response(:list)
37
- hash["soapenv:Envelope"]["soapenv:Body"].should be_a(Hash)
38
- end
39
- end
40
-
41
- describe ".to_array" do
42
- let(:response_hash) { Fixture.response_hash :authentication }
43
-
44
- context "when the given path exists" do
45
- it "should return an Array containing the path value" do
46
- Savon::SOAP::XML.to_array(response_hash, :authenticate_response, :return).should ==
47
- [response_hash[:authenticate_response][:return]]
48
- end
49
- end
50
-
51
- context "when the given path returns nil" do
52
- it "should return an empty Array" do
53
- Savon::SOAP::XML.to_array(response_hash, :authenticate_response, :undefined).should == []
54
- end
55
- end
56
-
57
- context "when the given path does not exist at all" do
58
- it "should return an empty Array" do
59
- Savon::SOAP::XML.to_array(response_hash, :authenticate_response, :some, :wrong, :path).should == []
60
- end
61
- end
62
- end
63
-
64
6
  describe ".new" do
65
7
  it "should accept an endpoint, an input tag and a SOAP body" do
66
8
  xml = Savon::SOAP::XML.new Endpoint.soap, :authentication, :id => 1
@@ -116,6 +58,11 @@ describe Savon::SOAP::XML do
116
58
  xml.header = { "MySecret" => "abc" }
117
59
  xml.header.should == { "MySecret" => "abc" }
118
60
  end
61
+
62
+ it "should use the global soap_header if set" do
63
+ Savon.stubs(:soap_header).returns({ "MySecret" => "abc" })
64
+ xml.header.should == { "MySecret" => "abc" }
65
+ end
119
66
  end
120
67
 
121
68
  describe "#env_namespace" do
@@ -13,9 +13,4 @@ describe Savon::SOAP do
13
13
  Savon::SOAP::Versions.should == (1..2)
14
14
  end
15
15
 
16
- it "should contain a Regexp matching the xs:dateTime format" do
17
- Savon::SOAP::DateTimeRegexp.should be_a(Regexp)
18
- (Savon::SOAP::DateTimeRegexp === "2012-03-22T16:22:33").should be_true
19
- end
20
-
21
16
  end
@@ -4,8 +4,16 @@ describe Savon::WSDL::Request do
4
4
  let(:http_request) { HTTPI::Request.new :url => Endpoint.wsdl }
5
5
  let(:request) { Savon::WSDL::Request.new http_request }
6
6
 
7
+ describe ".execute" do
8
+ it "executes a WSDL request and returns the response" do
9
+ response = HTTPI::Response.new 200, {}, Fixture.response(:authentication)
10
+ HTTPI.expects(:get).with(http_request).returns(response)
11
+ Savon::WSDL::Request.execute(http_request).should == response
12
+ end
13
+ end
14
+
7
15
  describe "#response" do
8
- it "execute an HTTP GET request and return the HTTPI::Response" do
16
+ it "executes an HTTP GET request and returns the HTTPI::Response" do
9
17
  response = HTTPI::Response.new 200, {}, Fixture.response(:authentication)
10
18
  HTTPI.expects(:get).with(http_request).returns(response)
11
19
  request.response.should == response
@@ -151,7 +151,8 @@ describe Savon::WSSE do
151
151
  end
152
152
 
153
153
  it "should contain a wsu:Created tag" do
154
- wsse.to_xml.should match(/<wsu:Created>#{Savon::SOAP::DateTimeRegexp}.+<\/wsu:Created>/)
154
+ datetime_regexp = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/
155
+ wsse.to_xml.should match(/<wsu:Created>#{datetime_regexp}.+<\/wsu:Created>/)
155
156
  end
156
157
 
157
158
  it "should contain the PasswordDigest type attribute" do
@@ -163,7 +164,7 @@ describe Savon::WSSE do
163
164
  before { wsse.timestamp = true }
164
165
 
165
166
  it "should contain a wsse:Timestamp node" do
166
- wsse.to_xml.should include('<wsse:Timestamp wsu:Id="Timestamp-1" ' +
167
+ wsse.to_xml.should include('<wsu:Timestamp wsu:Id="Timestamp-1" ' +
167
168
  'xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">')
168
169
  end
169
170
 
data/spec/spec_helper.rb CHANGED
@@ -5,10 +5,11 @@ RSpec.configure do |config|
5
5
  config.mock_with :mocha
6
6
  end
7
7
 
8
- require "savon"
9
-
10
- # Disable logging for specs.
11
- Savon.log = false
8
+ # Disable logging and deprecations for specs.
9
+ Savon.configure do |config|
10
+ config.log = false
11
+ config.deprecate = false
12
+ end
12
13
 
13
14
  require "support/endpoint"
14
15
  require "support/fixture"
@@ -10,13 +10,11 @@ class Fixture
10
10
 
11
11
  def response_hash(fixture)
12
12
  @response_hash ||= {}
13
- @response_hash[fixture] ||= Savon::SOAP::XML.to_hash response(fixture)
13
+ @response_hash[fixture] ||= Nori.parse(response(fixture))[:envelope][:body]
14
14
  end
15
15
 
16
16
  TYPES.each do |type, ext|
17
- define_method type do |fixture|
18
- self[type, fixture]
19
- end
17
+ define_method(type) { |fixture| self[type, fixture] }
20
18
  end
21
19
 
22
20
  private
@@ -29,7 +27,7 @@ class Fixture
29
27
  def read_file(type, fixture)
30
28
  path = File.expand_path "../../fixtures/#{type}/#{fixture}.#{TYPES[type]}", __FILE__
31
29
  raise ArgumentError, "Unable to load: #{path}" unless File.exist? path
32
-
30
+
33
31
  File.read path
34
32
  end
35
33
 
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 9
9
- - 2
10
- version: 0.9.2
5
+ version: 0.9.3
11
6
  platform: ruby
12
7
  authors:
13
8
  - Daniel Harrington
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-04-30 00:00:00 +02:00
19
- default_executable:
13
+ date: 2011-06-29 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: builder
@@ -26,11 +20,6 @@ dependencies:
26
20
  requirements:
27
21
  - - ">="
28
22
  - !ruby/object:Gem::Version
29
- hash: 15
30
- segments:
31
- - 2
32
- - 1
33
- - 2
34
23
  version: 2.1.2
35
24
  type: :runtime
36
25
  version_requirements: *id001
@@ -40,14 +29,9 @@ dependencies:
40
29
  requirement: &id002 !ruby/object:Gem::Requirement
41
30
  none: false
42
31
  requirements:
43
- - - ">="
32
+ - - ~>
44
33
  - !ruby/object:Gem::Version
45
- hash: 23
46
- segments:
47
- - 0
48
- - 2
49
- - 0
50
- version: 0.2.0
34
+ version: "1.0"
51
35
  type: :runtime
52
36
  version_requirements: *id002
53
37
  - !ruby/object:Gem::Dependency
@@ -56,14 +40,9 @@ dependencies:
56
40
  requirement: &id003 !ruby/object:Gem::Requirement
57
41
  none: false
58
42
  requirements:
59
- - - ">="
43
+ - - ~>
60
44
  - !ruby/object:Gem::Version
61
- hash: 19
62
- segments:
63
- - 0
64
- - 7
65
- - 8
66
- version: 0.7.8
45
+ version: "0.9"
67
46
  type: :runtime
68
47
  version_requirements: *id003
69
48
  - !ruby/object:Gem::Dependency
@@ -74,11 +53,6 @@ dependencies:
74
53
  requirements:
75
54
  - - ">="
76
55
  - !ruby/object:Gem::Version
77
- hash: 15
78
- segments:
79
- - 0
80
- - 4
81
- - 0
82
56
  version: 0.4.0
83
57
  type: :runtime
84
58
  version_requirements: *id004
@@ -90,42 +64,29 @@ dependencies:
90
64
  requirements:
91
65
  - - ">="
92
66
  - !ruby/object:Gem::Version
93
- hash: 7
94
- segments:
95
- - 1
96
- - 4
97
- - 0
98
67
  version: 1.4.0
99
68
  type: :runtime
100
69
  version_requirements: *id005
101
70
  - !ruby/object:Gem::Dependency
102
- name: rspec
71
+ name: rake
103
72
  prerelease: false
104
73
  requirement: &id006 !ruby/object:Gem::Requirement
105
74
  none: false
106
75
  requirements:
107
76
  - - ~>
108
77
  - !ruby/object:Gem::Version
109
- hash: 31
110
- segments:
111
- - 2
112
- - 4
113
- - 0
114
- version: 2.4.0
78
+ version: 0.8.7
115
79
  type: :development
116
80
  version_requirements: *id006
117
81
  - !ruby/object:Gem::Dependency
118
- name: autotest
82
+ name: rspec
119
83
  prerelease: false
120
84
  requirement: &id007 !ruby/object:Gem::Requirement
121
85
  none: false
122
86
  requirements:
123
- - - ">="
87
+ - - ~>
124
88
  - !ruby/object:Gem::Version
125
- hash: 3
126
- segments:
127
- - 0
128
- version: "0"
89
+ version: 2.5.0
129
90
  type: :development
130
91
  version_requirements: *id007
131
92
  - !ruby/object:Gem::Dependency
@@ -136,11 +97,6 @@ dependencies:
136
97
  requirements:
137
98
  - - ~>
138
99
  - !ruby/object:Gem::Version
139
- hash: 43
140
- segments:
141
- - 0
142
- - 9
143
- - 8
144
100
  version: 0.9.8
145
101
  type: :development
146
102
  version_requirements: *id008
@@ -152,15 +108,21 @@ dependencies:
152
108
  requirements:
153
109
  - - ~>
154
110
  - !ruby/object:Gem::Version
155
- hash: 25
156
- segments:
157
- - 0
158
- - 3
159
- - 5
160
111
  version: 0.3.5
161
112
  type: :development
162
113
  version_requirements: *id009
163
- description: Savon is the heavy metal Ruby SOAP client
114
+ - !ruby/object:Gem::Dependency
115
+ name: autotest
116
+ prerelease: false
117
+ requirement: &id010 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: "0"
123
+ type: :development
124
+ version_requirements: *id010
125
+ description: Ruby's heavy metal SOAP client
164
126
  email: me@rubiii.com
165
127
  executables: []
166
128
 
@@ -180,7 +142,6 @@ files:
180
142
  - Rakefile
181
143
  - lib/savon.rb
182
144
  - lib/savon/client.rb
183
- - lib/savon/core_ext/hash.rb
184
145
  - lib/savon/core_ext/object.rb
185
146
  - lib/savon/core_ext/string.rb
186
147
  - lib/savon/core_ext/time.rb
@@ -213,7 +174,6 @@ files:
213
174
  - spec/fixtures/wsdl/soap12.xml
214
175
  - spec/fixtures/wsdl/two_bindings.xml
215
176
  - spec/savon/client_spec.rb
216
- - spec/savon/core_ext/hash_spec.rb
217
177
  - spec/savon/core_ext/object_spec.rb
218
178
  - spec/savon/core_ext/string_spec.rb
219
179
  - spec/savon/core_ext/time_spec.rb
@@ -231,7 +191,6 @@ files:
231
191
  - spec/spec_helper.rb
232
192
  - spec/support/endpoint.rb
233
193
  - spec/support/fixture.rb
234
- has_rdoc: true
235
194
  homepage: http://savonrb.com
236
195
  licenses: []
237
196
 
@@ -245,23 +204,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
204
  requirements:
246
205
  - - ">="
247
206
  - !ruby/object:Gem::Version
248
- hash: 3
249
- segments:
250
- - 0
251
207
  version: "0"
252
208
  required_rubygems_version: !ruby/object:Gem::Requirement
253
209
  none: false
254
210
  requirements:
255
211
  - - ">="
256
212
  - !ruby/object:Gem::Version
257
- hash: 3
258
- segments:
259
- - 0
260
213
  version: "0"
261
214
  requirements: []
262
215
 
263
216
  rubyforge_project: savon
264
- rubygems_version: 1.4.2
217
+ rubygems_version: 1.8.4
265
218
  signing_key:
266
219
  specification_version: 3
267
220
  summary: Heavy metal Ruby SOAP client