wash_out 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Appraisals +4 -4
- data/README.md +9 -2
- data/gemfiles/{rails-3.0.10.gemfile → rails-3.0.11.gemfile} +1 -1
- data/gemfiles/{rails-3.0.10.gemfile.lock → rails-3.0.11.gemfile.lock} +29 -28
- data/gemfiles/{rails-3.1.0.gemfile → rails-3.1.3.gemfile} +1 -1
- data/gemfiles/{rails-3.1.0.gemfile.lock → rails-3.1.3.gemfile.lock} +35 -36
- data/lib/wash_out.rb +4 -3
- data/lib/wash_out/dispatcher.rb +26 -21
- data/lib/wash_out/param.rb +1 -1
- data/lib/wash_out/router.rb +28 -0
- data/lib/wash_out/version.rb +1 -1
- data/spec/spec_helper.rb +14 -1
- data/spec/support/httpi-rack.rb +18 -6
- data/spec/wash_out_spec.rb +20 -16
- metadata +17 -17
- data/spec/support/mock_controller.rb +0 -34
data/Appraisals
CHANGED
data/README.md
CHANGED
@@ -15,8 +15,8 @@ Usage
|
|
15
15
|
|
16
16
|
A SOAP endpoint in WashOut is simply a Rails controller which includes the module WashOut::SOAP. Each SOAP
|
17
17
|
action corresponds to a certain controller method; this mapping, as well as the argument definition, is defined
|
18
|
-
by [soap_action][] method. Check the method documentation for complete info; here,
|
19
|
-
|
18
|
+
by [soap_action][] method. Check the method documentation for complete info; here, only a few examples will be
|
19
|
+
demonstrated.
|
20
20
|
|
21
21
|
[soap_action]: http://rubydoc.info/gems/wash_out/0.2.1/WashOut/SOAP/ClassMethods#soap_action-instance_method
|
22
22
|
|
@@ -54,6 +54,13 @@ class ApiController < ApplicationController
|
|
54
54
|
|
55
55
|
render :soap => nil
|
56
56
|
end
|
57
|
+
|
58
|
+
# You can use all Rails features like filtering, too. A SOAP controller
|
59
|
+
# is just like a normal controller with a special routing.
|
60
|
+
before_filter :dump_parameters
|
61
|
+
def dump_parameters
|
62
|
+
Rails.logger.log(params.inspect)
|
63
|
+
end
|
57
64
|
end
|
58
65
|
```
|
59
66
|
|
@@ -1,18 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /home/whitequark/wash_out
|
3
3
|
specs:
|
4
|
-
wash_out (0.1)
|
4
|
+
wash_out (0.2.1)
|
5
|
+
nori
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: http://rubygems.org/
|
8
9
|
specs:
|
9
10
|
abstract (1.0.0)
|
10
|
-
actionmailer (3.0.
|
11
|
-
actionpack (= 3.0.
|
11
|
+
actionmailer (3.0.11)
|
12
|
+
actionpack (= 3.0.11)
|
12
13
|
mail (~> 2.2.19)
|
13
|
-
actionpack (3.0.
|
14
|
-
activemodel (= 3.0.
|
15
|
-
activesupport (= 3.0.
|
14
|
+
actionpack (3.0.11)
|
15
|
+
activemodel (= 3.0.11)
|
16
|
+
activesupport (= 3.0.11)
|
16
17
|
builder (~> 2.1.2)
|
17
18
|
erubis (~> 2.6.6)
|
18
19
|
i18n (~> 0.5.0)
|
@@ -20,19 +21,19 @@ GEM
|
|
20
21
|
rack-mount (~> 0.6.14)
|
21
22
|
rack-test (~> 0.5.7)
|
22
23
|
tzinfo (~> 0.3.23)
|
23
|
-
activemodel (3.0.
|
24
|
-
activesupport (= 3.0.
|
24
|
+
activemodel (3.0.11)
|
25
|
+
activesupport (= 3.0.11)
|
25
26
|
builder (~> 2.1.2)
|
26
27
|
i18n (~> 0.5.0)
|
27
|
-
activerecord (3.0.
|
28
|
-
activemodel (= 3.0.
|
29
|
-
activesupport (= 3.0.
|
28
|
+
activerecord (3.0.11)
|
29
|
+
activemodel (= 3.0.11)
|
30
|
+
activesupport (= 3.0.11)
|
30
31
|
arel (~> 2.0.10)
|
31
32
|
tzinfo (~> 0.3.23)
|
32
|
-
activeresource (3.0.
|
33
|
-
activemodel (= 3.0.
|
34
|
-
activesupport (= 3.0.
|
35
|
-
activesupport (3.0.
|
33
|
+
activeresource (3.0.11)
|
34
|
+
activemodel (= 3.0.11)
|
35
|
+
activesupport (= 3.0.11)
|
36
|
+
activesupport (3.0.11)
|
36
37
|
akami (1.0.0)
|
37
38
|
gyoku (>= 0.4.0)
|
38
39
|
appraisal (0.4.0)
|
@@ -48,7 +49,7 @@ GEM
|
|
48
49
|
httpi (0.9.5)
|
49
50
|
rack
|
50
51
|
i18n (0.5.0)
|
51
|
-
json (1.6.
|
52
|
+
json (1.6.3)
|
52
53
|
mail (2.2.19)
|
53
54
|
activesupport (>= 2.3.6)
|
54
55
|
i18n (>= 0.4.0)
|
@@ -63,22 +64,22 @@ GEM
|
|
63
64
|
rack (>= 1.0.0)
|
64
65
|
rack-test (0.5.7)
|
65
66
|
rack (>= 1.0)
|
66
|
-
rails (3.0.
|
67
|
-
actionmailer (= 3.0.
|
68
|
-
actionpack (= 3.0.
|
69
|
-
activerecord (= 3.0.
|
70
|
-
activeresource (= 3.0.
|
71
|
-
activesupport (= 3.0.
|
67
|
+
rails (3.0.11)
|
68
|
+
actionmailer (= 3.0.11)
|
69
|
+
actionpack (= 3.0.11)
|
70
|
+
activerecord (= 3.0.11)
|
71
|
+
activeresource (= 3.0.11)
|
72
|
+
activesupport (= 3.0.11)
|
72
73
|
bundler (~> 1.0)
|
73
|
-
railties (= 3.0.
|
74
|
-
railties (3.0.
|
75
|
-
actionpack (= 3.0.
|
76
|
-
activesupport (= 3.0.
|
74
|
+
railties (= 3.0.11)
|
75
|
+
railties (3.0.11)
|
76
|
+
actionpack (= 3.0.11)
|
77
|
+
activesupport (= 3.0.11)
|
77
78
|
rake (>= 0.8.7)
|
78
79
|
rdoc (~> 3.4)
|
79
80
|
thor (~> 0.14.4)
|
80
81
|
rake (0.9.2.2)
|
81
|
-
rdoc (3.
|
82
|
+
rdoc (3.12)
|
82
83
|
json (~> 1.4)
|
83
84
|
rspec (2.7.0)
|
84
85
|
rspec-core (~> 2.7.0)
|
@@ -114,7 +115,7 @@ PLATFORMS
|
|
114
115
|
|
115
116
|
DEPENDENCIES
|
116
117
|
appraisal
|
117
|
-
rails (= 3.0.
|
118
|
+
rails (= 3.0.11)
|
118
119
|
rspec-rails
|
119
120
|
savon
|
120
121
|
tzinfo
|
@@ -1,39 +1,39 @@
|
|
1
1
|
PATH
|
2
|
-
remote: /
|
2
|
+
remote: /home/whitequark/wash_out
|
3
3
|
specs:
|
4
|
-
wash_out (0.1)
|
4
|
+
wash_out (0.2.1)
|
5
|
+
nori
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: http://rubygems.org/
|
8
9
|
specs:
|
9
|
-
actionmailer (3.1.
|
10
|
-
actionpack (= 3.1.
|
10
|
+
actionmailer (3.1.3)
|
11
|
+
actionpack (= 3.1.3)
|
11
12
|
mail (~> 2.3.0)
|
12
|
-
actionpack (3.1.
|
13
|
-
activemodel (= 3.1.
|
14
|
-
activesupport (= 3.1.
|
13
|
+
actionpack (3.1.3)
|
14
|
+
activemodel (= 3.1.3)
|
15
|
+
activesupport (= 3.1.3)
|
15
16
|
builder (~> 3.0.0)
|
16
17
|
erubis (~> 2.7.0)
|
17
18
|
i18n (~> 0.6)
|
18
|
-
rack (~> 1.3.
|
19
|
-
rack-cache (~> 1.
|
19
|
+
rack (~> 1.3.5)
|
20
|
+
rack-cache (~> 1.1)
|
20
21
|
rack-mount (~> 0.8.2)
|
21
22
|
rack-test (~> 0.6.1)
|
22
|
-
sprockets (~> 2.0.
|
23
|
-
activemodel (3.1.
|
24
|
-
activesupport (= 3.1.
|
25
|
-
bcrypt-ruby (~> 3.0.0)
|
23
|
+
sprockets (~> 2.0.3)
|
24
|
+
activemodel (3.1.3)
|
25
|
+
activesupport (= 3.1.3)
|
26
26
|
builder (~> 3.0.0)
|
27
27
|
i18n (~> 0.6)
|
28
|
-
activerecord (3.1.
|
29
|
-
activemodel (= 3.1.
|
30
|
-
activesupport (= 3.1.
|
28
|
+
activerecord (3.1.3)
|
29
|
+
activemodel (= 3.1.3)
|
30
|
+
activesupport (= 3.1.3)
|
31
31
|
arel (~> 2.2.1)
|
32
32
|
tzinfo (~> 0.3.29)
|
33
|
-
activeresource (3.1.
|
34
|
-
activemodel (= 3.1.
|
35
|
-
activesupport (= 3.1.
|
36
|
-
activesupport (3.1.
|
33
|
+
activeresource (3.1.3)
|
34
|
+
activemodel (= 3.1.3)
|
35
|
+
activesupport (= 3.1.3)
|
36
|
+
activesupport (3.1.3)
|
37
37
|
multi_json (~> 1.0)
|
38
38
|
akami (1.0.0)
|
39
39
|
gyoku (>= 0.4.0)
|
@@ -41,7 +41,6 @@ GEM
|
|
41
41
|
bundler
|
42
42
|
rake
|
43
43
|
arel (2.2.1)
|
44
|
-
bcrypt-ruby (3.0.1)
|
45
44
|
builder (3.0.0)
|
46
45
|
diff-lcs (1.1.3)
|
47
46
|
erubis (2.7.0)
|
@@ -51,18 +50,18 @@ GEM
|
|
51
50
|
httpi (0.9.5)
|
52
51
|
rack
|
53
52
|
i18n (0.6.0)
|
54
|
-
json (1.6.
|
53
|
+
json (1.6.3)
|
55
54
|
mail (2.3.0)
|
56
55
|
i18n (>= 0.4.0)
|
57
56
|
mime-types (~> 1.16)
|
58
57
|
treetop (~> 1.4.8)
|
59
58
|
mime-types (1.17.2)
|
60
|
-
multi_json (1.0.
|
59
|
+
multi_json (1.0.4)
|
61
60
|
nokogiri (1.5.0)
|
62
61
|
nori (1.0.2)
|
63
62
|
polyglot (0.3.3)
|
64
63
|
rack (1.3.5)
|
65
|
-
rack-cache (1.
|
64
|
+
rack-cache (1.1)
|
66
65
|
rack (>= 0.4)
|
67
66
|
rack-mount (0.8.3)
|
68
67
|
rack (>= 1.0.0)
|
@@ -70,23 +69,23 @@ GEM
|
|
70
69
|
rack
|
71
70
|
rack-test (0.6.1)
|
72
71
|
rack (>= 1.0)
|
73
|
-
rails (3.1.
|
74
|
-
actionmailer (= 3.1.
|
75
|
-
actionpack (= 3.1.
|
76
|
-
activerecord (= 3.1.
|
77
|
-
activeresource (= 3.1.
|
78
|
-
activesupport (= 3.1.
|
72
|
+
rails (3.1.3)
|
73
|
+
actionmailer (= 3.1.3)
|
74
|
+
actionpack (= 3.1.3)
|
75
|
+
activerecord (= 3.1.3)
|
76
|
+
activeresource (= 3.1.3)
|
77
|
+
activesupport (= 3.1.3)
|
79
78
|
bundler (~> 1.0)
|
80
|
-
railties (= 3.1.
|
81
|
-
railties (3.1.
|
82
|
-
actionpack (= 3.1.
|
83
|
-
activesupport (= 3.1.
|
79
|
+
railties (= 3.1.3)
|
80
|
+
railties (3.1.3)
|
81
|
+
actionpack (= 3.1.3)
|
82
|
+
activesupport (= 3.1.3)
|
84
83
|
rack-ssl (~> 1.3.2)
|
85
84
|
rake (>= 0.8.7)
|
86
85
|
rdoc (~> 3.4)
|
87
86
|
thor (~> 0.14.6)
|
88
87
|
rake (0.9.2.2)
|
89
|
-
rdoc (3.
|
88
|
+
rdoc (3.12)
|
90
89
|
json (~> 1.4)
|
91
90
|
rspec (2.7.0)
|
92
91
|
rspec-core (~> 2.7.0)
|
@@ -127,7 +126,7 @@ PLATFORMS
|
|
127
126
|
|
128
127
|
DEPENDENCIES
|
129
128
|
appraisal
|
130
|
-
rails (= 3.1.
|
129
|
+
rails (= 3.1.3)
|
131
130
|
rspec-rails
|
132
131
|
savon
|
133
132
|
tzinfo
|
data/lib/wash_out.rb
CHANGED
@@ -2,13 +2,14 @@ require 'wash_out/engine'
|
|
2
2
|
require 'wash_out/param'
|
3
3
|
require 'wash_out/dispatcher'
|
4
4
|
require 'wash_out/soap'
|
5
|
+
require 'wash_out/router'
|
5
6
|
|
6
7
|
module ActionDispatch::Routing
|
7
8
|
class Mapper
|
8
9
|
# Adds the routes for a SOAP endpoint at +controller+.
|
9
|
-
def wash_out(
|
10
|
-
match "#{
|
11
|
-
match "#{
|
10
|
+
def wash_out(controller_name, options={})
|
11
|
+
match "#{controller_name}/wsdl" => "#{controller_name}#_generate_wsdl", :via => :get
|
12
|
+
match "#{controller_name}/action" => WashOut::Router.new(controller_name), :defaults => { :action => '_action' }
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
data/lib/wash_out/dispatcher.rb
CHANGED
@@ -9,42 +9,40 @@ module WashOut
|
|
9
9
|
# response.
|
10
10
|
class SOAPError < Exception; end
|
11
11
|
|
12
|
-
# This
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
@name = controller_path.gsub('/', '_')
|
17
|
-
|
18
|
-
render :template => 'wash_with_soap/wsdl'
|
19
|
-
end
|
20
|
-
|
21
|
-
# This action maps the SOAP action to a controller method defined with
|
22
|
-
# +soap_action+.
|
23
|
-
def _action
|
24
|
-
map = self.class.soap_actions
|
25
|
-
method = request.env['HTTP_SOAPACTION'].gsub(/^\"(.*)\"$/, '\1')
|
26
|
-
@_current = map[method.force_encoding('UTF-8')]
|
27
|
-
|
28
|
-
raise SOAPError, "Method #{method} does not exists" unless @_current
|
12
|
+
# This filter parses the SOAP request and puts it into +params+ array.
|
13
|
+
def _parse_soap_parameters
|
14
|
+
soap_action = request.env['wash_out.soap_action']
|
15
|
+
action_spec = self.class.soap_actions[soap_action]
|
29
16
|
|
30
17
|
params = Nori.parse(request.body)
|
31
|
-
xml_data = params[:envelope][:body][
|
18
|
+
xml_data = params[:envelope][:body][soap_action.underscore.to_sym]
|
32
19
|
|
33
20
|
@_params = HashWithIndifferentAccess.new
|
34
21
|
(xml_data || {}).map do |opt, value|
|
35
|
-
param =
|
22
|
+
param = action_spec[:in].find { |param| param.name.underscore.to_sym == opt }
|
36
23
|
raise SOAPError, "unknown parameter #{opt}" unless param
|
37
24
|
|
38
25
|
@_params[param.name] = param.load(value)
|
39
26
|
end
|
27
|
+
end
|
40
28
|
|
41
|
-
|
29
|
+
# This action generates the WSDL for defined SOAP methods.
|
30
|
+
def _generate_wsdl
|
31
|
+
@map = self.class.soap_actions
|
32
|
+
@namespace = 'urn:WashOut'
|
33
|
+
@name = controller_path.gsub('/', '_')
|
34
|
+
|
35
|
+
render :template => 'wash_with_soap/wsdl'
|
42
36
|
end
|
43
37
|
|
38
|
+
# Render a SOAP response.
|
44
39
|
def _render_soap(result, options)
|
40
|
+
soap_action = request.env['wash_out.soap_action']
|
41
|
+
action_spec = self.class.soap_actions[soap_action]
|
42
|
+
|
45
43
|
result = { 'value' => result } unless result.is_a? Hash
|
46
44
|
result = HashWithIndifferentAccess.new(result)
|
47
|
-
result = Hash[
|
45
|
+
result = Hash[*action_spec[:out].map do |param|
|
48
46
|
[param, param.store(result[param.name])]
|
49
47
|
end.flatten]
|
50
48
|
|
@@ -52,6 +50,11 @@ module WashOut
|
|
52
50
|
:locals => { :result => result }
|
53
51
|
end
|
54
52
|
|
53
|
+
# This action is a fallback for all undefined SOAP actions.
|
54
|
+
def _invalid_action
|
55
|
+
render_soap_error("Cannot find SOAP action mapping for #{request.env['wash_out.soap_action']}")
|
56
|
+
end
|
57
|
+
|
55
58
|
# Render a SOAP error response.
|
56
59
|
#
|
57
60
|
# Rails do not support sequental rescue_from handling, that is, rescuing an
|
@@ -65,6 +68,8 @@ module WashOut
|
|
65
68
|
|
66
69
|
def self.included(controller)
|
67
70
|
controller.send :rescue_from, SOAPError, :with => :_render_soap_exception
|
71
|
+
controller.send :helper, :wash_out
|
72
|
+
controller.send :before_filter, :_parse_soap_parameters, :except => [ :_generate_wsdl, :_invalid_action ]
|
68
73
|
end
|
69
74
|
|
70
75
|
def _render_soap_exception(error)
|
data/lib/wash_out/param.rb
CHANGED
@@ -35,7 +35,7 @@ module WashOut
|
|
35
35
|
when 'string'; data.to_s
|
36
36
|
when 'integer'; data.to_i
|
37
37
|
when 'double'; data.to_f
|
38
|
-
when 'boolean'; data
|
38
|
+
when 'boolean'; data # Nori handles that for us
|
39
39
|
else raise RuntimeError, "Invalid WashOut simple type: #{type}"
|
40
40
|
end
|
41
41
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module WashOut
|
2
|
+
# This class is a Rack middleware used to route SOAP requests to a proper
|
3
|
+
# action of a given SOAP controller.
|
4
|
+
class Router
|
5
|
+
def initialize(controller_name)
|
6
|
+
@controller_name = "#{controller_name.to_s}_controller".camelize
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
controller = @controller_name.constantize
|
11
|
+
|
12
|
+
soap_action = env['HTTP_SOAPACTION']
|
13
|
+
soap_action.force_encoding('UTF-8')
|
14
|
+
soap_action.gsub!(/^\"(.*)\"$/, '\1')
|
15
|
+
|
16
|
+
env['wash_out.soap_action'] = soap_action
|
17
|
+
|
18
|
+
action_spec = controller.soap_actions[soap_action]
|
19
|
+
if action_spec
|
20
|
+
action = action_spec[:to]
|
21
|
+
else
|
22
|
+
action = '_invalid_action'
|
23
|
+
end
|
24
|
+
|
25
|
+
controller.action(action).call(env)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/wash_out/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -20,6 +20,8 @@ RSpec.configure do |config|
|
|
20
20
|
config.mock_with :rspec
|
21
21
|
end
|
22
22
|
|
23
|
+
require 'savon'
|
24
|
+
|
23
25
|
Savon.configure do |config|
|
24
26
|
config.log = false # disable logging
|
25
27
|
end
|
@@ -27,12 +29,23 @@ end
|
|
27
29
|
HTTPI.logger = Logger.new(open("/dev/null", 'w'))
|
28
30
|
HTTPI.adapter = :rack
|
29
31
|
|
32
|
+
HTTPI::Adapters::Rack.mount 'app', Dummy::Application
|
33
|
+
|
30
34
|
Dummy::Application.routes.draw do
|
31
35
|
wash_out :api
|
32
36
|
end
|
33
37
|
|
34
38
|
def savon_instance
|
35
39
|
Savon::Client.new do
|
36
|
-
wsdl.document = 'http://
|
40
|
+
wsdl.document = 'http://app/api/wsdl'
|
37
41
|
end
|
38
42
|
end
|
43
|
+
|
44
|
+
def mock_controller(&block)
|
45
|
+
Object.send :remove_const, :ApiController if defined?(ApiController)
|
46
|
+
Object.send :const_set, :ApiController, Class.new(ApplicationController) {
|
47
|
+
include WashOut::SOAP
|
48
|
+
|
49
|
+
class_exec &block if block
|
50
|
+
}
|
51
|
+
end
|
data/spec/support/httpi-rack.rb
CHANGED
@@ -3,7 +3,19 @@ require 'httpi/response'
|
|
3
3
|
|
4
4
|
module HTTPI
|
5
5
|
module Adapters
|
6
|
+
# This is an adapter for testing the Rack applications with HTTPI-capable
|
7
|
+
# clients.
|
6
8
|
class Rack
|
9
|
+
class << self
|
10
|
+
attr_accessor :mounted_apps
|
11
|
+
end
|
12
|
+
|
13
|
+
self.mounted_apps = {}
|
14
|
+
|
15
|
+
def self.mount(host, application)
|
16
|
+
self.mounted_apps[host] = application
|
17
|
+
end
|
18
|
+
|
7
19
|
def initialize(request=nil)
|
8
20
|
end
|
9
21
|
|
@@ -11,16 +23,16 @@ module HTTPI
|
|
11
23
|
if %w{get post head put delete}.include?(method.to_s)
|
12
24
|
request, = args
|
13
25
|
|
14
|
-
|
15
|
-
app = $controller.action(action)
|
16
|
-
app = ActionDispatch::ParamsParser.new(app)
|
26
|
+
app = self.class.mounted_apps[request.url.host]
|
17
27
|
mock_req = ::Rack::MockRequest.new(app)
|
18
28
|
|
19
29
|
env = {}
|
20
|
-
|
21
|
-
|
30
|
+
request.headers.each do |header, value|
|
31
|
+
env["HTTP_#{header.gsub('-', '_').upcase}"] = value
|
32
|
+
end
|
33
|
+
|
22
34
|
mock_resp = mock_req.request(method.to_s.upcase, request.url.to_s,
|
23
|
-
{ :fatal => true, :
|
35
|
+
{ :fatal => true, :input => request.body.to_s }.merge(env))
|
24
36
|
|
25
37
|
HTTPI::Response.new(mock_resp.status, mock_resp.headers, mock_resp.body)
|
26
38
|
else
|
data/spec/wash_out_spec.rb
CHANGED
@@ -8,36 +8,40 @@ describe WashOut do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should allow to include SOAP module" do
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
lambda {
|
12
|
+
mock_controller do
|
13
|
+
# nothing
|
14
|
+
end
|
15
|
+
}.should_not raise_exception
|
14
16
|
end
|
15
17
|
|
16
18
|
it "should allow definition of a simple action" do
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
lambda {
|
20
|
+
mock_controller do
|
21
|
+
soap_action "answer", :args => [], :return => :int
|
22
|
+
end
|
23
|
+
}.should_not raise_exception
|
20
24
|
end
|
21
25
|
|
22
26
|
it "should answer to request without parameters" do
|
23
27
|
mock_controller do
|
24
28
|
soap_action "answer", :args => [], :return => :int
|
25
29
|
def answer
|
26
|
-
render :soap => 42
|
30
|
+
render :soap => "42"
|
27
31
|
end
|
28
|
-
end
|
32
|
+
end
|
29
33
|
|
30
34
|
client = savon_instance
|
31
|
-
client.request(:answer).to_hash[:value].should == 42
|
35
|
+
client.request(:answer).to_hash[:value].should == "42"
|
32
36
|
end
|
33
37
|
|
34
38
|
it "should answer to request with one parameter" do
|
35
39
|
mock_controller do
|
36
|
-
soap_action "
|
40
|
+
soap_action "checkAnswer", :args => :integer, :return => :boolean, :to => 'check_answer'
|
37
41
|
def check_answer
|
38
42
|
render :soap => (params[:value] == 42)
|
39
43
|
end
|
40
|
-
end
|
44
|
+
end
|
41
45
|
|
42
46
|
client = savon_instance
|
43
47
|
client.request(:check_answer) do
|
@@ -54,7 +58,7 @@ describe WashOut do
|
|
54
58
|
def funky
|
55
59
|
render :soap => ((params[:a] * 10).to_s + params[:b])
|
56
60
|
end
|
57
|
-
end
|
61
|
+
end
|
58
62
|
|
59
63
|
client = savon_instance
|
60
64
|
client.request(:funky) do
|
@@ -69,7 +73,7 @@ describe WashOut do
|
|
69
73
|
def answer
|
70
74
|
render :soap => "forty two"
|
71
75
|
end
|
72
|
-
end
|
76
|
+
end
|
73
77
|
|
74
78
|
client = savon_instance
|
75
79
|
client.request('AnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything').to_hash[:value].should == "forty two"
|
@@ -83,7 +87,7 @@ describe WashOut do
|
|
83
87
|
|
84
88
|
render :soap => nil
|
85
89
|
end
|
86
|
-
end
|
90
|
+
end
|
87
91
|
|
88
92
|
client = savon_instance
|
89
93
|
lambda {
|
@@ -99,7 +103,7 @@ describe WashOut do
|
|
99
103
|
end
|
100
104
|
|
101
105
|
it "should report a SOAP error if method does not exists" do
|
102
|
-
mock_controller
|
106
|
+
mock_controller
|
103
107
|
|
104
108
|
client = savon_instance
|
105
109
|
lambda {
|
@@ -113,7 +117,7 @@ describe WashOut do
|
|
113
117
|
def error
|
114
118
|
render_soap_error "a message"
|
115
119
|
end
|
116
|
-
end
|
120
|
+
end
|
117
121
|
|
118
122
|
client = savon_instance
|
119
123
|
lambda {
|
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nori
|
17
|
-
requirement: &
|
17
|
+
requirement: &70120807486540 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70120807486540
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec-rails
|
28
|
-
requirement: &
|
28
|
+
requirement: &70120807486020 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70120807486020
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: appraisal
|
39
|
-
requirement: &
|
39
|
+
requirement: &70120807485520 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70120807485520
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: tzinfo
|
50
|
-
requirement: &
|
50
|
+
requirement: &70120807484900 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70120807484900
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: savon
|
61
|
-
requirement: &
|
61
|
+
requirement: &70120807484020 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70120807484020
|
70
70
|
description: Dead simple Rails 3 SOAP server library
|
71
71
|
email: boris@roundlake.ru
|
72
72
|
executables: []
|
@@ -83,15 +83,16 @@ files:
|
|
83
83
|
- app/views/wash_with_soap/error.builder
|
84
84
|
- app/views/wash_with_soap/response.builder
|
85
85
|
- app/views/wash_with_soap/wsdl.builder
|
86
|
-
- gemfiles/rails-3.0.
|
87
|
-
- gemfiles/rails-3.0.
|
88
|
-
- gemfiles/rails-3.1.
|
89
|
-
- gemfiles/rails-3.1.
|
86
|
+
- gemfiles/rails-3.0.11.gemfile
|
87
|
+
- gemfiles/rails-3.0.11.gemfile.lock
|
88
|
+
- gemfiles/rails-3.1.3.gemfile
|
89
|
+
- gemfiles/rails-3.1.3.gemfile.lock
|
90
90
|
- init.rb
|
91
91
|
- lib/wash_out.rb
|
92
92
|
- lib/wash_out/dispatcher.rb
|
93
93
|
- lib/wash_out/engine.rb
|
94
94
|
- lib/wash_out/param.rb
|
95
|
+
- lib/wash_out/router.rb
|
95
96
|
- lib/wash_out/soap.rb
|
96
97
|
- lib/wash_out/version.rb
|
97
98
|
- spec/dummy/Rakefile
|
@@ -119,7 +120,6 @@ files:
|
|
119
120
|
- spec/dummy/script/rails
|
120
121
|
- spec/spec_helper.rb
|
121
122
|
- spec/support/httpi-rack.rb
|
122
|
-
- spec/support/mock_controller.rb
|
123
123
|
- spec/wash_out_spec.rb
|
124
124
|
- wash_out.gemspec
|
125
125
|
homepage: http://github.com/roundlake/wash_out
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'savon'
|
2
|
-
|
3
|
-
def mock_controller(&block)
|
4
|
-
# You are not expected to understand this.
|
5
|
-
class <<(mock = lambda do
|
6
|
-
Class.new(ApplicationController) do
|
7
|
-
include WashOut::SOAP
|
8
|
-
|
9
|
-
class_exec &block
|
10
|
-
|
11
|
-
def self.controller_path
|
12
|
-
"api"
|
13
|
-
end
|
14
|
-
|
15
|
-
def default_url_options
|
16
|
-
{ :controller => 'api' }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end)
|
20
|
-
def invoke
|
21
|
-
@self ||= call
|
22
|
-
end
|
23
|
-
|
24
|
-
def method_missing(method, *args)
|
25
|
-
invoke.send method, *args
|
26
|
-
end
|
27
|
-
|
28
|
-
def use!
|
29
|
-
$controller = invoke
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
mock
|
34
|
-
end
|