wash_out 0.6.1 → 0.7.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 +5 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +9 -4
- data/Gemfile.lock +2 -2
- data/README.md +6 -2
- data/app/helpers/wash_out_helper.rb +15 -4
- data/app/views/wash_with_soap/document/error.builder +9 -0
- data/app/views/wash_with_soap/document/response.builder +12 -0
- data/app/views/wash_with_soap/document/wsdl.builder +68 -0
- data/app/views/wash_with_soap/{error.builder → rpc/error.builder} +0 -0
- data/app/views/wash_with_soap/{response.builder → rpc/response.builder} +0 -0
- data/app/views/wash_with_soap/{wsdl.builder → rpc/wsdl.builder} +0 -0
- data/lib/wash_out/dispatcher.rb +13 -11
- data/lib/wash_out/engine.rb +7 -0
- data/lib/wash_out/param.rb +5 -3
- data/lib/wash_out/type.rb +2 -2
- data/lib/wash_out/version.rb +1 -1
- data/spec/lib/wash_out/dispatcher_spec.rb +29 -0
- data/spec/lib/wash_out/param_spec.rb +46 -24
- data/spec/lib/wash_out_spec.rb +34 -2
- data/spec/spec_helper.rb +7 -0
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19fe1a666c510fa52e22b9c31a93a38424d2aa32
|
4
|
+
data.tar.gz: 1c01364f646262f102e61b6aa810fcf94fdf4f6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13d6e1f2e7d3bc7a9dd6ce4733b54ae7a676fc92c301e88c6dd5744a7fe989f7c980e5b84702eee31adc119914fbbb1aa9feb0b178f85a43c67c93edd045d70e
|
7
|
+
data.tar.gz: 1ba235561f6101acddeb623aa5e0750911ed24310532802f74ecc9597e5d845ab32775348888b934c0088b8b333dc7ed4ecfe3dd8970988ed4cfc6b4d556066c
|
data/.gitignore
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
.rbx/
|
2
2
|
.bundle/
|
3
|
+
*.gem
|
3
4
|
.idea/
|
5
|
+
.rvmrc
|
6
|
+
*.swp
|
4
7
|
log/*.log
|
5
8
|
pkg/
|
6
9
|
spec/dummy/db/*.sqlite3
|
@@ -8,3 +11,5 @@ spec/dummy/log/*.log
|
|
8
11
|
spec/dummy/tmp/
|
9
12
|
gemfiles/rails-3.1.0.gemfile.lock b/gemfiles/rails-3.1.0.gemfile.lock
|
10
13
|
gemfiles/rails-3.1.0.gemfile.lock b/gemfiles/rails-3.0.10.gemfile.lock
|
14
|
+
coverage
|
15
|
+
tags
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.7.0
|
4
|
+
|
5
|
+
* WSDL Document mode support [@gorism][]
|
6
|
+
|
3
7
|
## 0.6.0
|
4
8
|
|
5
|
-
* Switched to Savon2 family
|
6
|
-
* Main spec refactored greatly
|
9
|
+
* Switched to Savon2 family [@inossidabile][]
|
10
|
+
* Main spec refactored greatly [@inossidabile][]
|
7
11
|
|
8
12
|
## 0.5.4
|
9
13
|
|
@@ -82,7 +86,8 @@
|
|
82
86
|
* SOAP response format improved. All results are now wrapped into tns:messages instead of soap:Body.
|
83
87
|
* Arrays (minOccurs/maxOccurs) are now supported with `:foo => [:integer]` syntax.
|
84
88
|
|
85
|
-
[@inossidabile]:
|
89
|
+
[@inossidabile]: http://staal.io
|
86
90
|
[@rngtng]: https://github.com/rngtng
|
87
91
|
[@dhinus]: https://github.com/dhinus
|
88
|
-
[@ebeigarts]: https://github.com/ebeigarts
|
92
|
+
[@ebeigarts]: https://github.com/ebeigarts
|
93
|
+
[@gorism]: https://github.com/gorism
|
data/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ GIT
|
|
8
8
|
PATH
|
9
9
|
remote: .
|
10
10
|
specs:
|
11
|
-
wash_out (0.
|
11
|
+
wash_out (0.7.0)
|
12
12
|
nori (~> 2.0.0)
|
13
13
|
|
14
14
|
GEM
|
@@ -86,7 +86,7 @@ GEM
|
|
86
86
|
rake (>= 0.8.7)
|
87
87
|
rdoc (~> 3.4)
|
88
88
|
thor (>= 0.14.6, < 2.0)
|
89
|
-
rake (10.0.
|
89
|
+
rake (10.0.4)
|
90
90
|
rb-fsevent (0.9.2)
|
91
91
|
rdoc (3.12)
|
92
92
|
json (~> 1.4)
|
data/README.md
CHANGED
@@ -9,10 +9,12 @@ But if you have a chance, please [http://stopsoap.com/](http://stopsoap.com/).
|
|
9
9
|
|
10
10
|
## Compatibility
|
11
11
|
|
12
|
-
Rails >3.0 only. MRI 1.9, 2.0, JRuby (--1.9)
|
12
|
+
Rails >3.0 only. MRI 1.9, 2.0, JRuby (--1.9).
|
13
13
|
|
14
14
|
Ruby 1.8 is not officially supported since 0.5.3. We will accept further compatibilty pull-requests but no upcoming versions will be tested against it.
|
15
15
|
|
16
|
+
Rubinius support temporarily dropped since 0.6.2 due to Rails 4 incompatibility.
|
17
|
+
|
16
18
|
## Installation
|
17
19
|
|
18
20
|
In your Gemfile, add this line:
|
@@ -140,6 +142,7 @@ Use `config.wash_out...` inside your environment configuration to setup WashOut.
|
|
140
142
|
|
141
143
|
Available properties are:
|
142
144
|
|
145
|
+
* **style**: sets WSDL style. Supported values are: 'document' and 'rpc'.
|
143
146
|
* **catch_xml_errors**: intercept Rails parsing exceptions to return correct XML response for corrupt XML input. Default is `false`.
|
144
147
|
* **namespace**: SOAP namespace to use. Default is `urn:WashOut`.
|
145
148
|
* **snakecase**: *(DEPRECATED SINCE 0.4.0)* Determines if WashOut should modify parameters keys to snakecase. Default is `false`.
|
@@ -157,7 +160,7 @@ soap_action "foo" # this will be passed as is
|
|
157
160
|
|
158
161
|
## Credits
|
159
162
|
|
160
|
-
* Boris Staal ([@
|
163
|
+
* Boris Staal ([@inossidabile](http://staal.io)) [](http://coderwall.com/inossidabile)
|
161
164
|
* Peter Zotov ([@whitequark](http://twitter.com/#!/whitequark)) [](http://coderwall.com/inossidabile)
|
162
165
|
|
163
166
|
## Contributors
|
@@ -167,6 +170,7 @@ soap_action "foo" # this will be passed as is
|
|
167
170
|
* Francesco Negri ([@dhinus](https://github.com/dhinus))
|
168
171
|
* Edgars Beigarts ([@ebeigarts](https://github.com/ebeigarts))
|
169
172
|
* [Exad](https://github.com/exad) ([@wknechtel](https://github.com/wknechtel) and [@☈king](https://github.com/rking))
|
173
|
+
* Mark Goris ([@gorism](https://github.com/gorism))
|
170
174
|
|
171
175
|
## LICENSE
|
172
176
|
|
@@ -1,25 +1,36 @@
|
|
1
1
|
module WashOutHelper
|
2
|
+
|
3
|
+
def wsdl_data_options(param)
|
4
|
+
case WashOut::Engine.style
|
5
|
+
when 'rpc'
|
6
|
+
{ :"xsi:type" => param.namespaced_type }
|
7
|
+
when 'document'
|
8
|
+
{ }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
2
12
|
def wsdl_data(xml, params)
|
3
13
|
params.each do |param|
|
4
14
|
tag_name = param.name
|
15
|
+
param_options = wsdl_data_options(param)
|
5
16
|
|
6
17
|
if !param.struct?
|
7
18
|
if !param.multiplied
|
8
|
-
xml.tag! tag_name, param.value,
|
19
|
+
xml.tag! tag_name, param.value, param_options
|
9
20
|
else
|
10
21
|
param.value = [] unless param.value.is_a?(Array)
|
11
22
|
param.value.each do |v|
|
12
|
-
xml.tag! tag_name, v,
|
23
|
+
xml.tag! tag_name, v, param_options
|
13
24
|
end
|
14
25
|
end
|
15
26
|
else
|
16
27
|
if !param.multiplied
|
17
|
-
xml.tag! tag_name,
|
28
|
+
xml.tag! tag_name, param_options do
|
18
29
|
wsdl_data(xml, param.map)
|
19
30
|
end
|
20
31
|
else
|
21
32
|
param.map.each do |p|
|
22
|
-
xml.tag! tag_name,
|
33
|
+
xml.tag! tag_name, param_options do
|
23
34
|
wsdl_data(xml, p.map)
|
24
35
|
end
|
25
36
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
xml.instruct!
|
2
|
+
xml.tag! "soap:Envelope", "xmlns:soap" => 'http://schemas.xmlsoap.org/soap/envelope/',
|
3
|
+
"xmlns:xsd" => 'http://www.w3.org/2001/XMLSchema',
|
4
|
+
"xmlns:tns" => @namespace do
|
5
|
+
xml.tag! "soap:Body" do
|
6
|
+
key = "tns:#{@operation}#{WashOut::Engine.camelize_wsdl ? 'Response' : '_response'}"
|
7
|
+
|
8
|
+
xml.tag! @action_spec[:response_tag] do
|
9
|
+
wsdl_data xml, result
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
xml.instruct!
|
2
|
+
xml.definitions 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/',
|
3
|
+
'xmlns:tns' => @namespace,
|
4
|
+
'xmlns:soap' => 'http://schemas.xmlsoap.org/wsdl/soap/',
|
5
|
+
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
|
6
|
+
'xmlns:soap-enc' => 'http://schemas.xmlsoap.org/soap/encoding/',
|
7
|
+
'xmlns:wsdl' => 'http://schemas.xmlsoap.org/wsdl/',
|
8
|
+
'name' => @name,
|
9
|
+
'targetNamespace' => @namespace do
|
10
|
+
|
11
|
+
xml.types do
|
12
|
+
xml.tag! "schema", :targetNamespace => @namespace, :xmlns => 'http://www.w3.org/2001/XMLSchema' do
|
13
|
+
defined = []
|
14
|
+
@map.each do |operation, formats|
|
15
|
+
(formats[:in] + formats[:out]).each do |p|
|
16
|
+
wsdl_type xml, p, defined
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
xml.portType :name => "#{@name}_port" do
|
23
|
+
@map.keys.each do |operation|
|
24
|
+
xml.operation :name => operation do
|
25
|
+
xml.input :message => "tns:#{operation}"
|
26
|
+
xml.output :message => "tns:#{operation}#{WashOut::Engine.camelize_wsdl ? 'Response' : '_response'}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
xml.binding :name => "#{@name}_binding", :type => "tns:#{@name}_port" do
|
32
|
+
xml.tag! "soap:binding", :style => 'document', :transport => 'http://schemas.xmlsoap.org/soap/http'
|
33
|
+
@map.keys.each do |operation|
|
34
|
+
xml.operation :name => operation do
|
35
|
+
xml.tag! "soap:operation", :soapAction => operation
|
36
|
+
xml.input do
|
37
|
+
xml.tag! "soap:body",
|
38
|
+
:use => "literal",
|
39
|
+
:namespace => @namespace
|
40
|
+
end
|
41
|
+
xml.output do
|
42
|
+
xml.tag! "soap:body",
|
43
|
+
:use => "literal",
|
44
|
+
:namespace => @namespace
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
xml.service :name => "service" do
|
51
|
+
xml.port :name => "#{@name}_port", :binding => "tns:#{@name}_binding" do
|
52
|
+
xml.tag! "soap:address", :location => url_for(:action => '_action', :only_path => false)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
@map.each do |operation, formats|
|
57
|
+
xml.message :name => "#{operation}" do
|
58
|
+
formats[:in].each do |p|
|
59
|
+
xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
xml.message :name => "#{operation}#{WashOut::Engine.camelize_wsdl ? 'Response' : '_response'}" do
|
63
|
+
formats[:out].each do |p|
|
64
|
+
xml.part wsdl_occurence(p, false, :name => p.name, :type => p.namespaced_type)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
data/lib/wash_out/dispatcher.rb
CHANGED
@@ -15,11 +15,8 @@ module WashOut
|
|
15
15
|
parser = Nori.new(
|
16
16
|
:strip_namespaces => true,
|
17
17
|
:advanced_typecasting => true,
|
18
|
-
:convert_tags_to => (
|
19
|
-
|
20
|
-
: lambda { |tag| tag.to_sym }
|
21
|
-
)
|
22
|
-
)
|
18
|
+
:convert_tags_to => ( WashOut::Engine.snakecase_input ? lambda { |tag| tag.snakecase.to_sym } \
|
19
|
+
: lambda { |tag| tag.to_sym } ))
|
23
20
|
|
24
21
|
@_params = parser.parse(request.body.read)
|
25
22
|
references = WashOut::Dispatcher.deep_select(@_params){|k,v| v.is_a?(Hash) && v.has_key?(:@id)}
|
@@ -70,14 +67,19 @@ module WashOut
|
|
70
67
|
hash
|
71
68
|
}
|
72
69
|
xml_data = strip_empty_nodes.call(xml_data)
|
73
|
-
@_params =
|
70
|
+
@_params = _load_params(action_spec[:in], xml_data)
|
71
|
+
end
|
74
72
|
|
75
|
-
|
73
|
+
# Creates the final parameter hash based on the request spec and xml_data from the request
|
74
|
+
def _load_params(spec, xml_data)
|
75
|
+
params = HashWithIndifferentAccess.new
|
76
|
+
spec.each do |param|
|
76
77
|
key = param.raw_name.to_sym
|
77
78
|
if xml_data.has_key? key
|
78
|
-
|
79
|
+
params[param.raw_name] = param.load(xml_data, key)
|
79
80
|
end
|
80
81
|
end
|
82
|
+
params
|
81
83
|
end
|
82
84
|
|
83
85
|
# This action generates the WSDL for defined SOAP methods.
|
@@ -86,7 +88,7 @@ module WashOut
|
|
86
88
|
@namespace = WashOut::Engine.namespace
|
87
89
|
@name = controller_path.gsub('/', '_')
|
88
90
|
|
89
|
-
render :template =>
|
91
|
+
render :template => "wash_with_soap/#{WashOut::Engine.style}/wsdl", :layout => false
|
90
92
|
end
|
91
93
|
|
92
94
|
# Render a SOAP response.
|
@@ -136,7 +138,7 @@ module WashOut
|
|
136
138
|
return result_spec
|
137
139
|
}
|
138
140
|
|
139
|
-
render :template =>
|
141
|
+
render :template => "wash_with_soap/#{WashOut::Engine.style}/response",
|
140
142
|
:layout => false,
|
141
143
|
:locals => { :result => inject.call(result, @action_spec[:out]) },
|
142
144
|
:content_type => 'text/xml'
|
@@ -156,7 +158,7 @@ module WashOut
|
|
156
158
|
# Rails do not support sequental rescue_from handling, that is, rescuing an
|
157
159
|
# exception from a rescue_from handler. Hence this function is a public API.
|
158
160
|
def render_soap_error(message)
|
159
|
-
render :template =>
|
161
|
+
render :template => "wash_with_soap/#{WashOut::Engine.style}/error", :status => 500,
|
160
162
|
:layout => false,
|
161
163
|
:locals => { :error_message => message },
|
162
164
|
:content_type => 'text/xml'
|
data/lib/wash_out/engine.rb
CHANGED
@@ -2,6 +2,7 @@ module WashOut
|
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
class << self
|
4
4
|
attr_accessor :namespace
|
5
|
+
attr_accessor :style
|
5
6
|
attr_accessor :snakecase, :camelize_output
|
6
7
|
attr_accessor :snakecase_input, :camelize_wsdl
|
7
8
|
attr_accessor :wsse_username, :wsse_password
|
@@ -9,6 +10,7 @@ module WashOut
|
|
9
10
|
end
|
10
11
|
|
11
12
|
self.namespace = 'urn:WashOut'
|
13
|
+
self.style = 'rpc'
|
12
14
|
self.snakecase = nil
|
13
15
|
|
14
16
|
self.snakecase_input = false
|
@@ -34,9 +36,14 @@ module WashOut
|
|
34
36
|
raise "Usage of wash_out.camelize_output is deprecated. You should use wash_out.camelize_wsdl option instead"
|
35
37
|
end
|
36
38
|
|
39
|
+
unless ['rpc','document'].include? self.class.style
|
40
|
+
raise "Invalid binding. Style must be one of #{['rpc','document'].join(',')}"
|
41
|
+
end
|
42
|
+
|
37
43
|
if self.class.catch_xml_errors
|
38
44
|
app.config.middleware.insert_after 'ActionDispatch::ShowExceptions', WashOut::Middleware
|
39
45
|
end
|
40
46
|
end
|
47
|
+
|
41
48
|
end
|
42
49
|
end
|
data/lib/wash_out/param.rb
CHANGED
@@ -47,6 +47,7 @@ module WashOut
|
|
47
47
|
data = [data] if @multiplied && !data.is_a?(Array)
|
48
48
|
|
49
49
|
if struct?
|
50
|
+
data ||= {}
|
50
51
|
if @multiplied
|
51
52
|
data.map do |x|
|
52
53
|
map_struct x do |param, data, elem|
|
@@ -63,7 +64,7 @@ module WashOut
|
|
63
64
|
when 'string'; :to_s
|
64
65
|
when 'integer'; :to_i
|
65
66
|
when 'double'; :to_f
|
66
|
-
when 'boolean';
|
67
|
+
when 'boolean'; lambda{|data| data === "0" ? false : !!data}
|
67
68
|
when 'date'; :to_date
|
68
69
|
when 'datetime'; :to_datetime
|
69
70
|
when 'time'; :to_time
|
@@ -71,10 +72,11 @@ module WashOut
|
|
71
72
|
end
|
72
73
|
|
73
74
|
begin
|
74
|
-
if
|
75
|
+
if data.nil?
|
75
76
|
data
|
76
77
|
elsif @multiplied
|
77
|
-
data.map{|x| x.send(operation)}
|
78
|
+
return data.map{|x| x.send(operation)} if operation.is_a?(Symbol)
|
79
|
+
return data.map{|x| operation.call(x)} if operation.is_a?(Proc)
|
78
80
|
elsif operation.is_a? Symbol
|
79
81
|
data.send(operation)
|
80
82
|
else
|
data/lib/wash_out/type.rb
CHANGED
data/lib/wash_out/version.rb
CHANGED
@@ -58,4 +58,33 @@ describe WashOut::Dispatcher do
|
|
58
58
|
}
|
59
59
|
end
|
60
60
|
|
61
|
+
describe "#_load_params" do
|
62
|
+
let(:dispatcher) { Dispatcher.new }
|
63
|
+
|
64
|
+
it "should load params for an array" do
|
65
|
+
spec = WashOut::Param.parse_def( {:my_array => [:integer] } )
|
66
|
+
xml_data = {:my_array => [1, 2, 3]}
|
67
|
+
dispatcher._load_params(spec, xml_data).should == {"my_array" => [1, 2, 3]}
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should load params for an empty array" do
|
71
|
+
spec = WashOut::Param.parse_def( {:my_array => [:integer] } )
|
72
|
+
xml_data = {}
|
73
|
+
dispatcher._load_params(spec, xml_data).should == {}
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should load params for a nested array" do
|
77
|
+
spec = WashOut::Param.parse_def( {:nested => {:my_array => [:integer]}} )
|
78
|
+
xml_data = {:nested => {:my_array => [1, 2, 3]}}
|
79
|
+
dispatcher._load_params(spec, xml_data).should == {"nested" => {"my_array" => [1, 2, 3]}}
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should load params for an empty nested array" do
|
83
|
+
spec = WashOut::Param.parse_def( {:nested => {:empty => [:integer] }} )
|
84
|
+
xml_data = {:nested => nil}
|
85
|
+
dispatcher._load_params(spec, xml_data).should == {"nested" => {}}
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
61
90
|
end
|
@@ -4,34 +4,56 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe WashOut::Param do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
context "custom types" do
|
8
|
+
class Abraka1 < WashOut::Type
|
9
|
+
map(
|
10
|
+
:test => :string
|
11
|
+
)
|
12
|
+
end
|
13
|
+
class Abraka2 < WashOut::Type
|
14
|
+
type_name 'test'
|
15
|
+
map :foo => Abraka1
|
16
|
+
end
|
17
|
+
|
18
|
+
it "loads custom_types" do
|
19
|
+
map = WashOut::Param.parse_def Abraka2
|
20
|
+
|
21
|
+
map.should be_a_kind_of(Array)
|
22
|
+
map[0].name.should == 'value'
|
23
|
+
map[0].map[0].name.should == 'foo'
|
24
|
+
map[0].map[0].map[0].name.should == 'test'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "respects camelization setting" do
|
28
|
+
WashOut::Engine.camelize_wsdl = true
|
29
|
+
|
30
|
+
map = WashOut::Param.parse_def Abraka2
|
31
|
+
|
32
|
+
map.should be_a_kind_of(Array)
|
33
|
+
map[0].name.should == 'Value'
|
34
|
+
map[0].map[0].name.should == 'Foo'
|
35
|
+
map[0].map[0].map[0].name.should == 'Test'
|
36
|
+
end
|
11
37
|
end
|
12
|
-
class Abraka2 < WashOut::Type
|
13
|
-
type_name 'test'
|
14
|
-
map :foo => Abraka1
|
15
|
-
end
|
16
|
-
|
17
|
-
it "loads custom_types" do
|
18
|
-
map = WashOut::Param.parse_def Abraka2
|
19
38
|
|
20
|
-
|
21
|
-
map[
|
22
|
-
map[0].
|
23
|
-
map[0].map[0].map[0].name.should == 'test'
|
39
|
+
it "should accept nested empty arrays" do
|
40
|
+
map = WashOut::Param.parse_def( {:nested => {:some_attr => :string, :empty => [:integer] }} )
|
41
|
+
map[0].load( {:nested => nil}, :nested).should == {}
|
24
42
|
end
|
25
43
|
|
26
|
-
|
27
|
-
|
44
|
+
describe "booleans" do
|
45
|
+
# following http://www.w3.org/TR/xmlschema-2/#boolean, only true, false, 0 and 1 are allowed.
|
46
|
+
# Nori maps the strings true and false to TrueClass and FalseClass, but not 0 and 1.
|
47
|
+
let(:map) { WashOut::Param.parse_def(:value => :boolean) }
|
28
48
|
|
29
|
-
|
49
|
+
it "should accept 'true' and '1'" do
|
50
|
+
map[0].load({:value => true}, :value).should be_true
|
51
|
+
map[0].load({:value => "1"}, :value).should be_true
|
52
|
+
end
|
30
53
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
54
|
+
it "should accept 'false' and '0'" do
|
55
|
+
map[0].load({:value => false}, :value).should be_false
|
56
|
+
map[0].load({:value => "0"}, :value).should be_false
|
57
|
+
end
|
35
58
|
end
|
36
|
-
|
37
|
-
end
|
59
|
+
end
|
data/spec/lib/wash_out_spec.rb
CHANGED
@@ -185,6 +185,36 @@ describe WashOut do
|
|
185
185
|
savon(:rumba, :rumbas => [1, 2, 3])
|
186
186
|
end
|
187
187
|
|
188
|
+
it "accept empty arrays" do
|
189
|
+
mock_controller do
|
190
|
+
soap_action "rumba",
|
191
|
+
:args => {
|
192
|
+
:my_array => [:integer]
|
193
|
+
},
|
194
|
+
:return => nil
|
195
|
+
def rumba
|
196
|
+
params.should == {}
|
197
|
+
render :soap => nil
|
198
|
+
end
|
199
|
+
end
|
200
|
+
savon(:rumba, :empty => [])
|
201
|
+
end
|
202
|
+
|
203
|
+
it "accept nested empty arrays" do
|
204
|
+
mock_controller do
|
205
|
+
soap_action "rumba",
|
206
|
+
:args => {
|
207
|
+
:nested => {:my_array => [:integer] }
|
208
|
+
},
|
209
|
+
:return => nil
|
210
|
+
def rumba
|
211
|
+
params.should == {"nested" => {}}
|
212
|
+
render :soap => nil
|
213
|
+
end
|
214
|
+
end
|
215
|
+
savon(:rumba, :nested => {:my_array => []})
|
216
|
+
end
|
217
|
+
|
188
218
|
it "accept nested structures inside arrays" do
|
189
219
|
mock_controller do
|
190
220
|
soap_action "rumba",
|
@@ -357,8 +387,10 @@ describe WashOut do
|
|
357
387
|
end
|
358
388
|
end
|
359
389
|
|
360
|
-
savon(:true, :value => true)
|
361
|
-
savon(:
|
390
|
+
savon(:true, :value => "true")
|
391
|
+
savon(:true, :value => "1")
|
392
|
+
savon(:false, :value => "false")
|
393
|
+
savon(:false, :value => "0")
|
362
394
|
end
|
363
395
|
|
364
396
|
it "recognize dates" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Configure Rails Envinronment
|
2
2
|
ENV["RAILS_ENV"] = "test"
|
3
3
|
|
4
|
+
require "simplecov"
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter 'spec'
|
7
|
+
add_group 'Library', 'lib'
|
8
|
+
add_group 'App', 'app'
|
9
|
+
end
|
10
|
+
|
4
11
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
12
|
require "rails/test_help"
|
6
13
|
require "rspec/rails"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wash_out
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Staal
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nori
|
@@ -43,9 +43,12 @@ files:
|
|
43
43
|
- README.md
|
44
44
|
- Rakefile
|
45
45
|
- app/helpers/wash_out_helper.rb
|
46
|
-
- app/views/wash_with_soap/error.builder
|
47
|
-
- app/views/wash_with_soap/response.builder
|
48
|
-
- app/views/wash_with_soap/wsdl.builder
|
46
|
+
- app/views/wash_with_soap/document/error.builder
|
47
|
+
- app/views/wash_with_soap/document/response.builder
|
48
|
+
- app/views/wash_with_soap/document/wsdl.builder
|
49
|
+
- app/views/wash_with_soap/rpc/error.builder
|
50
|
+
- app/views/wash_with_soap/rpc/response.builder
|
51
|
+
- app/views/wash_with_soap/rpc/wsdl.builder
|
49
52
|
- gemfiles/rails_3.1.3.gemfile
|
50
53
|
- gemfiles/rails_3.1.3.gemfile.lock
|
51
54
|
- gemfiles/rails_3.2.12.gemfile
|