washout_builder 0.14.1 → 0.15.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/.rubocop.yml +68 -0
- data/.travis.yml +1 -1
- data/Appraisals +9 -1
- data/Gemfile +2 -3
- data/Rakefile +17 -20
- data/app/controllers/washout_builder/washout_builder_controller.rb +79 -79
- data/app/helpers/washout_builder_complex_type_helper.rb +16 -23
- data/app/helpers/washout_builder_fault_type_helper.rb +12 -13
- data/app/helpers/washout_builder_method_arguments_helper.rb +24 -26
- data/app/helpers/washout_builder_method_list_helper.rb +16 -11
- data/app/helpers/washout_builder_method_return_type_helper.rb +14 -12
- data/app/views/wash_with_html/doc.builder +2 -2
- data/bin/appraisal +16 -0
- data/bin/autospec +16 -0
- data/bin/bundler +16 -0
- data/bin/cdiff +16 -0
- data/bin/coderay +16 -0
- data/bin/colortab +16 -0
- data/bin/coveralls +16 -0
- data/bin/decolor +16 -0
- data/bin/erubis +16 -0
- data/bin/guard +16 -0
- data/bin/htmldiff +16 -0
- data/bin/ldiff +16 -0
- data/bin/listen +16 -0
- data/bin/nokogiri +16 -0
- data/bin/phare +16 -0
- data/bin/pry +16 -0
- data/bin/rackup +16 -0
- data/bin/rails +16 -0
- data/bin/rake +16 -0
- data/bin/restclient +16 -0
- data/bin/rspec +16 -0
- data/bin/rubocop +16 -0
- data/bin/ruby-parse +16 -0
- data/bin/ruby-rewrite +16 -0
- data/bin/sass +16 -0
- data/bin/sass-convert +16 -0
- data/bin/scss +16 -0
- data/bin/scss-lint +16 -0
- data/bin/term_display +16 -0
- data/bin/term_mandel +16 -0
- data/bin/thor +16 -0
- data/bin/uuid +16 -0
- data/config/routes.rb +3 -3
- data/init.rb +1 -1
- data/lib/washout_builder.rb +20 -29
- data/lib/washout_builder/document/complex_type.rb +70 -75
- data/lib/washout_builder/document/exception_model.rb +46 -51
- data/lib/washout_builder/document/generator.rb +56 -66
- data/lib/washout_builder/document/shared_complex_type.rb +2 -4
- data/lib/washout_builder/engine.rb +1 -2
- data/lib/washout_builder/soap.rb +6 -10
- data/lib/washout_builder/type.rb +9 -23
- data/lib/washout_builder/version.rb +5 -5
- data/spec/app/controllers/washout_builder_controller_spec.rb +26 -28
- data/spec/app/helpers/washout_builder_complex_type_helper_spec.rb +37 -45
- data/spec/app/helpers/washout_builder_fault_type_helper_spec.rb +65 -77
- data/spec/app/helpers/washout_builder_method_arguments_helper_spec.rb +65 -76
- data/spec/app/helpers/washout_builder_method_list_helper_spec.rb +30 -35
- data/spec/app/helpers/washout_builder_method_return_type_helper_spec.rb +25 -27
- data/spec/dummy/config/application.rb +4 -4
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/development.rb +2 -3
- data/spec/dummy/config/environments/test.rb +3 -3
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/routes.rb +0 -1
- data/spec/dummy/script/rails +2 -2
- data/spec/integration/washout_builder_all_services_spec.rb +2 -5
- data/spec/integration/washout_builder_service_spec.rb +2 -5
- data/spec/lib/washout_builder/document/complex_type_spec.rb +98 -118
- data/spec/lib/washout_builder/document/exception_model_spec.rb +49 -54
- data/spec/lib/washout_builder/document/generator_spec.rb +93 -118
- data/spec/lib/washout_builder/type_spec.rb +17 -29
- data/spec/lib/washout_builder_spec.rb +293 -308
- data/spec/spec_helper.rb +24 -30
- data/spec/support/complex_types/fluffy.rb +3 -3
- data/spec/support/complex_types/fluffy_container.rb +3 -3
- data/spec/support/complex_types/project_type.rb +4 -5
- data/spec/support/complex_types/test_type.rb +4 -4
- data/washout_builder.gemspec +5 -2
- metadata +78 -3
@@ -1,109 +1,107 @@
|
|
1
|
-
#encoding:utf-8
|
1
|
+
# encoding:utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe WashoutBuilder do
|
6
|
-
|
7
6
|
before(:each) do
|
8
7
|
WashOut::Engine.config.wash_out[:wsdl_style] = 'rpc'
|
9
8
|
WashOut::Engine.config.wash_out[:parser] = :nokogiri
|
10
9
|
WashOut::Engine.config.wash_out[:catch_xml_errors] = true
|
11
|
-
WashOut::Engine.config.wash_out[:camelize_wsdl] =
|
10
|
+
WashOut::Engine.config.wash_out[:camelize_wsdl] = 'lower'
|
12
11
|
end
|
13
|
-
|
12
|
+
|
14
13
|
let :nori do
|
15
14
|
Nori.new(
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
15
|
+
strip_namespaces: true,
|
16
|
+
advanced_typecasting: true,
|
17
|
+
convert_tags_to: ->(x) { x.snakecase.to_sym }
|
19
18
|
)
|
20
19
|
end
|
21
20
|
|
22
|
-
def savon(method, message={}, &block)
|
23
|
-
message = {:
|
21
|
+
def savon(method, message = {}, &block)
|
22
|
+
message = { value: message } unless message.is_a?(Hash)
|
24
23
|
|
25
|
-
savon_client = Savon::Client.new(:
|
26
|
-
result = savon_client.call(method, :
|
24
|
+
savon_client = Savon::Client.new(log: false, wsdl: 'http://app/api/wsdl', &block)
|
25
|
+
result = savon_client.call(method, message: message)
|
27
26
|
result.respond_to?(:to_hash) ? result.to_hash : result
|
28
27
|
end
|
29
28
|
|
30
|
-
def savon!(method, message={}, &block)
|
31
|
-
message = {:
|
29
|
+
def savon!(method, message = {}, &block)
|
30
|
+
message = { value: message } unless message.is_a?(Hash)
|
32
31
|
|
33
|
-
savon_client = Savon::Client.new(:
|
34
|
-
result = savon_client.call(method, :
|
32
|
+
savon_client = Savon::Client.new(log: true, wsdl: 'http://app/api/wsdl', &block)
|
33
|
+
result = savon_client.call(method, message: message)
|
35
34
|
result.respond_to?(:to_hash) ? result.to_hash : result
|
36
35
|
end
|
37
|
-
|
38
|
-
describe
|
39
|
-
it
|
40
|
-
lambda
|
36
|
+
|
37
|
+
describe 'Module' do
|
38
|
+
it 'includes' do
|
39
|
+
lambda do
|
41
40
|
mock_controller do
|
42
41
|
# nothing
|
43
42
|
end
|
44
|
-
|
43
|
+
end.should_not raise_exception
|
45
44
|
end
|
46
45
|
|
47
|
-
it
|
48
|
-
lambda
|
46
|
+
it 'allows definition of a simple action' do
|
47
|
+
lambda do
|
49
48
|
mock_controller do
|
50
|
-
soap_action
|
49
|
+
soap_action 'answer', args: nil, return: :integer
|
51
50
|
end
|
52
|
-
|
51
|
+
end.should_not raise_exception
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
56
|
-
describe
|
55
|
+
describe 'WSDL' do
|
57
56
|
let :wsdl do
|
58
57
|
mock_controller do
|
59
|
-
soap_action :result, :
|
60
|
-
|
61
|
-
soap_action
|
62
|
-
:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
soap_action
|
68
|
-
|
58
|
+
soap_action :result, args: nil, return: :int
|
59
|
+
|
60
|
+
soap_action 'getArea', args: {
|
61
|
+
circle: [{
|
62
|
+
center: { x: [:integer], y: :integer },
|
63
|
+
radius: :double
|
64
|
+
}] },
|
65
|
+
return: { area: :double }
|
66
|
+
soap_action 'rocky', args: { circle1: { x: :integer } },
|
67
|
+
return: { circle2: { y: :integer } }
|
69
68
|
end
|
70
69
|
|
71
|
-
HTTPI.get(
|
70
|
+
HTTPI.get('http://app/api/wsdl').body
|
72
71
|
end
|
73
72
|
|
74
73
|
let :xml do
|
75
74
|
nori.parse wsdl
|
76
75
|
end
|
77
76
|
|
78
|
-
it
|
77
|
+
it 'lists operations' do
|
79
78
|
operations = xml[:definitions][:binding][:operation]
|
80
79
|
operations.should be_a_kind_of(Array)
|
81
80
|
|
82
|
-
operations.map{|e| e[:'@name']}.sort.should ==
|
81
|
+
operations.map { |e| e[:'@name'] }.sort.should == %w(Result getArea rocky).sort
|
83
82
|
end
|
84
83
|
|
85
|
-
it
|
84
|
+
it 'defines complex types' do
|
86
85
|
wsdl.include?('<xsd:complexType name="Circle1">').should == true
|
87
86
|
end
|
88
87
|
|
89
|
-
it
|
90
|
-
x = xml[:definitions][:types][:schema][:complex_type]
|
91
|
-
|
92
|
-
|
88
|
+
it 'defines arrays' do
|
89
|
+
x = xml[:definitions][:types][:schema][:complex_type]
|
90
|
+
.find { |inneer_x| inneer_x[:'@name'] == 'Center' }[:sequence][:element]
|
91
|
+
.find { |inneer_x| inneer_x[:'@name'] == 'X' }
|
93
92
|
|
94
|
-
x[:'@min_occurs'].should
|
95
|
-
x[:'@max_occurs'].should
|
93
|
+
x[:'@min_occurs'].should eq('0')
|
94
|
+
x[:'@max_occurs'].should eq('unbounded')
|
96
95
|
end
|
97
96
|
end
|
98
97
|
|
99
|
-
describe
|
100
|
-
|
101
|
-
|
102
|
-
it "accepts requests with no HTTP header" do
|
98
|
+
describe 'Dispatcher' do
|
99
|
+
context 'simple actions' do
|
100
|
+
it 'accepts requests with no HTTP header' do
|
103
101
|
mock_controller do
|
104
|
-
soap_action
|
102
|
+
soap_action 'answer', args: nil, return: :int
|
105
103
|
def answer
|
106
|
-
render :
|
104
|
+
render soap: '42'
|
107
105
|
end
|
108
106
|
end
|
109
107
|
|
@@ -118,7 +116,7 @@ describe WashoutBuilder do
|
|
118
116
|
</env:Envelope>
|
119
117
|
XML
|
120
118
|
|
121
|
-
HTTPI.post(
|
119
|
+
HTTPI.post('http://app/api/action', request).body.should == <<-XML
|
122
120
|
<?xml version="1.0" encoding="UTF-8"?>
|
123
121
|
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="false">
|
124
122
|
<soap:Body>
|
@@ -130,535 +128,522 @@ describe WashoutBuilder do
|
|
130
128
|
XML
|
131
129
|
end
|
132
130
|
|
133
|
-
it
|
131
|
+
it 'accept no parameters' do
|
134
132
|
mock_controller do
|
135
|
-
soap_action
|
133
|
+
soap_action 'answer', args: nil, return: :int
|
136
134
|
def answer
|
137
|
-
render :
|
135
|
+
render soap: '42'
|
138
136
|
end
|
139
137
|
end
|
140
138
|
|
141
|
-
savon(:answer)[:answer_response][:value]
|
142
|
-
should ==
|
139
|
+
savon(:answer)[:answer_response][:value]
|
140
|
+
.should == '42'
|
143
141
|
end
|
144
142
|
|
145
|
-
it
|
143
|
+
it 'accept insufficient parameters' do
|
146
144
|
mock_controller do
|
147
|
-
soap_action
|
145
|
+
soap_action 'answer', args: { a: :integer }, return: :integer
|
148
146
|
def answer
|
149
|
-
render :
|
147
|
+
render soap: '42'
|
150
148
|
end
|
151
149
|
end
|
152
150
|
|
153
|
-
savon(:answer)[:answer_response][:value]
|
154
|
-
should ==
|
151
|
+
savon(:answer)[:answer_response][:value]
|
152
|
+
.should == '42'
|
155
153
|
end
|
156
154
|
|
157
|
-
it
|
155
|
+
it 'accept empty parameter' do
|
158
156
|
mock_controller do
|
159
|
-
soap_action
|
157
|
+
soap_action 'answer', args: { a: :string }, return: { a: :string }
|
160
158
|
def answer
|
161
|
-
render :
|
159
|
+
render soap: { a: params[:a] }
|
162
160
|
end
|
163
161
|
end
|
164
|
-
savon(:answer, :
|
165
|
-
should == {:"@xsi:type"=>
|
162
|
+
savon(:answer, a: '')[:answer_response][:a]
|
163
|
+
.should == { :"@xsi:type" => 'xsd:string' }
|
166
164
|
end
|
167
165
|
|
168
|
-
it
|
166
|
+
it 'accept one parameter' do
|
169
167
|
mock_controller do
|
170
|
-
soap_action
|
168
|
+
soap_action 'checkAnswer', args: :integer, return: :boolean, to: 'check_answer'
|
171
169
|
def check_answer
|
172
|
-
render :
|
170
|
+
render soap: (params[:value] == 42)
|
173
171
|
end
|
174
172
|
end
|
175
173
|
|
176
|
-
savon(:check_answer, 42)[:check_answer_response][:value].should
|
177
|
-
savon(:check_answer, 13)[:check_answer_response][:value].should
|
174
|
+
savon(:check_answer, 42)[:check_answer_response][:value].should eq true
|
175
|
+
savon(:check_answer, 13)[:check_answer_response][:value].should eq false
|
178
176
|
end
|
179
177
|
|
180
|
-
it
|
178
|
+
it 'accept two parameters' do
|
181
179
|
mock_controller do
|
182
|
-
soap_action
|
180
|
+
soap_action 'funky', args: { a: :integer, b: :string }, return: :string
|
183
181
|
def funky
|
184
|
-
render :
|
182
|
+
render soap: ((params[:a] * 10).to_s + params[:b])
|
185
183
|
end
|
186
184
|
end
|
187
185
|
|
188
|
-
savon(:funky, :
|
186
|
+
savon(:funky, a: 42, b: 'k')[:funky_response][:value].should == '420k'
|
189
187
|
end
|
190
188
|
end
|
191
189
|
|
192
|
-
context
|
193
|
-
it
|
190
|
+
context 'complex actions' do
|
191
|
+
it 'accept nested structures' do
|
194
192
|
mock_controller do
|
195
|
-
soap_action
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
def
|
193
|
+
soap_action 'findArea', args: { circle: { center: { x: :integer,
|
194
|
+
y: :integer },
|
195
|
+
radius: :double } },
|
196
|
+
return: { area: :double,
|
197
|
+
distance_from_o: :double },
|
198
|
+
to: :find_area
|
199
|
+
def find_area
|
202
200
|
circle = params[:circle]
|
203
|
-
render :
|
204
|
-
|
201
|
+
render soap: { area: Math::PI * circle[:radius]**2,
|
202
|
+
distance_from_o: Math.sqrt(circle[:center][:x]**2 + circle[:center][:y]**2) }
|
205
203
|
end
|
206
204
|
end
|
207
205
|
|
208
|
-
message = { :
|
209
|
-
|
206
|
+
message = { circle: { center: { x: 3, y: 4 },
|
207
|
+
radius: 5 } }
|
210
208
|
|
211
|
-
savon(:
|
212
|
-
should == ({ :
|
209
|
+
savon(:find_area, message)[:find_area_response]
|
210
|
+
.should == ({ area: (Math::PI * 25).to_s, distance_from_o: (5.0).to_s })
|
213
211
|
end
|
214
212
|
|
215
|
-
it
|
213
|
+
it 'accept arrays' do
|
216
214
|
mock_controller do
|
217
|
-
soap_action
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
215
|
+
soap_action 'rumba',
|
216
|
+
args: {
|
217
|
+
rumbas: [:integer]
|
218
|
+
},
|
219
|
+
return: nil
|
222
220
|
def rumba
|
223
|
-
params
|
224
|
-
render :
|
221
|
+
raise 'not ok' unless params == { 'rumbas' => [1, 2, 3] }
|
222
|
+
render soap: nil
|
225
223
|
end
|
226
224
|
end
|
227
225
|
|
228
|
-
savon(:rumba, :
|
226
|
+
savon(:rumba, rumbas: [1, 2, 3])
|
229
227
|
end
|
230
228
|
|
231
|
-
it
|
229
|
+
it 'accept empty arrays' do
|
232
230
|
mock_controller do
|
233
|
-
soap_action
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
231
|
+
soap_action 'rumba',
|
232
|
+
args: {
|
233
|
+
my_array: [:integer]
|
234
|
+
},
|
235
|
+
return: nil
|
238
236
|
def rumba
|
239
|
-
params
|
240
|
-
render :
|
237
|
+
raise 'not ok' unless params == {}
|
238
|
+
render soap: nil
|
241
239
|
end
|
242
240
|
end
|
243
|
-
savon(:rumba, :
|
241
|
+
savon(:rumba, empty: [])
|
244
242
|
end
|
245
243
|
|
246
|
-
it
|
244
|
+
it 'accept nested empty arrays' do
|
247
245
|
mock_controller do
|
248
|
-
soap_action
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
246
|
+
soap_action 'rumba',
|
247
|
+
args: {
|
248
|
+
nested: { my_array: [:integer] }
|
249
|
+
},
|
250
|
+
return: nil
|
253
251
|
def rumba
|
254
|
-
params
|
255
|
-
render :
|
252
|
+
raise 'not ok' unless params == { 'nested' => {} }
|
253
|
+
render soap: nil
|
256
254
|
end
|
257
255
|
end
|
258
|
-
savon(:rumba, :
|
256
|
+
savon(:rumba, nested: { my_array: [] })
|
259
257
|
end
|
260
258
|
|
261
|
-
it
|
259
|
+
it 'accept nested structures inside arrays' do
|
262
260
|
mock_controller do
|
263
|
-
soap_action
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
261
|
+
soap_action 'rumba',
|
262
|
+
args: {
|
263
|
+
rumbas: [{
|
264
|
+
zombies: :string,
|
265
|
+
puppies: :string
|
266
|
+
}]
|
267
|
+
},
|
268
|
+
return: nil
|
271
269
|
def rumba
|
272
|
-
params
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
}
|
278
|
-
render :soap => nil
|
270
|
+
raise 'not ok' unless params == { 'rumbas' => [
|
271
|
+
{ 'zombies' => 'suck', 'puppies' => 'rock' },
|
272
|
+
{ 'zombies' => 'slow', 'puppies' => 'fast' }
|
273
|
+
] }
|
274
|
+
render soap: nil
|
279
275
|
end
|
280
276
|
end
|
281
277
|
|
282
|
-
savon :rumba, :
|
283
|
-
{:
|
284
|
-
{:
|
278
|
+
savon :rumba, rumbas: [
|
279
|
+
{ zombies: 'suck', puppies: 'rock' },
|
280
|
+
{ zombies: 'slow', puppies: 'fast' }
|
285
281
|
]
|
286
282
|
end
|
287
283
|
|
288
|
-
it
|
284
|
+
it 'respond with nested structures' do
|
289
285
|
mock_controller do
|
290
|
-
soap_action
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
286
|
+
soap_action 'gogogo',
|
287
|
+
args: nil,
|
288
|
+
return: {
|
289
|
+
zoo: :string,
|
290
|
+
boo: { moo: :string, doo: :string }
|
291
|
+
}
|
296
292
|
def gogogo
|
297
|
-
render :
|
298
|
-
:
|
299
|
-
:
|
293
|
+
render soap: {
|
294
|
+
zoo: 'zoo',
|
295
|
+
boo: { moo: 'moo', doo: 'doo' }
|
300
296
|
}
|
301
297
|
end
|
302
298
|
end
|
303
299
|
|
304
|
-
savon(:gogogo)[:gogogo_response]
|
305
|
-
should == {:zoo
|
300
|
+
savon(:gogogo)[:gogogo_response]
|
301
|
+
.should == { zoo: 'zoo', boo: { :moo => 'moo', :doo => 'doo', :"@xsi:type" => 'tns:Boo' } }
|
306
302
|
end
|
307
303
|
|
308
|
-
it
|
304
|
+
it 'respond with arrays' do
|
309
305
|
mock_controller do
|
310
|
-
soap_action
|
311
|
-
|
312
|
-
|
306
|
+
soap_action 'rumba',
|
307
|
+
args: nil,
|
308
|
+
return: [:integer]
|
313
309
|
def rumba
|
314
|
-
render :
|
310
|
+
render soap: [1, 2, 3]
|
315
311
|
end
|
316
312
|
end
|
317
313
|
|
318
|
-
savon(:rumba)[:rumba_response].should == {:
|
314
|
+
savon(:rumba)[:rumba_response].should == { value: %w(1 2 3) }
|
319
315
|
end
|
320
316
|
|
321
|
-
it
|
317
|
+
it 'respond with complex structures inside arrays' do
|
322
318
|
mock_controller do
|
323
|
-
soap_action
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
319
|
+
soap_action 'rumba',
|
320
|
+
args: nil,
|
321
|
+
return: {
|
322
|
+
rumbas: [{ zombies: :string, puppies: :string }]
|
323
|
+
}
|
328
324
|
def rumba
|
329
|
-
render :
|
330
|
-
{:
|
331
|
-
|
332
|
-
|
333
|
-
]
|
325
|
+
render soap: { rumbas: [
|
326
|
+
{ zombies: 'suck1', puppies: 'rock1' },
|
327
|
+
{ zombies: 'suck2', puppies: 'rock2' }
|
328
|
+
]
|
334
329
|
}
|
335
330
|
end
|
336
331
|
end
|
337
332
|
|
338
333
|
savon(:rumba)[:rumba_response].should == {
|
339
|
-
:
|
340
|
-
{:zombies =>
|
341
|
-
{:zombies =>
|
334
|
+
rumbas: [
|
335
|
+
{ :zombies => 'suck1', :puppies => 'rock1', :"@xsi:type" => 'tns:Rumbas' },
|
336
|
+
{ :zombies => 'suck2', :puppies => 'rock2', :"@xsi:type" => 'tns:Rumbas' }
|
342
337
|
]
|
343
338
|
}
|
344
339
|
end
|
345
340
|
|
346
|
-
it
|
341
|
+
it 'respond with structs in structs in arrays' do
|
347
342
|
mock_controller do
|
348
|
-
soap_action
|
349
|
-
|
350
|
-
|
343
|
+
soap_action 'rumba',
|
344
|
+
args: nil,
|
345
|
+
return: [{ rumbas: { zombies: :integer } }]
|
351
346
|
|
352
347
|
def rumba
|
353
|
-
render :
|
348
|
+
render soap: [{ rumbas: { zombies: 100_000 } }, { rumbas: { zombies: 2 } }]
|
354
349
|
end
|
355
350
|
end
|
356
351
|
|
357
352
|
savon(:rumba)[:rumba_response].should == {
|
358
|
-
:
|
353
|
+
value: [
|
359
354
|
{
|
360
355
|
:rumbas => {
|
361
|
-
:zombies =>
|
362
|
-
:"@xsi:type" =>
|
356
|
+
:zombies => '100000',
|
357
|
+
:"@xsi:type" => 'tns:Rumbas'
|
363
358
|
},
|
364
|
-
:"@xsi:type" =>
|
359
|
+
:"@xsi:type" => 'tns:Value'
|
365
360
|
},
|
366
361
|
{
|
367
362
|
:rumbas => {
|
368
|
-
:zombies =>
|
369
|
-
:"@xsi:type" =>
|
363
|
+
:zombies => '2',
|
364
|
+
:"@xsi:type" => 'tns:Rumbas'
|
370
365
|
},
|
371
|
-
:"@xsi:type"=>
|
366
|
+
:"@xsi:type" => 'tns:Value'
|
372
367
|
}
|
373
368
|
]
|
374
369
|
}
|
375
370
|
end
|
376
371
|
|
377
|
-
context
|
378
|
-
it
|
372
|
+
context 'with arrays missing' do
|
373
|
+
it 'respond with simple definition' do
|
379
374
|
mock_controller do
|
380
|
-
soap_action
|
381
|
-
|
375
|
+
soap_action 'rocknroll',
|
376
|
+
args: nil, return: { my_value: [:integer] }
|
382
377
|
def rocknroll
|
383
|
-
render :
|
378
|
+
render soap: {}
|
384
379
|
end
|
385
380
|
end
|
386
381
|
|
387
382
|
savon(:rocknroll)[:rocknroll_response].should be_nil
|
388
383
|
end
|
389
384
|
|
390
|
-
it
|
385
|
+
it 'respond with complext definition' do
|
391
386
|
mock_controller do
|
392
|
-
soap_action
|
393
|
-
|
387
|
+
soap_action 'rocknroll',
|
388
|
+
args: nil, return: { my_value: [{ value: :integer }] }
|
394
389
|
def rocknroll
|
395
|
-
render :
|
390
|
+
render soap: {}
|
396
391
|
end
|
397
392
|
end
|
398
393
|
|
399
394
|
savon(:rocknroll)[:rocknroll_response].should be_nil
|
400
395
|
end
|
401
396
|
|
402
|
-
it
|
397
|
+
it 'respond with nested simple definition' do
|
403
398
|
mock_controller do
|
404
|
-
soap_action
|
405
|
-
|
399
|
+
soap_action 'rocknroll',
|
400
|
+
args: nil, return: { my_value: { my_array: [{ value: :integer }] } }
|
406
401
|
def rocknroll
|
407
|
-
render :
|
402
|
+
render soap: {}
|
408
403
|
end
|
409
404
|
end
|
410
405
|
|
411
|
-
savon(:rocknroll)[:rocknroll_response][:my_value]
|
412
|
-
should == { :"@xsi:type" =>
|
406
|
+
savon(:rocknroll)[:rocknroll_response][:my_value]
|
407
|
+
.should == { :"@xsi:type" => 'tns:MyValue' }
|
413
408
|
end
|
414
409
|
|
415
|
-
it
|
410
|
+
it 'handles incomplete array response' do
|
416
411
|
mock_controller do
|
417
|
-
soap_action
|
418
|
-
|
412
|
+
soap_action 'rocknroll',
|
413
|
+
args: nil, return: { my_value: [{ value: :string }] }
|
419
414
|
def rocknroll
|
420
|
-
render :
|
415
|
+
render soap: { my_value: [nil] }
|
421
416
|
end
|
422
417
|
end
|
423
418
|
|
424
|
-
expect{savon(:rocknroll)}.not_to raise_error
|
419
|
+
expect { savon(:rocknroll) }.not_to raise_error
|
425
420
|
end
|
426
421
|
end
|
427
422
|
end
|
428
423
|
|
429
|
-
context
|
430
|
-
it
|
424
|
+
context 'types' do
|
425
|
+
it 'recognize boolean' do
|
431
426
|
mock_controller do
|
432
|
-
soap_action
|
427
|
+
soap_action 'true', args: :boolean, return: :nil
|
433
428
|
def true
|
434
|
-
params[:value]
|
435
|
-
render :
|
429
|
+
raise 'not ok' unless params[:value] == true
|
430
|
+
render soap: nil
|
436
431
|
end
|
437
432
|
|
438
|
-
soap_action
|
433
|
+
soap_action 'false', args: :boolean, return: :nil
|
439
434
|
def false
|
440
|
-
params[:value]
|
441
|
-
render :
|
435
|
+
raise 'not ok' unless params[:value] == false
|
436
|
+
render soap: nil
|
442
437
|
end
|
443
438
|
end
|
444
439
|
|
445
|
-
savon(:true, :
|
446
|
-
savon(:true, :
|
447
|
-
savon(:false, :
|
448
|
-
savon(:false, :
|
440
|
+
savon(:true, value: 'true')
|
441
|
+
savon(:true, value: '1')
|
442
|
+
savon(:false, value: 'false')
|
443
|
+
savon(:false, value: '0')
|
449
444
|
end
|
450
445
|
|
451
|
-
it
|
446
|
+
it 'recognize dates' do
|
452
447
|
mock_controller do
|
453
|
-
soap_action
|
448
|
+
soap_action 'date', args: :date, return: :nil
|
454
449
|
def date
|
455
450
|
params[:value].should == Date.parse('2000-12-30') unless params[:value].blank?
|
456
|
-
render :
|
451
|
+
render soap: nil
|
457
452
|
end
|
458
453
|
end
|
459
454
|
|
460
|
-
savon(:date, :
|
461
|
-
|
455
|
+
savon(:date, value: '2000-12-30')
|
456
|
+
-> { savon(:date) }.should_not raise_exception
|
462
457
|
end
|
463
458
|
|
464
|
-
it
|
459
|
+
it 'recognize base64Binary' do
|
465
460
|
mock_controller do
|
466
|
-
soap_action
|
461
|
+
soap_action 'base64', args: :base64Binary, return: :nil
|
467
462
|
def base64
|
468
463
|
params[:value].should == 'test' unless params[:value].blank?
|
469
|
-
render :
|
464
|
+
render soap: nil
|
470
465
|
end
|
471
466
|
end
|
472
467
|
|
473
|
-
savon(:base64, :
|
474
|
-
|
468
|
+
savon(:base64, value: Base64.encode64('test'))
|
469
|
+
-> { savon(:base64) }.should_not raise_exception
|
475
470
|
end
|
476
471
|
end
|
477
472
|
|
478
|
-
context
|
479
|
-
it
|
473
|
+
context 'errors' do
|
474
|
+
it 'raise for incorrect requests' do
|
480
475
|
mock_controller do
|
481
|
-
soap_action
|
482
|
-
|
483
|
-
|
476
|
+
soap_action 'duty',
|
477
|
+
args: { bad: { a: :string, b: :string }, good: { a: :string, b: :string } },
|
478
|
+
return: nil
|
484
479
|
def duty
|
485
|
-
render :
|
480
|
+
render soap: nil
|
486
481
|
end
|
487
482
|
end
|
488
483
|
|
489
|
-
lambda
|
490
|
-
savon(:duty, :
|
491
|
-
|
484
|
+
lambda do
|
485
|
+
savon(:duty, bad: 42, good: nil)
|
486
|
+
end.should raise_exception(Savon::SOAPFault)
|
492
487
|
end
|
493
488
|
|
494
|
-
it
|
489
|
+
it 'raise for date in incorrect format' do
|
495
490
|
mock_controller do
|
496
|
-
soap_action
|
491
|
+
soap_action 'date', args: :date, return: :nil
|
497
492
|
def date
|
498
|
-
render :
|
493
|
+
render soap: nil
|
499
494
|
end
|
500
495
|
end
|
501
|
-
lambda
|
502
|
-
savon(:date, :
|
503
|
-
|
496
|
+
lambda do
|
497
|
+
savon(:date, value: 'incorrect format')
|
498
|
+
end.should raise_exception(Savon::SOAPFault)
|
504
499
|
end
|
505
500
|
|
506
|
-
it
|
501
|
+
it 'raise to report SOAP errors', fails: true do
|
507
502
|
mock_controller do
|
508
|
-
soap_action
|
503
|
+
soap_action 'error', args: { need_error: :boolean }, return: nil
|
509
504
|
def error
|
510
|
-
raise self.class.const_get(:SOAPError),
|
511
|
-
render :
|
505
|
+
raise self.class.const_get(:SOAPError), 'you wanted one' if params[:need_error]
|
506
|
+
render soap: nil
|
512
507
|
end
|
513
508
|
end
|
514
509
|
|
515
|
-
|
516
|
-
|
510
|
+
-> { savon(:error, need_error: false) }.should_not raise_exception
|
511
|
+
-> { savon(:error, need_error: true) }.should raise_exception(Savon::SOAPFault)
|
517
512
|
end
|
518
513
|
|
519
|
-
it
|
514
|
+
it 'raise for manual throws' do
|
520
515
|
mock_controller do
|
521
|
-
soap_action
|
516
|
+
soap_action 'error', args: nil, return: nil
|
522
517
|
def error
|
523
|
-
render_soap_error
|
518
|
+
render_soap_error 'a message'
|
524
519
|
end
|
525
520
|
end
|
526
521
|
|
527
|
-
|
522
|
+
-> { savon(:error) }.should raise_exception(Savon::SOAPFault)
|
528
523
|
end
|
529
524
|
|
530
|
-
it
|
525
|
+
it 'raise when response structure mismatches' do
|
531
526
|
mock_controller do
|
532
|
-
soap_action 'bad', :
|
533
|
-
:
|
534
|
-
:
|
535
|
-
:
|
536
|
-
:
|
537
|
-
:
|
527
|
+
soap_action 'bad', args: :integer, return: {
|
528
|
+
basic: :string,
|
529
|
+
stallions: {
|
530
|
+
stallion: [
|
531
|
+
name: :string,
|
532
|
+
wyldness: :integer
|
538
533
|
]
|
539
|
-
}
|
534
|
+
}
|
540
535
|
}
|
541
536
|
def bad
|
542
|
-
render :
|
543
|
-
:
|
544
|
-
:
|
537
|
+
render soap: {
|
538
|
+
basic: 'hi',
|
539
|
+
stallions: [{ name: 'ted', wyldness: 11 }]
|
545
540
|
}
|
546
541
|
end
|
547
542
|
|
548
|
-
soap_action 'bad2', :
|
549
|
-
:
|
550
|
-
:
|
543
|
+
soap_action 'bad2', args: :integer, return: {
|
544
|
+
basic: :string,
|
545
|
+
telephone_booths: [:string]
|
551
546
|
}
|
552
547
|
def bad2
|
553
|
-
render :
|
554
|
-
:
|
555
|
-
:
|
548
|
+
render soap: {
|
549
|
+
basic: 'hihi',
|
550
|
+
telephone_booths: 'oops'
|
556
551
|
}
|
557
552
|
end
|
558
553
|
end
|
559
554
|
|
560
|
-
|
555
|
+
-> { savon(:bad) }.should raise_exception(
|
561
556
|
WashOut::Dispatcher::ProgrammerError,
|
562
557
|
/SOAP response .*wyldness.*Array.*Hash.*stallion/
|
563
558
|
)
|
564
559
|
|
565
|
-
|
560
|
+
-> { savon(:bad2) }.should raise_exception(
|
566
561
|
WashOut::Dispatcher::ProgrammerError,
|
567
562
|
/SOAP response .*oops.*String.*telephone_booths.*Array/
|
568
563
|
)
|
569
564
|
end
|
570
|
-
|
571
|
-
context
|
572
|
-
let(:error_message) {
|
565
|
+
|
566
|
+
context 'custom exceptions' do
|
567
|
+
let(:error_message) { 'some message' }
|
573
568
|
let(:error_code) { 1001 }
|
574
|
-
let(:soap_exception) { WashOut::Dispatcher::SOAPError.new(error_message,error_code) }
|
575
|
-
|
569
|
+
let(:soap_exception) { WashOut::Dispatcher::SOAPError.new(error_message, error_code) }
|
570
|
+
|
576
571
|
before(:each) do
|
577
572
|
# Savon::Response.raise_errors = false
|
578
573
|
end
|
579
574
|
|
580
|
-
it
|
575
|
+
it 'raises a savon soapfault' do
|
581
576
|
mock_controller do
|
582
|
-
soap_action 'bad', :
|
577
|
+
soap_action 'bad', args: nil, return: nil
|
583
578
|
|
584
579
|
def bad
|
585
|
-
raise WashOut::Dispatcher::SOAPError.new(
|
580
|
+
raise WashOut::Dispatcher::SOAPError.new('some message', 1001)
|
586
581
|
end
|
587
582
|
end
|
588
583
|
|
589
|
-
|
584
|
+
-> { savon(:bad) }.should raise_exception{ |error|
|
590
585
|
error_hash = error.to_hash
|
591
586
|
error_hash[:fault][:faultcode].should eq(error_code.to_s)
|
592
587
|
error_hash[:fault][:faultstring].should eq(error_message)
|
593
588
|
expect(error).to be_a(Savon::SOAPFault)
|
594
589
|
}
|
595
|
-
|
596
590
|
end
|
597
|
-
|
598
591
|
end
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
592
|
end
|
604
593
|
|
605
|
-
context
|
606
|
-
it
|
594
|
+
context 'deprecates' do
|
595
|
+
it 'old syntax' do
|
607
596
|
# save rspec context check
|
608
597
|
raise_runtime_exception = raise_exception(RuntimeError)
|
609
598
|
|
610
599
|
mock_controller do
|
611
|
-
lambda
|
612
|
-
soap_action
|
613
|
-
|
614
|
-
|
615
|
-
|
600
|
+
lambda do
|
601
|
+
soap_action 'rumba',
|
602
|
+
args: :integer,
|
603
|
+
return: []
|
604
|
+
end.should raise_runtime_exception
|
616
605
|
def rumba
|
617
|
-
render :
|
606
|
+
render soap: nil
|
618
607
|
end
|
619
608
|
end
|
620
609
|
end
|
621
610
|
end
|
622
611
|
|
623
|
-
it
|
612
|
+
it 'allows arbitrary action names' do
|
624
613
|
name = 'AnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything'
|
625
614
|
|
626
615
|
mock_controller do
|
627
|
-
soap_action name, :
|
616
|
+
soap_action name, args: nil, return: :integer, to: :answer
|
628
617
|
def answer
|
629
|
-
render :
|
618
|
+
render soap: 'forty two'
|
630
619
|
end
|
631
620
|
end
|
632
621
|
|
633
|
-
savon(name.underscore.to_sym)["#{name.underscore}_response".to_sym][:value]
|
634
|
-
should ==
|
622
|
+
savon(name.underscore.to_sym)["#{name.underscore}_response".to_sym][:value]
|
623
|
+
.should == 'forty two'
|
635
624
|
end
|
636
625
|
|
637
|
-
it
|
626
|
+
it 'respects :response_tag option' do
|
638
627
|
mock_controller do
|
639
|
-
soap_action
|
628
|
+
soap_action 'specific', response_tag: 'test', return: :string
|
640
629
|
def specific
|
641
|
-
render :
|
630
|
+
render soap: 'test'
|
642
631
|
end
|
643
632
|
end
|
644
633
|
|
645
|
-
savon(:specific).should == {:
|
634
|
+
savon(:specific).should == { test: { value: 'test' } }
|
646
635
|
end
|
647
636
|
|
648
|
-
it
|
637
|
+
it 'handles snakecase option properly' do
|
649
638
|
mock_controller(snakecase_input: false, camelize_wsdl: false) do
|
650
|
-
soap_action
|
639
|
+
soap_action 'rocknroll', args: { ZOMG: :string }, return: nil
|
651
640
|
def rocknroll
|
652
|
-
params[
|
653
|
-
render :
|
641
|
+
raise 'not ok' unless params['ZOMG'] == 'yam!'
|
642
|
+
render soap: nil
|
654
643
|
end
|
655
644
|
end
|
656
645
|
|
657
|
-
savon(:rocknroll,
|
646
|
+
savon(:rocknroll, 'ZOMG' => 'yam!')
|
658
647
|
end
|
659
|
-
|
660
648
|
end
|
661
|
-
|
662
|
-
|
663
|
-
|
664
649
|
end
|