washout_builder 0.10.2 → 0.10.3

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTA4NWYxOTgyZjQ2MGYwNDY2MzY2ZTYyOGFjNjllNzliOTExZjdlOA==
4
+ NGMwZWQyMDJkY2E1OTU1MzBhOGVhY2YyMDE4NTc3ZWUyM2MwODA2NQ==
5
5
  data.tar.gz: !binary |-
6
- MjU3MjQ4MjkzN2E0NTVhZjJlYmVkYTczNDVkYTZmMTIxZmZlYzg5OA==
6
+ MjE4YjQyNjI5NjIwZWMzMjI5YmQyNGEwNGUwMWFlOTI0ZGJjM2I2ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWY4MTUzMzlhODA4NGJlNTU2YTIzNTg5NWIyZTZkNWFlZTI5MmZlYWZiNWM4
10
- ZDBlMDQ0NzNkM2Y0ZGRjOTBkNDUwMThmZTVlMTRlNTFiZmIwYzIwNTRlMDVj
11
- YjZhZWFkYWM3NWY3MWMyM2ZhNjAyNThhMTBmYmU3NWU3YzM0Yjg=
9
+ NDhlODA4MzAzYzU4YmE0NDE0YWYyNDA5NmYyNjkzNjE4NWViNGIzZGJlMmI1
10
+ ODQyN2ZjZDc0MTU4MGUxZTgzMmYxYWM5YTc0OGE5YjFlODRmYjgxMWIxMTAz
11
+ MWFlZWI0ZGM0ZjZjZTg2ZDE0ZmQ4MmRjOWU1OGFlN2ZlODQwNWI=
12
12
  data.tar.gz: !binary |-
13
- M2FjODc5YTA1OGFkNTllZDkwZjlhYWY4NDg2OTFhMzIxYTNmOTNjNGY1NzMz
14
- MmZmMWQ0MzEzZDExNzM0YTQyNjJjNjRjMGI1OTA3NjZlMGM1ZDNjZjM4ODk1
15
- NjI4ZWNmNmU4MzM3ZDg3YzMzMDZmOTE1ZTJjMGZhMGZlNzVlZjA=
13
+ N2RkMjg5MGYxODQxZWI2NDRlYTM3ZWY4NmI0M2ZkYmVlYjM3YjEzMDgzMjIy
14
+ YWQ3OGYzYTZiOGE0NDNmMzAyNzBhMjQ3ZjA4YzZmNWIwNzUwNTJkNzU1MWEw
15
+ ODU5OGQxYmQwMTNkY2FjYjJiNWM2YzZiMDkwYTgxMWYxYzY0M2Q=
@@ -30,7 +30,7 @@ end
30
30
  Virtus::InstanceMethods::Constructor.class_eval do
31
31
  alias_method :original_initialize,:initialize
32
32
  def initialize(attributes = nil)
33
- if self.class.ancestors.include?(WashOut::SOAPError) || self.is_a?(WashOut::SOAPError)
33
+ if self.class.ancestors.include?(WashOut::SOAPError) || self.is_a?(WashOut::SOAPError) || self.class.ancestors.include?(SOAPError) ||self.is_a?(SOAPError)
34
34
  attributes = {:message => attributes} unless attributes.is_a?(Hash)
35
35
  end
36
36
  original_initialize(attributes)
@@ -1,3 +1,3 @@
1
1
  module WashoutBuilder
2
- VERSION = "0.10.2"
2
+ VERSION = "0.10.3"
3
3
  end
@@ -5,9 +5,9 @@ require 'spec_helper'
5
5
  describe WashoutBuilder do
6
6
 
7
7
  before(:each) do
8
- WashOut::Rails::Engine.config.wash_out[:wsdl_style] = 'rpc'
9
- WashOut::Rails::Engine.config.wash_out[:parser] = :nokogiri
10
- WashOut::Rails::Engine.config.wash_out[:catch_xml_errors] = true
8
+ WashOut::Rails::Engine.config.wash_out[:wsdl_style] = 'rpc'
9
+ WashOut::Rails::Engine.config.wash_out[:parser] = :nokogiri
10
+ WashOut::Rails::Engine.config.wash_out[:catch_xml_errors] = true
11
11
  end
12
12
 
13
13
  let :nori do
@@ -22,16 +22,16 @@ describe WashoutBuilder do
22
22
  message = {:value => message} unless message.is_a?(Hash)
23
23
 
24
24
  savon_client = Savon::Client.new(:log => false, :wsdl => 'http://app/api/wsdl', &block)
25
- result = savon_client.call(method, :message => message)
26
- result.respond_to?(:to_hash) ? result.to_hash : result
25
+ result = savon_client.call(method, :message => message)
26
+ result.respond_to?(:to_hash) ? result.to_hash : result
27
27
  end
28
28
 
29
29
  def savon!(method, message={}, &block)
30
30
  message = {:value => message} unless message.is_a?(Hash)
31
31
 
32
32
  savon_client = Savon::Client.new(:log => true, :wsdl => 'http://app/api/wsdl', &block)
33
- result = savon_client.call(method, :message => message)
34
- result.respond_to?(:to_hash) ? result.to_hash : result
33
+ result = savon_client.call(method, :message => message)
34
+ result.respond_to?(:to_hash) ? result.to_hash : result
35
35
  end
36
36
 
37
37
  describe "Module" do
@@ -59,12 +59,12 @@ describe WashoutBuilder do
59
59
 
60
60
  soap_action "getArea", :args => {
61
61
  :circle => [{
62
- :center => { :x => [:integer], :y => :integer },
63
- :radius => :double
64
- }]},
62
+ :center => { :x => [:integer], :y => :integer },
63
+ :radius => :double
64
+ }]},
65
65
  :return => { :area => :double }
66
66
  soap_action "rocky", :args => { :circle1 => { :x => :integer } },
67
- :return => { :circle2 => { :y => :integer } }
67
+ :return => { :circle2 => { :y => :integer } }
68
68
  end
69
69
 
70
70
  HTTPI.get("http://app/api/wsdl").body
@@ -192,20 +192,20 @@ describe WashoutBuilder do
192
192
  it "accept nested structures" do
193
193
  mock_controller do
194
194
  soap_action "getArea", :args => { :circle => { :center => { :x => :integer,
195
- :y => :integer },
196
- :radius => :double } },
197
- :return => { :area => :double,
198
- :distance_from_o => :double },
199
- :to => :get_area
195
+ :y => :integer },
196
+ :radius => :double } },
197
+ :return => { :area => :double,
198
+ :distance_from_o => :double },
199
+ :to => :get_area
200
200
  def get_area
201
201
  circle = params[:circle]
202
202
  render :soap => { :area => Math::PI * circle[:radius] ** 2,
203
- :distance_from_o => Math.sqrt(circle[:center][:x] ** 2 + circle[:center][:y] ** 2) }
203
+ :distance_from_o => Math.sqrt(circle[:center][:x] ** 2 + circle[:center][:y] ** 2) }
204
204
  end
205
205
  end
206
206
 
207
207
  message = { :circle => { :center => { :x => 3, :y => 4 },
208
- :radius => 5 } }
208
+ :radius => 5 } }
209
209
 
210
210
  savon(:get_area, message)[:get_area_response].
211
211
  should == ({ :area => (Math::PI * 25).to_s, :distance_from_o => (5.0).to_s })
@@ -214,10 +214,10 @@ describe WashoutBuilder do
214
214
  it "accept arrays" do
215
215
  mock_controller do
216
216
  soap_action "rumba",
217
- :args => {
218
- :rumbas => [:integer]
219
- },
220
- :return => nil
217
+ :args => {
218
+ :rumbas => [:integer]
219
+ },
220
+ :return => nil
221
221
  def rumba
222
222
  params.should == {"rumbas" => [1, 2, 3]}
223
223
  render :soap => nil
@@ -230,10 +230,10 @@ describe WashoutBuilder do
230
230
  it "accept empty arrays" do
231
231
  mock_controller do
232
232
  soap_action "rumba",
233
- :args => {
234
- :my_array => [:integer]
235
- },
236
- :return => nil
233
+ :args => {
234
+ :my_array => [:integer]
235
+ },
236
+ :return => nil
237
237
  def rumba
238
238
  params.should == {}
239
239
  render :soap => nil
@@ -245,10 +245,10 @@ describe WashoutBuilder do
245
245
  it "accept nested empty arrays" do
246
246
  mock_controller do
247
247
  soap_action "rumba",
248
- :args => {
249
- :nested => {:my_array => [:integer] }
250
- },
251
- :return => nil
248
+ :args => {
249
+ :nested => {:my_array => [:integer] }
250
+ },
251
+ :return => nil
252
252
  def rumba
253
253
  params.should == {"nested" => {}}
254
254
  render :soap => nil
@@ -260,13 +260,13 @@ describe WashoutBuilder do
260
260
  it "accept nested structures inside arrays" do
261
261
  mock_controller do
262
262
  soap_action "rumba",
263
- :args => {
264
- :rumbas => [ {
265
- :zombies => :string,
266
- :puppies => :string
267
- } ]
268
- },
269
- :return => nil
263
+ :args => {
264
+ :rumbas => [ {
265
+ :zombies => :string,
266
+ :puppies => :string
267
+ } ]
268
+ },
269
+ :return => nil
270
270
  def rumba
271
271
  params.should == {
272
272
  "rumbas" => [
@@ -287,11 +287,11 @@ describe WashoutBuilder do
287
287
  it "respond with nested structures" do
288
288
  mock_controller do
289
289
  soap_action "gogogo",
290
- :args => nil,
291
- :return => {
292
- :zoo => :string,
293
- :boo => { :moo => :string, :doo => :string }
294
- }
290
+ :args => nil,
291
+ :return => {
292
+ :zoo => :string,
293
+ :boo => { :moo => :string, :doo => :string }
294
+ }
295
295
  def gogogo
296
296
  render :soap => {
297
297
  :zoo => 'zoo',
@@ -307,8 +307,8 @@ describe WashoutBuilder do
307
307
  it "respond with arrays" do
308
308
  mock_controller do
309
309
  soap_action "rumba",
310
- :args => nil,
311
- :return => [:integer]
310
+ :args => nil,
311
+ :return => [:integer]
312
312
  def rumba
313
313
  render :soap => [1, 2, 3]
314
314
  end
@@ -322,15 +322,15 @@ describe WashoutBuilder do
322
322
  soap_action "rumba",
323
323
  :args => nil,
324
324
  :return => {
325
- :rumbas => [{:zombies => :string, :puppies => :string}]
326
- }
325
+ :rumbas => [{:zombies => :string, :puppies => :string}]
326
+ }
327
327
  def rumba
328
328
  render :soap =>
329
329
  {:rumbas => [
330
- {:zombies => "suck1", :puppies => "rock1" },
331
- {:zombies => "suck2", :puppies => "rock2" }
332
- ]
333
- }
330
+ {:zombies => "suck1", :puppies => "rock1" },
331
+ {:zombies => "suck2", :puppies => "rock2" }
332
+ ]
333
+ }
334
334
  end
335
335
  end
336
336
 
@@ -377,7 +377,7 @@ describe WashoutBuilder do
377
377
  it "respond with simple definition" do
378
378
  mock_controller do
379
379
  soap_action "rocknroll",
380
- :args => nil, :return => { :my_value => [:integer] }
380
+ :args => nil, :return => { :my_value => [:integer] }
381
381
  def rocknroll
382
382
  render :soap => {}
383
383
  end
@@ -389,7 +389,7 @@ describe WashoutBuilder do
389
389
  it "respond with complext definition" do
390
390
  mock_controller do
391
391
  soap_action "rocknroll",
392
- :args => nil, :return => { :my_value => [{ :value => :integer }] }
392
+ :args => nil, :return => { :my_value => [{ :value => :integer }] }
393
393
  def rocknroll
394
394
  render :soap => {}
395
395
  end
@@ -401,7 +401,7 @@ describe WashoutBuilder do
401
401
  it "respond with nested simple definition" do
402
402
  mock_controller do
403
403
  soap_action "rocknroll",
404
- :args => nil, :return => { :my_value => { :my_array => [{ :value => :integer }] } }
404
+ :args => nil, :return => { :my_value => { :my_array => [{ :value => :integer }] } }
405
405
  def rocknroll
406
406
  render :soap => {}
407
407
  end
@@ -414,7 +414,7 @@ describe WashoutBuilder do
414
414
  it "handles incomplete array response" do
415
415
  mock_controller do
416
416
  soap_action "rocknroll",
417
- :args => nil, :return => { :my_value => [{ :value => :string }] }
417
+ :args => nil, :return => { :my_value => [{ :value => :string }] }
418
418
  def rocknroll
419
419
  render :soap => { :my_value => [nil] }
420
420
  end
@@ -566,6 +566,42 @@ describe WashoutBuilder do
566
566
  /SOAP response .*oops.*String.*telephone_booths.*Array/
567
567
  )
568
568
  end
569
+
570
+ context "custom exceptions" do
571
+ let(:error_message) { "some message" }
572
+ let(:error_code) { 1001 }
573
+ let(:soap_exception) { SOAPError.new(error_message,error_code) }
574
+
575
+ before(:each) do
576
+ # Savon::Response.raise_errors = false
577
+ end
578
+
579
+ it "raises a savon soapfault" do
580
+ mock_controller do
581
+ soap_action 'bad', :args => nil, :return => nil
582
+
583
+ def bad
584
+ raise SOAPError.new("some message", 1001)
585
+ end
586
+ end
587
+
588
+ lambda { savon(:bad) }.should raise_exception{ |error|
589
+ error_hash = error.to_hash
590
+ error_hash[:fault][:faultcode].should eq(error_code.to_s)
591
+ error_hash[:fault][:faultstring].should eq(error_message)
592
+ expect(error).to be_a(Savon::SOAPFault)
593
+ }
594
+
595
+ end
596
+
597
+ it "intanstiates correctly a custom exception" do
598
+ soap_exception.attributes.should eq({:code=>error_code, :message=>error_message, :backtrace=>nil})
599
+ end
600
+ end
601
+
602
+
603
+
604
+
569
605
  end
570
606
 
571
607
  context "deprecates" do
@@ -576,8 +612,8 @@ describe WashoutBuilder do
576
612
  mock_controller do
577
613
  lambda {
578
614
  soap_action "rumba",
579
- :args => :integer,
580
- :return => []
615
+ :args => :integer,
616
+ :return => []
581
617
  }.should raise_runtime_exception
582
618
  def rumba
583
619
  render :soap => nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: washout_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada