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