savon 1.1.0 → 1.2.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.
@@ -45,7 +45,7 @@ describe Savon::HTTP::Error do
45
45
  def new_response(options = {})
46
46
  defaults = { :code => 200, :headers => {}, :body => Fixture.response(:authentication) }
47
47
  response = defaults.merge options
48
-
48
+
49
49
  HTTPI::Response.new response[:code], response[:headers], response[:body]
50
50
  end
51
51
 
@@ -82,7 +82,7 @@ describe Savon::SOAP::Fault do
82
82
  def new_response(options = {})
83
83
  defaults = { :code => 500, :headers => {}, :body => Fixture.response(:authentication) }
84
84
  response = defaults.merge options
85
-
85
+
86
86
  HTTPI::Response.new response[:code], response[:headers], response[:body]
87
87
  end
88
88
 
@@ -0,0 +1,207 @@
1
+ require "spec_helper"
2
+
3
+ describe Savon::SOAP::RequestBuilder do
4
+ describe "#request" do
5
+ def build_request_builder(operation)
6
+ request_builder = Savon::SOAP::RequestBuilder.new(operation)
7
+
8
+ request_builder.wsdl.document = Fixture.wsdl(:authentication)
9
+ request_builder.soap = soap
10
+ request_builder.http = http
11
+ request_builder.config = config
12
+ request_builder.wsse = wsse
13
+
14
+ soap.stubs(:types).returns({})
15
+ http.stubs(:headers).returns({})
16
+
17
+ request_builder
18
+ end
19
+
20
+ let(:soap) { stub_everything('soap') }
21
+ let(:http) { stub_everything('http') }
22
+ let(:config) { stub_everything('config') }
23
+ let(:wsse) { stub_everything('wsse') }
24
+ let(:request_builder) { build_request_builder(:get_user) }
25
+
26
+ before do
27
+ Savon::SOAP::Request.stubs(:new).returns(stub_everything('request'))
28
+ end
29
+
30
+ describe "the configuration of dependencies" do
31
+ it "sets the SOAP endpoint to the endpoint specified by the WSDL document" do
32
+ endpoint = request_builder.wsdl.endpoint
33
+ request_builder.wsdl.expects(:endpoint).returns(endpoint)
34
+ soap.expects(:endpoint=).with(endpoint)
35
+
36
+ request_builder.request
37
+ end
38
+
39
+ it "sets the SOAP element form default to the element form default specified by the WSDL document" do
40
+ element_form_default = request_builder.wsdl.element_form_default
41
+ request_builder.wsdl.expects(:element_form_default).returns(element_form_default)
42
+ soap.expects(:element_form_default=).with(element_form_default)
43
+
44
+ request_builder.request
45
+ end
46
+
47
+ it "sets the SOAP WSSE property to the WSSE property of the request builder" do
48
+ soap.expects(:wsse=).with(wsse)
49
+
50
+ request_builder.request
51
+ end
52
+
53
+ it "sets the SOAP namespace to the namespace specified by the WSDL document" do
54
+ namespace = "http://v1_0.ws.auth.order.example.com/"
55
+ soap.expects(:namespace=).with(namespace)
56
+
57
+ request_builder.request
58
+ end
59
+
60
+ it "sets the SOAP namespace identifier to nil" do
61
+ namespace_identifier = nil
62
+ soap.expects(:namespace_identifier=).with(namespace_identifier)
63
+
64
+ request_builder.request
65
+ end
66
+
67
+ it "sets the SOAP input to result in <getUser>" do
68
+ soap_input = [nil, :getUser, {}]
69
+ soap.expects(:input=).with(soap_input)
70
+
71
+ request_builder.request
72
+ end
73
+
74
+ context "when the operation namespace is specified by the WSDL" do
75
+ before do
76
+ request_builder.wsdl.operations[:authenticate][:namespace_identifier] = "tns"
77
+ end
78
+
79
+ let(:request_builder) { build_request_builder(:authenticate) }
80
+
81
+ it "sets the SOAP namespace to the operation's namespace" do
82
+ namespace = "http://v1_0.ws.auth.order.example.com/"
83
+ soap.expects(:namespace=).with(namespace)
84
+
85
+ request_builder.request
86
+ end
87
+
88
+ it "sets the SOAP namespace identifier to the operation's namespace identifier" do
89
+ namespace_identifier = :tns
90
+ soap.expects(:namespace_identifier=).with(namespace_identifier)
91
+
92
+ request_builder.request
93
+ end
94
+
95
+ it "sets the SOAP input to include the namespace identifier" do
96
+ soap_input = [:tns, :authenticate, {}]
97
+ soap.expects(:input=).with(soap_input)
98
+
99
+ request_builder.request
100
+ end
101
+ end
102
+
103
+ context "when the operation is a string" do
104
+ let(:request_builder) { build_request_builder("get_user") }
105
+ it "should set the SOAP input tag to <get_user>" do
106
+ soap_input = [nil, :get_user, {}]
107
+ soap.expects(:input=).with(soap_input)
108
+
109
+ request_builder.request
110
+ end
111
+ end
112
+
113
+ context "when attributes are specified" do
114
+ it "should add the attributes to the SOAP input" do
115
+ request_builder.attributes = { :active => true }
116
+ soap_input = [nil, :getUser, { :active => true }]
117
+ soap.expects(:input=).with(soap_input)
118
+
119
+ request_builder.request
120
+ end
121
+ end
122
+
123
+ context "when a SOAP action is specified" do
124
+ it "sets the SOAPAction header" do
125
+ request_builder.soap_action = :test_action
126
+ request_builder.request
127
+
128
+ http.headers["SOAPAction"].should == %{"test_action"}
129
+ end
130
+ end
131
+
132
+ context "when the namespace identifier is specified" do
133
+ before do
134
+ @namespace_identifier = :v1
135
+ request_builder.namespace_identifier = @namespace_identifier
136
+ end
137
+
138
+ it "should set the SOAP namespace identifier to the specified identifier" do
139
+ soap.expects(:namespace_identifier=).with(@namespace_identifier)
140
+
141
+ request_builder.request
142
+ end
143
+
144
+ it "should set the SOAP input to include the specified identifier" do
145
+ soap_input = [@namespace_identifier, :getUser, {}]
146
+ soap.expects(:input=).with(soap_input)
147
+
148
+ request_builder.request
149
+ end
150
+
151
+ it "should set the SOAP namespace to the one matched by the specified identifier" do
152
+ namespace = "http://v1_0.ws.auth.order.example.com/"
153
+ soap.expects(:namespace=).with(namespace)
154
+
155
+ request_builder.request
156
+ end
157
+ end
158
+
159
+ it "adds the WSDL document namespaces to the SOAP::XML object" do
160
+ request_builder.wsdl.type_namespaces.each do |path, uri|
161
+ soap.expects(:use_namespace).with(path, uri)
162
+ end
163
+
164
+ request_builder.request
165
+ end
166
+
167
+ it "adds the WSDL document types to the SOAP::XML object" do
168
+ request_builder.request
169
+
170
+ request_builder.wsdl.type_definitions do |path, type|
171
+ soap.types.has_key?(path).should be_true
172
+ soap.types[path].should == type
173
+ end
174
+ end
175
+ end
176
+
177
+ context "with a post-configuration block given" do
178
+ it "executes the block" do
179
+ executed = false
180
+ blk = lambda { executed = true }
181
+
182
+ request_builder.request(&blk)
183
+ executed.should == true
184
+ end
185
+
186
+ it "executes the block post-configuration" do
187
+ request_builder.namespace_identifier = :conf
188
+ blk = lambda { |rb| rb.soap.namespace_identifier = :blk }
189
+
190
+ conf_sequence = sequence('conf_sequence')
191
+ soap.expects(:namespace_identifier=).with(:conf).in_sequence(conf_sequence)
192
+ soap.expects(:namespace_identifier=).with(:blk).in_sequence(conf_sequence)
193
+
194
+ request_builder.request(&blk)
195
+ end
196
+
197
+ context "when the block has an argument" do
198
+ it "yields self to the block" do
199
+ request_builder = self.request_builder
200
+ blk = lambda { |rb_given| rb_given.should == request_builder }
201
+
202
+ request_builder.request(&blk)
203
+ end
204
+ end
205
+ end
206
+ end
207
+ end
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: 19
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Harrington
@@ -15,10 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-28 00:00:00 Z
18
+ date: 2012-09-15 00:00:00 +02:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ requirement: &id001 !ruby/object:Gem::Requirement
22
23
  none: false
23
24
  requirements:
24
25
  - - ~>
@@ -29,12 +30,12 @@ dependencies:
29
30
  - 1
30
31
  - 0
31
32
  version: 1.1.0
33
+ version_requirements: *id001
32
34
  name: nori
33
- type: :runtime
34
35
  prerelease: false
35
- requirement: *id001
36
+ type: :runtime
36
37
  - !ruby/object:Gem::Dependency
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
38
39
  none: false
39
40
  requirements:
40
41
  - - ~>
@@ -45,12 +46,12 @@ dependencies:
45
46
  - 1
46
47
  - 0
47
48
  version: 1.1.0
49
+ version_requirements: *id002
48
50
  name: httpi
49
- type: :runtime
50
51
  prerelease: false
51
- requirement: *id002
52
+ type: :runtime
52
53
  - !ruby/object:Gem::Dependency
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ requirement: &id003 !ruby/object:Gem::Requirement
54
55
  none: false
55
56
  requirements:
56
57
  - - ~>
@@ -61,12 +62,12 @@ dependencies:
61
62
  - 5
62
63
  - 0
63
64
  version: 2.5.0
65
+ version_requirements: *id003
64
66
  name: wasabi
65
- type: :runtime
66
67
  prerelease: false
67
- requirement: *id003
68
+ type: :runtime
68
69
  - !ruby/object:Gem::Dependency
69
- version_requirements: &id004 !ruby/object:Gem::Requirement
70
+ requirement: &id004 !ruby/object:Gem::Requirement
70
71
  none: false
71
72
  requirements:
72
73
  - - ~>
@@ -77,12 +78,12 @@ dependencies:
77
78
  - 2
78
79
  - 0
79
80
  version: 1.2.0
81
+ version_requirements: *id004
80
82
  name: akami
81
- type: :runtime
82
83
  prerelease: false
83
- requirement: *id004
84
+ type: :runtime
84
85
  - !ruby/object:Gem::Dependency
85
- version_requirements: &id005 !ruby/object:Gem::Requirement
86
+ requirement: &id005 !ruby/object:Gem::Requirement
86
87
  none: false
87
88
  requirements:
88
89
  - - ~>
@@ -93,12 +94,12 @@ dependencies:
93
94
  - 4
94
95
  - 5
95
96
  version: 0.4.5
97
+ version_requirements: *id005
96
98
  name: gyoku
97
- type: :runtime
98
99
  prerelease: false
99
- requirement: *id005
100
+ type: :runtime
100
101
  - !ruby/object:Gem::Dependency
101
- version_requirements: &id006 !ruby/object:Gem::Requirement
102
+ requirement: &id006 !ruby/object:Gem::Requirement
102
103
  none: false
103
104
  requirements:
104
105
  - - ">="
@@ -109,12 +110,12 @@ dependencies:
109
110
  - 1
110
111
  - 2
111
112
  version: 2.1.2
113
+ version_requirements: *id006
112
114
  name: builder
113
- type: :runtime
114
115
  prerelease: false
115
- requirement: *id006
116
+ type: :runtime
116
117
  - !ruby/object:Gem::Dependency
117
- version_requirements: &id007 !ruby/object:Gem::Requirement
118
+ requirement: &id007 !ruby/object:Gem::Requirement
118
119
  none: false
119
120
  requirements:
120
121
  - - ">="
@@ -125,12 +126,12 @@ dependencies:
125
126
  - 4
126
127
  - 0
127
128
  version: 1.4.0
129
+ version_requirements: *id007
128
130
  name: nokogiri
129
- type: :runtime
130
131
  prerelease: false
131
- requirement: *id007
132
+ type: :runtime
132
133
  - !ruby/object:Gem::Dependency
133
- version_requirements: &id008 !ruby/object:Gem::Requirement
134
+ requirement: &id008 !ruby/object:Gem::Requirement
134
135
  none: false
135
136
  requirements:
136
137
  - - ~>
@@ -140,12 +141,12 @@ dependencies:
140
141
  - 0
141
142
  - 9
142
143
  version: "0.9"
144
+ version_requirements: *id008
143
145
  name: rake
144
- type: :development
145
146
  prerelease: false
146
- requirement: *id008
147
+ type: :development
147
148
  - !ruby/object:Gem::Dependency
148
- version_requirements: &id009 !ruby/object:Gem::Requirement
149
+ requirement: &id009 !ruby/object:Gem::Requirement
149
150
  none: false
150
151
  requirements:
151
152
  - - ~>
@@ -155,12 +156,12 @@ dependencies:
155
156
  - 2
156
157
  - 10
157
158
  version: "2.10"
159
+ version_requirements: *id009
158
160
  name: rspec
159
- type: :development
160
161
  prerelease: false
161
- requirement: *id009
162
+ type: :development
162
163
  - !ruby/object:Gem::Dependency
163
- version_requirements: &id010 !ruby/object:Gem::Requirement
164
+ requirement: &id010 !ruby/object:Gem::Requirement
164
165
  none: false
165
166
  requirements:
166
167
  - - ~>
@@ -170,12 +171,12 @@ dependencies:
170
171
  - 0
171
172
  - 11
172
173
  version: "0.11"
174
+ version_requirements: *id010
173
175
  name: mocha
174
- type: :development
175
176
  prerelease: false
176
- requirement: *id010
177
+ type: :development
177
178
  - !ruby/object:Gem::Dependency
178
- version_requirements: &id011 !ruby/object:Gem::Requirement
179
+ requirement: &id011 !ruby/object:Gem::Requirement
179
180
  none: false
180
181
  requirements:
181
182
  - - ~>
@@ -185,10 +186,10 @@ dependencies:
185
186
  - 0
186
187
  - 3
187
188
  version: "0.3"
189
+ version_requirements: *id011
188
190
  name: timecop
189
- type: :development
190
191
  prerelease: false
191
- requirement: *id011
192
+ type: :development
192
193
  description: Delicious SOAP for the Ruby community
193
194
  email: me@rubiii.com
194
195
  executables: []
@@ -223,10 +224,10 @@ files:
223
224
  - lib/savon/soap/fault.rb
224
225
  - lib/savon/soap/invalid_response_error.rb
225
226
  - lib/savon/soap/request.rb
227
+ - lib/savon/soap/request_builder.rb
226
228
  - lib/savon/soap/response.rb
227
229
  - lib/savon/soap/xml.rb
228
230
  - lib/savon/version.rb
229
- - lib/savon/wasabi/document.rb
230
231
  - savon.gemspec
231
232
  - spec/fixtures/gzip/message.gz
232
233
  - spec/fixtures/response/another_soap_fault.xml
@@ -253,14 +254,15 @@ files:
253
254
  - spec/savon/model_spec.rb
254
255
  - spec/savon/savon_spec.rb
255
256
  - spec/savon/soap/fault_spec.rb
257
+ - spec/savon/soap/request_builder_spec.rb
256
258
  - spec/savon/soap/request_spec.rb
257
259
  - spec/savon/soap/response_spec.rb
258
260
  - spec/savon/soap/xml_spec.rb
259
261
  - spec/savon/soap_spec.rb
260
- - spec/savon/wasabi/document_spec.rb
261
262
  - spec/spec_helper.rb
262
263
  - spec/support/endpoint.rb
263
264
  - spec/support/fixture.rb
265
+ has_rdoc: true
264
266
  homepage: http://savonrb.com
265
267
  licenses: []
266
268
 
@@ -290,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
292
  requirements: []
291
293
 
292
294
  rubyforge_project: savon
293
- rubygems_version: 1.8.21
295
+ rubygems_version: 1.6.2
294
296
  signing_key:
295
297
  specification_version: 3
296
298
  summary: Heavy metal SOAP client