playerconnect-wsdsl 0.3.7 → 0.3.8
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.
- data/VERSION +1 -1
- data/lib/wsdsl.rb +2 -2
- data/playerconnect-wsdsl.gemspec +2 -2
- data/spec/hello_world_service.rb +1 -1
- data/spec/params_verification_spec.rb +5 -5
- data/spec/preferences_service.rb +1 -1
- data/spec/test_services.rb +4 -4
- data/spec/wsdsl_sinatra_ext_spec.rb +2 -2
- data/spec/wsdsl_spec.rb +21 -21
- metadata +43 -18
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.8
|
data/lib/wsdsl.rb
CHANGED
@@ -331,8 +331,8 @@ class WSDSL
|
|
331
331
|
end
|
332
332
|
|
333
333
|
SERVICE_ROOT_REGEXP = /(.*?)[\/\(\.]/
|
334
|
-
SERVICE_ACTION_REGEXP = /[\/\(\.]([a-z0-9_]+)[\/\(\.\?]/i
|
335
|
-
SERVICE_RESTFUL_SHOW_REGEXP = /\/:[a-z0-9_]+\.\w{3}$/
|
334
|
+
SERVICE_ACTION_REGEXP = /[\/\(\.]([a-z0-9_]+)[\/\.\(\?]?/i # /[\/\(\.]([a-z0-9_]+)[\/\(\.\?]/i
|
335
|
+
SERVICE_RESTFUL_SHOW_REGEXP = /\/:[a-z0-9_]+$/ # /\/:[a-z0-9_]+\.\w{3}$/
|
336
336
|
|
337
337
|
private
|
338
338
|
|
data/playerconnect-wsdsl.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "playerconnect-wsdsl"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Team SDOD"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-12-09"
|
13
13
|
s.description = "A Ruby DSL describing Web Services without implementation details."
|
14
14
|
s.email = "sdod"
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/hello_world_service.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative "spec_helper"
|
|
3
3
|
describe ParamsVerification do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@service = WSList.all.find{|s| s.url == 'services/test
|
6
|
+
@service = WSList.all.find{|s| s.url == 'services/test'}
|
7
7
|
@service.should_not be_nil
|
8
8
|
end
|
9
9
|
|
@@ -72,7 +72,7 @@ describe ParamsVerification do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should cast a comma delimited string into an array when param marked as an array" do
|
75
|
-
service = WSList.all.find{|s| s.url == "services/array_param
|
75
|
+
service = WSList.all.find{|s| s.url == "services/array_param"}
|
76
76
|
service.should_not be_nil
|
77
77
|
params = {'seq' => "a,b,c,d,e,g"}
|
78
78
|
validated = ParamsVerification.validate!(params, service.defined_params)
|
@@ -80,7 +80,7 @@ describe ParamsVerification do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should not raise an exception if a req array param doesn't contain a comma" do
|
83
|
-
service = WSList.all.find{|s| s.url == "services/array_param
|
83
|
+
service = WSList.all.find{|s| s.url == "services/array_param"}
|
84
84
|
params = {'seq' => "a b c d e g"}
|
85
85
|
lambda{ ParamsVerification.validate!(params, service.defined_params) }.should_not raise_exception(ParamsVerification::InvalidParamType)
|
86
86
|
end
|
@@ -127,13 +127,13 @@ describe ParamsVerification do
|
|
127
127
|
lambda{ ParamsVerification.validate!(params, @service.defined_params) }.should raise_exception(ParamsVerification::InvalidParamValue)
|
128
128
|
# other service
|
129
129
|
params = {'preference' => {'region_code' => 'us', 'language_code' => 'de'}}
|
130
|
-
service = WSList.all.find{|s| s.url == 'preferences
|
130
|
+
service = WSList.all.find{|s| s.url == 'preferences'}
|
131
131
|
service.should_not be_nil
|
132
132
|
lambda{ ParamsVerification.validate!(params, service.defined_params) }.should raise_exception(ParamsVerification::InvalidParamValue)
|
133
133
|
end
|
134
134
|
|
135
135
|
it "should validate that no params are passed when accept_no_params! is set on a service" do
|
136
|
-
service = WSList.all.find{|s| s.url == "services/test_no_params
|
136
|
+
service = WSList.all.find{|s| s.url == "services/test_no_params"}
|
137
137
|
service.should_not be_nil
|
138
138
|
params = @valid_params.dup
|
139
139
|
lambda{ ParamsVerification.validate!(params, service.defined_params) }.should raise_exception
|
data/spec/preferences_service.rb
CHANGED
data/spec/test_services.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
WSDSLSpecOptions = ['RSpec', 'Bacon'] # usually pulled from a model
|
2
2
|
|
3
|
-
describe_service "services/test
|
3
|
+
describe_service "services/test" do |service|
|
4
4
|
service.formats :xml, :json
|
5
5
|
service.http_verb :get
|
6
6
|
|
@@ -63,19 +63,19 @@ The most common way to use this service looks like that:
|
|
63
63
|
end
|
64
64
|
|
65
65
|
|
66
|
-
describe_service "services/test_no_params
|
66
|
+
describe_service "services/test_no_params" do |service|
|
67
67
|
service.formats :xml
|
68
68
|
service.http_verb :get
|
69
69
|
service.accept_no_params!
|
70
70
|
end
|
71
71
|
|
72
|
-
describe_service "services
|
72
|
+
describe_service "services" do |service|
|
73
73
|
service.formats :xml
|
74
74
|
service.http_verb :put
|
75
75
|
|
76
76
|
end
|
77
77
|
|
78
|
-
describe_service "services/array_param
|
78
|
+
describe_service "services/array_param" do |s|
|
79
79
|
s.formats :xml
|
80
80
|
s.http_verb :post
|
81
81
|
|
@@ -12,13 +12,13 @@ describe "Hello World example" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
before(:all) do
|
15
|
-
service = WSList.all.find{|s| s.url == 'hello_world
|
15
|
+
service = WSList.all.find{|s| s.url == 'hello_world'}
|
16
16
|
service.should_not be_nil
|
17
17
|
service.load_sinatra_route
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should dispatch the hello world service properly" do
|
21
|
-
get "/hello_world
|
21
|
+
get "/hello_world"
|
22
22
|
last_response.body.should include("Hello World")
|
23
23
|
end
|
24
24
|
|
data/spec/wsdsl_spec.rb
CHANGED
@@ -3,13 +3,13 @@ require File.expand_path("spec_helper", File.dirname(__FILE__))
|
|
3
3
|
describe WSDSL do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@service = WSList.all.find{|s| s.url == 'services/test
|
6
|
+
@service = WSList.all.find{|s| s.url == 'services/test'}
|
7
7
|
@service.should_not be_nil
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should have an url" do
|
11
11
|
# dummy test since that's how we found the service, but oh well
|
12
|
-
@service.url.should be == 'services/test
|
12
|
+
@service.url.should be == 'services/test'
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should have some http verbs defined" do
|
@@ -39,7 +39,7 @@ describe WSDSL do
|
|
39
39
|
it "should set the controller accordingly" do
|
40
40
|
@service.controller_name.should_not be_nil
|
41
41
|
@service.controller_name.should be == 'ServicesController'
|
42
|
-
service = WSDSL.new("preferences
|
42
|
+
service = WSDSL.new("preferences")
|
43
43
|
service.name.should be == 'preferences'
|
44
44
|
ExtlibCopy.classify('preferences').should be == 'Preferences'
|
45
45
|
service.controller_name.should be == 'PreferencesController'
|
@@ -51,7 +51,7 @@ describe WSDSL do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should support restful routes based on the HTTP verb" do
|
54
|
-
service = WSList.all.find{|s| s.url == "services
|
54
|
+
service = WSList.all.find{|s| s.url == "services"}
|
55
55
|
service.should_not be_nil
|
56
56
|
service.http_verb.should be == :put
|
57
57
|
service.action.should_not be_nil
|
@@ -60,39 +60,39 @@ describe WSDSL do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should have a default action" do
|
63
|
-
service = WSDSL.new('spec_test
|
63
|
+
service = WSDSL.new('spec_test')
|
64
64
|
service.action.should be == 'list'
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should route to show when an id is the last passed param" do
|
68
|
-
service = WSDSL.new("players/:id
|
68
|
+
service = WSDSL.new("players/:id")
|
69
69
|
service.action.should be == 'show'
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should support some extra attributes" do
|
73
|
-
service = WSDSL.new("players/:id
|
73
|
+
service = WSDSL.new("players/:id")
|
74
74
|
service.extra[:custom_name] = 'fooBar'
|
75
75
|
service.extra[:custom_name].should be == 'fooBar'
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should respect the global controller pluralization flag" do
|
79
79
|
WSDSL.use_pluralized_controllers = true
|
80
|
-
service = WSDSL.new("player/:id
|
80
|
+
service = WSDSL.new("player/:id")
|
81
81
|
service.controller_name.should be == "PlayersController"
|
82
|
-
service = WSDSL.new("players/:id
|
82
|
+
service = WSDSL.new("players/:id")
|
83
83
|
service.controller_name.should be == "PlayersController"
|
84
84
|
WSDSL.use_pluralized_controllers = false
|
85
|
-
service = WSDSL.new("player/:id
|
85
|
+
service = WSDSL.new("player/:id")
|
86
86
|
service.controller_name.should be == "PlayerController"
|
87
87
|
end
|
88
88
|
|
89
89
|
|
90
90
|
it "should let overwrite the controller name and action after initialization" do
|
91
|
-
describe_service "players/:id
|
91
|
+
describe_service "players/:id" do |service|
|
92
92
|
service.controller_name "CustomController"
|
93
93
|
service.action :foo
|
94
94
|
end
|
95
|
-
service = WSList.all.find{|s| s.url == "players/:id
|
95
|
+
service = WSList.all.find{|s| s.url == "players/:id"}
|
96
96
|
service.controller_name.should be == "CustomController"
|
97
97
|
service.action.should be == :foo
|
98
98
|
end
|
@@ -132,36 +132,36 @@ describe WSDSL do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should be able to dispatch controller" do
|
135
|
-
describe_service("projects
|
136
|
-
service = WSList.all.find{|s| s.url == "projects
|
135
|
+
describe_service("projects") { |s| }
|
136
|
+
service = WSList.all.find{|s| s.url == "projects"}
|
137
137
|
service.controller_dispatch("application").
|
138
138
|
should be == ["application", "projects"]
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should be able to dispatch namespaced controller" do
|
142
|
-
describe_service("project/:project_id/tasks
|
142
|
+
describe_service("project/:project_id/tasks") do |service|
|
143
143
|
service.controller_name = "Projects::TasksController"
|
144
144
|
service.action = "list"
|
145
145
|
end
|
146
146
|
|
147
|
-
describe_service("project/:project_id/task/:task_id/items
|
147
|
+
describe_service("project/:project_id/task/:task_id/items") do |service|
|
148
148
|
service.controller_name = "Projects::Tasks::ItemsController"
|
149
149
|
service.action = "list"
|
150
150
|
end
|
151
151
|
|
152
|
-
service = WSList.all.find{|s| s.url == "project/:project_id/tasks
|
152
|
+
service = WSList.all.find{|s| s.url == "project/:project_id/tasks"}
|
153
153
|
service.controller_dispatch("application").should be == ["application", "project"]
|
154
154
|
|
155
|
-
service = WSList.all.find{|s| s.url == "project/:project_id/task/:task_id/items
|
155
|
+
service = WSList.all.find{|s| s.url == "project/:project_id/task/:task_id/items"}
|
156
156
|
service.controller_dispatch("application").should be == ["application", "project"]
|
157
157
|
end
|
158
158
|
|
159
159
|
it "should raise exception when controller class is not found" do
|
160
|
-
describe_service("unknown
|
160
|
+
describe_service("unknown") do |service|
|
161
161
|
service.controller_name = "UnknownController"
|
162
162
|
service.action = "list"
|
163
163
|
end
|
164
|
-
service = WSList.all.find{|s| s.url == "unknown
|
164
|
+
service = WSList.all.find{|s| s.url == "unknown"}
|
165
165
|
lambda { service.controller_dispatch("application") }.
|
166
166
|
should raise_error("The UnknownController class was not found")
|
167
167
|
lambda { service.controller_dispatch("application") }.
|
@@ -237,7 +237,7 @@ describe WSDSL do
|
|
237
237
|
end
|
238
238
|
|
239
239
|
it "should allow to define namespaced params doc" do
|
240
|
-
service = WSList.all.find{|s| s.url == "services
|
240
|
+
service = WSList.all.find{|s| s.url == "services"}
|
241
241
|
service.documentation do |doc|
|
242
242
|
doc.namespace :preference do |ns|
|
243
243
|
ns.param :id, "Ze id."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playerconnect-wsdsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,63 +9,88 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jeweler
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- - =
|
19
|
+
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 1.6.4
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.6.4
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rspec
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
|
-
- - =
|
35
|
+
- - '='
|
31
36
|
- !ruby/object:Gem::Version
|
32
37
|
version: 2.7.0
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.7.0
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: yard
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
|
-
- - =
|
51
|
+
- - '='
|
42
52
|
- !ruby/object:Gem::Version
|
43
53
|
version: 0.7.2
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.7.2
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rack-test
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
|
-
- - =
|
67
|
+
- - '='
|
53
68
|
- !ruby/object:Gem::Version
|
54
69
|
version: 0.5.7
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - '='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.5.7
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: sinatra
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
|
-
- - =
|
83
|
+
- - '='
|
64
84
|
- !ruby/object:Gem::Version
|
65
85
|
version: 1.2.0
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - '='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.2.0
|
69
94
|
description: A Ruby DSL describing Web Services without implementation details.
|
70
95
|
email: sdod
|
71
96
|
executables: []
|
@@ -121,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
146
|
version: '0'
|
122
147
|
requirements: []
|
123
148
|
rubyforge_project:
|
124
|
-
rubygems_version: 1.8.
|
149
|
+
rubygems_version: 1.8.24
|
125
150
|
signing_key:
|
126
151
|
specification_version: 3
|
127
152
|
summary: Web Service DSL
|