wash-out 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.travis.yml +35 -0
- data/Appraisals +25 -0
- data/CHANGELOG.md +102 -0
- data/Gemfile +16 -0
- data/Guardfile +12 -0
- data/LICENSE +22 -0
- data/README.md +246 -0
- data/Rakefile +13 -0
- data/app/helpers/wash_out_helper.rb +106 -0
- data/app/views/wash_out/document/error.builder +9 -0
- data/app/views/wash_out/document/response.builder +10 -0
- data/app/views/wash_out/document/wsdl.builder +68 -0
- data/app/views/wash_out/rpc/error.builder +10 -0
- data/app/views/wash_out/rpc/response.builder +11 -0
- data/app/views/wash_out/rpc/wsdl.builder +68 -0
- data/gemfiles/rails_3.1.3.gemfile +20 -0
- data/gemfiles/rails_3.2.12.gemfile +20 -0
- data/gemfiles/rails_4.0.0.gemfile +19 -0
- data/gemfiles/rails_4.1.0.gemfile +19 -0
- data/gemfiles/rails_4.2.0.gemfile +19 -0
- data/gemfiles/rails_5.0.0.beta2.gemfile +19 -0
- data/init.rb +1 -0
- data/lib/wash_out.rb +53 -0
- data/lib/wash_out/configurable.rb +41 -0
- data/lib/wash_out/dispatcher.rb +218 -0
- data/lib/wash_out/engine.rb +12 -0
- data/lib/wash_out/middleware.rb +41 -0
- data/lib/wash_out/model.rb +29 -0
- data/lib/wash_out/param.rb +200 -0
- data/lib/wash_out/router.rb +95 -0
- data/lib/wash_out/soap.rb +48 -0
- data/lib/wash_out/soap_config.rb +93 -0
- data/lib/wash_out/type.rb +29 -0
- data/lib/wash_out/version.rb +3 -0
- data/lib/wash_out/wsse.rb +101 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +51 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +23 -0
- data/spec/dummy/config/environments/test.rb +30 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +8 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/lib/wash_out/dispatcher_spec.rb +99 -0
- data/spec/lib/wash_out/middleware_spec.rb +33 -0
- data/spec/lib/wash_out/param_spec.rb +94 -0
- data/spec/lib/wash_out/router_spec.rb +22 -0
- data/spec/lib/wash_out/type_spec.rb +41 -0
- data/spec/lib/wash_out_spec.rb +754 -0
- data/spec/spec_helper.rb +82 -0
- data/wash_out.gemspec +21 -0
- metadata +128 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Print deprecation notices to the Rails logger
|
18
|
+
config.active_support.deprecation = :log
|
19
|
+
|
20
|
+
# Only use best-standards-support built into browsers
|
21
|
+
config.action_dispatch.best_standards_support = :builtin
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
config.eager_load = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Raise exceptions instead of rendering exception templates
|
17
|
+
config.action_dispatch.show_exceptions = false
|
18
|
+
|
19
|
+
# Disable request forgery protection in test environment
|
20
|
+
config.action_controller.allow_forgery_protection = false
|
21
|
+
|
22
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
23
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
24
|
+
# like if you have constraints or database-specific column types
|
25
|
+
# config.active_record.schema_format = :sql
|
26
|
+
|
27
|
+
# Print deprecation notices to the stderr
|
28
|
+
config.active_support.deprecation = :stderr
|
29
|
+
config.active_support.test_order = :random
|
30
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = 'b8d5d5687c012c2ef1a7a6e8006172402c48a3dcccca67c076eaad81c4712ad236ca2717c3706df7b286468c749d223f22acb0d96c27bdf33bbdbb9684ad46e5'
|
8
|
+
Dummy::Application.config.secret_key_base = 'ed27a919186a27649accc93ad8c2750a022ef255780e8a15a439658e9f8c520ed70ea071e596b2d23ed41163cf36c21ff5afcd31d19439bb1e4c420f2a57bce6'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
# The priority is based upon order of creation:
|
3
|
+
# first created -> highest priority.
|
4
|
+
|
5
|
+
# Sample of regular route:
|
6
|
+
# match 'products/:id' => 'catalog#view'
|
7
|
+
# Keep in mind you can assign values other than :controller and :action
|
8
|
+
|
9
|
+
# Sample of named route:
|
10
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
11
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
12
|
+
|
13
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
14
|
+
# resources :products
|
15
|
+
|
16
|
+
# Sample resource route with options:
|
17
|
+
# resources :products do
|
18
|
+
# member do
|
19
|
+
# get 'short'
|
20
|
+
# post 'toggle'
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# collection do
|
24
|
+
# get 'sold'
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Sample resource route with sub-resources:
|
29
|
+
# resources :products do
|
30
|
+
# resources :comments, :sales
|
31
|
+
# resource :seller
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Sample resource route with more complex sub-resources
|
35
|
+
# resources :products do
|
36
|
+
# resources :comments
|
37
|
+
# resources :sales do
|
38
|
+
# get 'recent', :on => :collection
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
|
42
|
+
# Sample resource route within a namespace:
|
43
|
+
# namespace :admin do
|
44
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
45
|
+
# # (app/controllers/admin/products_controller.rb)
|
46
|
+
# resources :products
|
47
|
+
# end
|
48
|
+
|
49
|
+
# You can have the root of your site routed with "root"
|
50
|
+
# just remember to delete public/index.html.
|
51
|
+
# root :to => "welcome#index"
|
52
|
+
|
53
|
+
# See how all your routes lay out with "rake routes"
|
54
|
+
|
55
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
56
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
57
|
+
# match ':controller(/:action(/:id(.:format)))'
|
58
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
File without changes
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#encoding:utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe WashOut::Dispatcher do
|
6
|
+
|
7
|
+
class Dispatcher < ApplicationController
|
8
|
+
soap_service
|
9
|
+
|
10
|
+
def params
|
11
|
+
@_params
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "finds nested hashes" do
|
16
|
+
expect(WashOut::Dispatcher.deep_select(:foo => 1){|k,v| k == :foo}).to eq [1]
|
17
|
+
expect(WashOut::Dispatcher.deep_select({:foo => {:foo => 1}}){|k,v| k == :foo}).to eq([{:foo => 1}, 1])
|
18
|
+
end
|
19
|
+
|
20
|
+
it "replaces nested hashed" do
|
21
|
+
expect(WashOut::Dispatcher.deep_replace_href({:foo => {:@href => 1}}, {1 => 2})).to eq({:foo => 2})
|
22
|
+
expect(WashOut::Dispatcher.deep_replace_href({:bar => {:foo => {:@href => 1}}}, {1 => 2})).to eq({:bar => {:foo => 2}})
|
23
|
+
end
|
24
|
+
|
25
|
+
xit "parses typical request" do
|
26
|
+
dispatcher = Dispatcher.mock("<foo>1</foo>")
|
27
|
+
dispatcher._parse_soap_parameters
|
28
|
+
expect(dispatcher.params).to eq({:foo => "1"})
|
29
|
+
end
|
30
|
+
|
31
|
+
xit "parses href request" do
|
32
|
+
dispatcher = Dispatcher.mock <<-XML
|
33
|
+
<root>
|
34
|
+
<request>
|
35
|
+
<entities href="#id1">
|
36
|
+
</entities>
|
37
|
+
</request>
|
38
|
+
<entity id="id1">
|
39
|
+
<foo><bar>1</bar></foo>
|
40
|
+
<sub href="#id2" />
|
41
|
+
</entity>
|
42
|
+
<ololo id="id2">
|
43
|
+
<foo>1</foo>
|
44
|
+
</ololo>
|
45
|
+
</root>
|
46
|
+
XML
|
47
|
+
dispatcher._parse_soap_parameters
|
48
|
+
expect(dispatcher.params[:root][:request][:entities]).to eq({
|
49
|
+
:foo => {:bar=>"1"},
|
50
|
+
:sub => {:foo=>"1", :@id=>"id2"},
|
51
|
+
:@id => "id1"
|
52
|
+
})
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#_map_soap_parameters" do
|
56
|
+
let(:dispatcher) { Dispatcher.new }
|
57
|
+
let(:soap_config) { WashOut::SoapConfig.new(camelize_wsdl: false) }
|
58
|
+
|
59
|
+
before do
|
60
|
+
allow(dispatcher).to receive(:action_spec).and_return(in: WashOut::Param.parse_def(soap_config, { foo: { "@bar" => :string, empty: :string } } ))
|
61
|
+
allow(dispatcher).to receive(:xml_data).and_return(foo: { "@bar" => "buzz", empty: { :"@xsi:type" => "xsd:string" } })
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should handle empty strings that have been parsed wrong by nori, but preserve attrs" do
|
65
|
+
dispatcher._map_soap_parameters
|
66
|
+
expect(dispatcher.params).to eq("foo" => { "bar" => "buzz", "empty" => nil })
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#_load_params" do
|
71
|
+
let(:dispatcher) { Dispatcher.new }
|
72
|
+
let(:soap_config) { WashOut::SoapConfig.new({ camelize_wsdl: false }) }
|
73
|
+
it "should load params for an array" do
|
74
|
+
spec = WashOut::Param.parse_def(soap_config, {:my_array => [:integer] } )
|
75
|
+
xml_data = {:my_array => [1, 2, 3]}
|
76
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({"my_array" => [1, 2, 3]})
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should load params for an empty array" do
|
80
|
+
spec = WashOut::Param.parse_def(soap_config, {:my_array => [:integer] } )
|
81
|
+
xml_data = {}
|
82
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({})
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should load params for a nested array" do
|
86
|
+
spec = WashOut::Param.parse_def(soap_config, {:nested => {:my_array => [:integer]}} )
|
87
|
+
xml_data = {:nested => {:my_array => [1, 2, 3]}}
|
88
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({"nested" => {"my_array" => [1, 2, 3]}})
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should load params for an empty nested array" do
|
92
|
+
spec = WashOut::Param.parse_def(soap_config, {:nested => {:empty => [:integer] }} )
|
93
|
+
xml_data = {:nested => nil}
|
94
|
+
expect(dispatcher._load_params(spec, xml_data)).to eq({"nested" => {}})
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'wash_out/middleware'
|
3
|
+
require 'rexml/document'
|
4
|
+
|
5
|
+
describe WashOut::Middleware do
|
6
|
+
it 'handles Rack environment variables' do
|
7
|
+
err = begin
|
8
|
+
REXML::Document.new '<hi>'
|
9
|
+
rescue REXML::ParseException => e
|
10
|
+
e
|
11
|
+
end
|
12
|
+
|
13
|
+
env = {}
|
14
|
+
expect {
|
15
|
+
WashOut::Middleware.raise_or_render_rexml_parse_error err, env
|
16
|
+
}.to raise_exception(REXML::ParseException)
|
17
|
+
|
18
|
+
env['HTTP_SOAPACTION'] = 'pretend_action'
|
19
|
+
env['rack.errors'] = double 'logger', {:puts => true}
|
20
|
+
env['rack.input'] = double 'basic-rack-input', {:string => '<hi>'}
|
21
|
+
result = WashOut::Middleware.raise_or_render_rexml_parse_error err, env
|
22
|
+
expect(result[0]).to eq 400
|
23
|
+
expect(result[1]['Content-Type']).to eq 'text/xml'
|
24
|
+
msg = result[2][0]
|
25
|
+
expect(msg).to include 'Error parsing SOAP Request XML'
|
26
|
+
expect(msg).to include 'soap:Fault'
|
27
|
+
expect(msg).not_to include __FILE__
|
28
|
+
|
29
|
+
env['rack.input'] = double 'passenger-input', {:read => '<hi>'}
|
30
|
+
result = WashOut::Middleware.raise_or_render_rexml_parse_error err, env
|
31
|
+
expect(result[0]).to eq 400
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#encoding:utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe WashOut::Param do
|
6
|
+
|
7
|
+
context "custom types" do
|
8
|
+
|
9
|
+
class Abraka1 < WashOut::Type
|
10
|
+
map(
|
11
|
+
:test => :string
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
class Abraka2 < WashOut::Type
|
16
|
+
type_name 'test'
|
17
|
+
map :foo => Abraka1
|
18
|
+
end
|
19
|
+
|
20
|
+
it "loads custom_types" do
|
21
|
+
soap_config = WashOut::SoapConfig.new({ camelize_wsdl: false })
|
22
|
+
map = WashOut::Param.parse_def soap_config, Abraka2
|
23
|
+
|
24
|
+
expect(map).to be_a_kind_of(Array)
|
25
|
+
expect(map[0].name).to eq 'foo'
|
26
|
+
expect(map[0].map[0].name).to eq 'test'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "respects camelization setting" do
|
30
|
+
soap_config = WashOut::SoapConfig.new({ camelize_wsdl: true })
|
31
|
+
|
32
|
+
map = WashOut::Param.parse_def soap_config, Abraka2
|
33
|
+
|
34
|
+
expect(map).to be_a_kind_of(Array)
|
35
|
+
expect(map[0].name).to eq 'Foo'
|
36
|
+
expect(map[0].map[0].name).to eq 'Test'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should accept nested empty arrays" do
|
41
|
+
soap_config = WashOut::SoapConfig.new({ camelize_wsdl: false })
|
42
|
+
map = WashOut::Param.parse_def(soap_config, {:nested => {:some_attr => :string, :empty => [:integer] }} )
|
43
|
+
expect(map[0].load( {:nested => nil}, :nested)).to eq({})
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "booleans" do
|
47
|
+
let(:soap_config) { WashOut::SoapConfig.new({ camelize_wsdl: false }) }
|
48
|
+
# following http://www.w3.org/TR/xmlschema-2/#boolean, only true, false, 0 and 1 are allowed.
|
49
|
+
# Nori maps the strings true and false to TrueClass and FalseClass, but not 0 and 1.
|
50
|
+
let(:map) { WashOut::Param.parse_def(soap_config, :value => :boolean) }
|
51
|
+
|
52
|
+
it "should accept 'true' and '1'" do
|
53
|
+
expect(map[0].load({:value => true}, :value)).to be true
|
54
|
+
expect(map[0].load({:value => "1"}, :value)).to be true
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should accept 'false' and '0'" do
|
58
|
+
expect(map[0].load({:value => false}, :value)).to be false
|
59
|
+
expect(map[0].load({:value => "0"}, :value)).to be false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'longs' do
|
64
|
+
let(:soap_config) { WashOut::SoapConfig.new({ camelize_wsdl: false }) }
|
65
|
+
let(:map) { WashOut::Param.parse_def(soap_config, :value => :long) }
|
66
|
+
|
67
|
+
it "should accept positive long" do
|
68
|
+
expect(map[0].load({:value => 9223372036854775807}, :value)).to eq 9223372036854775807
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should accept negative long" do
|
72
|
+
expect(map[0].load({:value => -9223372036854775807}, :value)).to eq -9223372036854775807
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#flat_copy' do
|
77
|
+
it 'should copy everything' do
|
78
|
+
soap_config = WashOut::SoapConfig.new({})
|
79
|
+
type = :foo
|
80
|
+
multiplied = "of course"
|
81
|
+
|
82
|
+
param = WashOut::Param.new(soap_config, 'name', type, multiplied)
|
83
|
+
param.source_class = "middle class"
|
84
|
+
evil_clone = param.flat_copy
|
85
|
+
|
86
|
+
expect(evil_clone.source_class).to eq "middle class"
|
87
|
+
expect(evil_clone.name).to eq 'name'
|
88
|
+
expect(evil_clone.raw_name).to eq 'name'
|
89
|
+
expect(evil_clone.type).to eq "foo"
|
90
|
+
expect(evil_clone.multiplied).to eq "of course"
|
91
|
+
expect(evil_clone.soap_config).to eq soap_config
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|