playerconnect-wsdsl 0.2.2
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/.rvmrc_example +15 -0
- data/LICENSE +23 -0
- data/README.md +100 -0
- data/Rakefile +36 -0
- data/VERSION +1 -0
- data/lib/documentation.rb +151 -0
- data/lib/framework_ext/sinatra.rb +30 -0
- data/lib/framework_ext/sinatra_controller.rb +80 -0
- data/lib/inflection.rb +460 -0
- data/lib/params.rb +367 -0
- data/lib/params_verification.rb +267 -0
- data/lib/response.rb +301 -0
- data/lib/ws_list.rb +48 -0
- data/lib/wsdsl.rb +359 -0
- data/playerconnect-wsdsl.gemspec +60 -0
- data/spec/hello_world_controller.rb +5 -0
- data/spec/hello_world_service.rb +20 -0
- data/spec/params_verification_spec.rb +93 -0
- data/spec/preferences_service.rb +10 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/test_services.rb +83 -0
- data/spec/wsdsl_sinatra_ext_spec.rb +26 -0
- data/spec/wsdsl_spec.rb +222 -0
- data/wsdsl.gemspec +60 -0
- metadata +71 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{playerconnect-wsdsl}
|
8
|
+
s.version = "0.2.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{Team SDOD}]
|
12
|
+
s.date = %q{2011-07-07}
|
13
|
+
s.description = %q{A Ruby DSL describing Web Services without implementation details.}
|
14
|
+
s.email = %q{sdod@scea.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".rvmrc_example",
|
21
|
+
"LICENSE",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lib/documentation.rb",
|
26
|
+
"lib/framework_ext/sinatra.rb",
|
27
|
+
"lib/framework_ext/sinatra_controller.rb",
|
28
|
+
"lib/inflection.rb",
|
29
|
+
"lib/params.rb",
|
30
|
+
"lib/params_verification.rb",
|
31
|
+
"lib/response.rb",
|
32
|
+
"lib/ws_list.rb",
|
33
|
+
"lib/wsdsl.rb",
|
34
|
+
"playerconnect-wsdsl.gemspec",
|
35
|
+
"spec/hello_world_controller.rb",
|
36
|
+
"spec/hello_world_service.rb",
|
37
|
+
"spec/params_verification_spec.rb",
|
38
|
+
"spec/preferences_service.rb",
|
39
|
+
"spec/spec_helper.rb",
|
40
|
+
"spec/test_services.rb",
|
41
|
+
"spec/wsdsl_sinatra_ext_spec.rb",
|
42
|
+
"spec/wsdsl_spec.rb",
|
43
|
+
"wsdsl.gemspec"
|
44
|
+
]
|
45
|
+
s.homepage = %q{http://github.com/playerconnect/wsdsl}
|
46
|
+
s.licenses = [%q{MIT}]
|
47
|
+
s.require_paths = [%q{lib}]
|
48
|
+
s.rubygems_version = %q{1.8.5}
|
49
|
+
s.summary = %q{Web Service DSL}
|
50
|
+
|
51
|
+
if s.respond_to? :specification_version then
|
52
|
+
s.specification_version = 3
|
53
|
+
|
54
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
+
else
|
56
|
+
end
|
57
|
+
else
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
describe_service "hello_world.xml" do |service|
|
2
|
+
service.formats :xml
|
3
|
+
service.http_verb :get
|
4
|
+
service.disable_auth # on by default
|
5
|
+
|
6
|
+
service.param.string :name, :default => 'World'
|
7
|
+
|
8
|
+
service.response do |response|
|
9
|
+
response.element(:name => "greeting") do |e|
|
10
|
+
e.attribute "message" => :string, :doc => "The greeting message sent back."
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
service.documentation do |doc|
|
15
|
+
doc.overall "This service provides a simple hello world implementation example."
|
16
|
+
doc.params :name, "The name of the person to greet."
|
17
|
+
doc.example "<code>http://ps3.yourgame.com/hello_world.xml?name=Matt</code>"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe ParamsVerification do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@service = WSList.all.find{|s| s.url == 'services/test.xml'}
|
7
|
+
@service.should_not be_nil
|
8
|
+
@valid_params = {'framework' => 'RSpec', 'version' => '1.02', 'user' => {'id' => '123'}}
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should validate valid params" do
|
12
|
+
params = @valid_params.dup
|
13
|
+
lambda{ ParamsVerification.validate!(params, @service.defined_params) }.should_not raise_exception
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return the params" do
|
17
|
+
params = @valid_params.dup
|
18
|
+
returned_params = ParamsVerification.validate!(params, @service.defined_params)
|
19
|
+
returned_params.should be_an_instance_of(Hash)
|
20
|
+
returned_params.keys.size.should >= 3
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should set the default value for an optional param" do
|
24
|
+
params = @valid_params.dup
|
25
|
+
params['timestamp'].should be_nil
|
26
|
+
returned_params = ParamsVerification.validate!(params, @service.defined_params)
|
27
|
+
returned_params['timestamp'].should_not be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should set the default value for a namespace optional param" do
|
31
|
+
params = {'framework' => 'RSpec', 'version' => '1.02', 'user' => {'id' => '123'}}
|
32
|
+
params['user']['mailing_list'].should be_nil
|
33
|
+
returned_params = ParamsVerification.validate!(params, @service.defined_params)
|
34
|
+
returned_params['user']['mailing_list'].should be_true
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should raise an exception when a required param is missing" do
|
38
|
+
params = @valid_params.dup
|
39
|
+
params.delete('framework')
|
40
|
+
lambda{ ParamsVerification.validate!(params, @service.defined_params) }.should raise_exception(ParamsVerification::MissingParam)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should cast a comma delimited string into an array when param marked as an array" do
|
44
|
+
service = WSList.all.find{|s| s.url == "services/array_param.xml"}
|
45
|
+
service.should_not be_nil
|
46
|
+
params = {'seq' => "a,b,c,d,e,g"}
|
47
|
+
validated = ParamsVerification.validate!(params, service.defined_params)
|
48
|
+
validated['seq'].should == %W{a b c d e g}
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should not raise an exception if a req array param doesn't contain a comma" do
|
52
|
+
service = WSList.all.find{|s| s.url == "services/array_param.xml"}
|
53
|
+
params = {'seq' => "a b c d e g"}
|
54
|
+
lambda{ ParamsVerification.validate!(params, service.defined_params) }.should_not raise_exception(ParamsVerification::InvalidParamType)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should raise an exception when a param is of the wrong type" do
|
58
|
+
params = @valid_params.dup
|
59
|
+
params['user']['id'] = 'abc'
|
60
|
+
lambda{ ParamsVerification.validate!(params, @service.defined_params) }.should raise_exception(ParamsVerification::InvalidParamType)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should raise an exception when a param is under the minvalue" do
|
64
|
+
params = @valid_params.dup
|
65
|
+
params['num'] = 1
|
66
|
+
lambda{ ParamsVerification.validate!(params, @service.defined_params) }.should raise_exception(ParamsVerification::InvalidParamType)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should raise an exception when a param isn't in the param option list" do
|
70
|
+
params = @valid_params.dup
|
71
|
+
params['alpha'] = 'z'
|
72
|
+
lambda{ ParamsVerification.validate!(params, @service.defined_params) }.should raise_exception(ParamsVerification::InvalidParamValue)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should raise an exception when a nested optional param isn't in the param option list" do
|
76
|
+
params = @valid_params.dup
|
77
|
+
params['user']['sex'] = 'large'
|
78
|
+
lambda{ ParamsVerification.validate!(params, @service.defined_params) }.should raise_exception(ParamsVerification::InvalidParamType)
|
79
|
+
# other service
|
80
|
+
params = {'preference' => {'region_code' => 'us', 'language_code' => 'de'}}
|
81
|
+
service = WSList.all.find{|s| s.url == 'preferences.xml'}
|
82
|
+
service.should_not be_nil
|
83
|
+
lambda{ ParamsVerification.validate!(params, service.defined_params) }.should raise_exception(ParamsVerification::InvalidParamValue)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should validate that no params are passed when accept_no_params! is set on a service" do
|
87
|
+
service = WSList.all.find{|s| s.url == "services/test_no_params.xml"}
|
88
|
+
service.should_not be_nil
|
89
|
+
params = @valid_params.dup
|
90
|
+
lambda{ ParamsVerification.validate!(params, service.defined_params) }.should raise_exception
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'rack/test'
|
3
|
+
require 'sinatra'
|
4
|
+
|
5
|
+
require_relative "../lib/wsdsl"
|
6
|
+
require_relative 'test_services'
|
7
|
+
require_relative 'preferences_service'
|
8
|
+
require_relative "../lib/framework_ext/sinatra_controller"
|
9
|
+
|
10
|
+
ENV["RACK_ENV"] = 'test'
|
11
|
+
|
12
|
+
RSpec.configure do |conf|
|
13
|
+
conf.include Rack::Test::Methods
|
14
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
WSDSLSpecOptions = ['RSpec', 'Bacon'] # usually pulled from a model
|
2
|
+
|
3
|
+
describe_service "services/test.xml" do |service|
|
4
|
+
service.formats :xml, :json
|
5
|
+
service.http_verb :get
|
6
|
+
|
7
|
+
service.params do |p|
|
8
|
+
p.string :framework, :in => WSDSLSpecOptions, :null => false, :required => true
|
9
|
+
|
10
|
+
p.datetime :timestamp, :default => Time.now
|
11
|
+
p.string :alpha, :in => ['a', 'b', 'c']
|
12
|
+
p.string :version, :null => false
|
13
|
+
p.integer :num, :minvalue => 42
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
# service.param :delta, :optional => true, :type => 'float'
|
18
|
+
# # if the optional flag isn't passed, the param is considered required.
|
19
|
+
# service.param :epsilon, :type => 'string'
|
20
|
+
|
21
|
+
service.params.namespace :user do |user|
|
22
|
+
user.integer :id, :required => :true
|
23
|
+
user.string :sex, :in => %Q{female, male}
|
24
|
+
user.boolean :mailing_list, :default => true
|
25
|
+
end
|
26
|
+
|
27
|
+
# the response contains a list of player creation ratings each object in the list
|
28
|
+
|
29
|
+
service.response do |response|
|
30
|
+
response.element(:name => "player_creation_ratings") do |e|
|
31
|
+
e.attribute :id => :integer, :doc => "id doc"
|
32
|
+
e.attribute :is_accepted => :boolean, :doc => "is accepted doc"
|
33
|
+
e.attribute :name => :string, :doc => "name doc"
|
34
|
+
|
35
|
+
e.array :name => 'player_creation_rating', :type => 'PlayerCreationRating' do |a|
|
36
|
+
a.attribute :comments => :string, :doc => "comments doc"
|
37
|
+
a.attribute :player_id => :integer, :doc => "player_id doc"
|
38
|
+
a.attribute :rating => :integer, :doc => "rating doc"
|
39
|
+
a.attribute :username => :string, :doc => "username doc"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
service.documentation do |doc|
|
45
|
+
# doc.overall <markdown description text>
|
46
|
+
doc.overall <<-DOC
|
47
|
+
This is a test service used to test the framework.
|
48
|
+
DOC
|
49
|
+
|
50
|
+
# doc.params <name>, <definition>
|
51
|
+
doc.param :framework, "The test framework used, could be one of the two following: #{WSDSLSpecOptions.join(", ")}."
|
52
|
+
doc.param :version, "The version of the framework to use."
|
53
|
+
|
54
|
+
# doc.example <markdown text>
|
55
|
+
doc.example <<-DOC
|
56
|
+
The most common way to use this service looks like that:
|
57
|
+
http://example.com/services/test.xml?framework=rspec&version=2.0.0
|
58
|
+
DOC
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
describe_service "services/test_no_params.xml" do |service|
|
64
|
+
service.formats :xml
|
65
|
+
service.http_verb :get
|
66
|
+
service.accept_no_params!
|
67
|
+
end
|
68
|
+
|
69
|
+
describe_service "services.xml" do |service|
|
70
|
+
service.formats :xml
|
71
|
+
service.http_verb :put
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
describe_service "services/array_param.xml" do |s|
|
76
|
+
s.formats :xml
|
77
|
+
s.http_verb :post
|
78
|
+
|
79
|
+
s.params do |p|
|
80
|
+
p.array :seq, :required => true
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path("spec_helper", File.dirname(__FILE__))
|
2
|
+
require 'sinatra'
|
3
|
+
require File.expand_path("./../lib/framework_ext/sinatra.rb", File.dirname(__FILE__))
|
4
|
+
WSDSL.send(:include, WSDSLSinatraExtension)
|
5
|
+
|
6
|
+
describe "Hello World example" do
|
7
|
+
require_relative "hello_world_service"
|
8
|
+
require_relative "hello_world_controller"
|
9
|
+
|
10
|
+
def app
|
11
|
+
Sinatra::Application
|
12
|
+
end
|
13
|
+
|
14
|
+
before(:all) do
|
15
|
+
service = WSList.all.find{|s| s.url == 'hello_world.xml'}
|
16
|
+
service.should_not be_nil
|
17
|
+
service.load_sinatra_route
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should dispatch the hello world service properly" do
|
21
|
+
get "/hello_world.xml"
|
22
|
+
last_response.body.should include("Hello World")
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
data/spec/wsdsl_spec.rb
ADDED
@@ -0,0 +1,222 @@
|
|
1
|
+
require File.expand_path("spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe WSDSL do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@service = WSList.all.find{|s| s.url == 'services/test.xml'}
|
7
|
+
@service.should_not be_nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have an url" do
|
11
|
+
# dummy test since that's how we found the service, but oh well
|
12
|
+
@service.url.should == 'services/test.xml'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have some http verbs defined" do
|
16
|
+
@service.verb.should == :get
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have supported formats defined" do
|
20
|
+
@service.formats.should == [:xml, :json]
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have params info" do
|
24
|
+
@service.params.should be_an_instance_of(WSDSL::Params)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have direct access to the required params" do
|
28
|
+
@service.required_rules.should == @service.params.list_required
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have direct access to the optional params" do
|
32
|
+
@service.optional_rules.should == @service.params.list_optional
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have direct access to the nested params" do
|
36
|
+
@service.nested_params.should == @service.params.namespaced_params
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should set the controller accordingly" do
|
40
|
+
@service.controller_name.should_not be_nil
|
41
|
+
@service.controller_name.should == 'ServicesController'
|
42
|
+
service = WSDSL.new("preferences.xml")
|
43
|
+
service.name.should == 'preferences'
|
44
|
+
ExtlibCopy.classify('preferences').should == 'Preferences'
|
45
|
+
service.controller_name.should == 'PreferencesController'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should set the action accordingly" do
|
49
|
+
@service.action.should_not be_nil
|
50
|
+
@service.action.should == 'test'
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should support restful routes based on the HTTP verb" do
|
54
|
+
service = WSList.all.find{|s| s.url == "services.xml"}
|
55
|
+
service.should_not be_nil
|
56
|
+
service.http_verb.should == :put
|
57
|
+
service.action.should_not be_nil
|
58
|
+
service.controller_name.should == 'ServicesController'
|
59
|
+
service.action.should == 'update'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should have a default action" do
|
63
|
+
service = WSDSL.new('spec_test.xml')
|
64
|
+
service.action.should == 'list'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should route to show when an id is the last passed param" do
|
68
|
+
service = WSDSL.new("players/:id.xml")
|
69
|
+
service.action.should == 'show'
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should support some extra attributes" do
|
73
|
+
service = WSDSL.new("players/:id.xml")
|
74
|
+
service.extra[:custom_name] = 'fooBar'
|
75
|
+
service.extra[:custom_name].should == 'fooBar'
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should respect the global controller pluralization flag" do
|
79
|
+
WSDSL.use_pluralized_controllers = true
|
80
|
+
service = WSDSL.new("player/:id.xml")
|
81
|
+
service.controller_name.should == "PlayersController"
|
82
|
+
service = WSDSL.new("players/:id.xml")
|
83
|
+
service.controller_name.should == "PlayersController"
|
84
|
+
WSDSL.use_pluralized_controllers = false
|
85
|
+
service = WSDSL.new("player/:id.xml")
|
86
|
+
service.controller_name.should == "PlayerController"
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
it "should let overwrite the controller name and action after initialization" do
|
91
|
+
describe_service "players/:id.xml" do |service|
|
92
|
+
service.controller_name = "CustomController"
|
93
|
+
service.action = "foo"
|
94
|
+
end
|
95
|
+
service = WSList.all.find{|s| s.url == "players/:id.xml"}
|
96
|
+
service.controller_name.should == "CustomController"
|
97
|
+
service.action.should == "foo"
|
98
|
+
end
|
99
|
+
|
100
|
+
describe WSDSL::Params do
|
101
|
+
|
102
|
+
before(:all) do
|
103
|
+
@sparams = @service.params
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should have the possibility to have a space name" do
|
107
|
+
@sparams.should respond_to(:space_name)
|
108
|
+
service_params = WSDSL::Params.new(:space_name => 'spec_test')
|
109
|
+
service_params.space_name.should == 'spec_test'
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should have a list of required param rules" do
|
113
|
+
@sparams.list_required.should be_an_instance_of(Array)
|
114
|
+
@sparams.list_required.length.should == 1
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should have a list of optional param rules" do
|
118
|
+
@sparams.list_optional.should be_an_instance_of(Array)
|
119
|
+
@sparams.list_optional.length.should == 4
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should have a list of namespaced param rules" do
|
123
|
+
@sparams.namespaced_params.should be_an_instance_of(Array)
|
124
|
+
@sparams.namespaced_params.length.should == 1
|
125
|
+
@sparams.namespaced_params.first.space_name.should == :user
|
126
|
+
end
|
127
|
+
|
128
|
+
describe WSDSL::Params::Rule do
|
129
|
+
before :all do
|
130
|
+
@rule = @sparams.list_required.first
|
131
|
+
@rule.should_not be_nil
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should have a name" do
|
135
|
+
@rule.name.should == :framework
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should have options" do
|
139
|
+
@rule.options[:type].should == :string
|
140
|
+
@rule.options[:in].should == WSDSLSpecOptions
|
141
|
+
@rule.options[:null].should be_false
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should have some documentation" do
|
148
|
+
@service.doc.should be_an_instance_of(WSDSL::Documentation)
|
149
|
+
end
|
150
|
+
|
151
|
+
describe WSDSL::Documentation do
|
152
|
+
before(:all) do
|
153
|
+
@doc = @service.doc
|
154
|
+
@doc.should_not be_nil
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should have an overall description" do
|
158
|
+
@doc.desc.strip.should == "This is a test service used to test the framework."
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should have a list of params doc" do
|
162
|
+
@doc.params_doc.should be_an_instance_of(Hash)
|
163
|
+
@doc.params_doc.keys.sort.should == [:framework, :version]
|
164
|
+
@doc.params_doc[:framework].should == "The test framework used, could be one of the two following: #{WSDSLSpecOptions.join(", ")}."
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should allow to define namespaced params doc" do
|
168
|
+
service = WSList.all.find{|s| s.url == "services.xml"}
|
169
|
+
service.documentation do |doc|
|
170
|
+
doc.namespace :preference do |ns|
|
171
|
+
ns.param :id, "Ze id."
|
172
|
+
end
|
173
|
+
end
|
174
|
+
service.doc.namespaced_params.should_not be_empty
|
175
|
+
ns = service.doc.namespaced_params.find{|ns| ns.name == :preference}
|
176
|
+
ns.should_not be_nil
|
177
|
+
ns.params[:id].should == "Ze id."
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should have an optional list of examples" do
|
181
|
+
@doc.examples.should be_an_instance_of(Array)
|
182
|
+
@doc.examples.first.should == <<-DOC
|
183
|
+
The most common way to use this service looks like that:
|
184
|
+
http://example.com/services/test.xml?framework=rspec&version=2.0.0
|
185
|
+
DOC
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should have the service response documented" do
|
189
|
+
@doc.response.should_not be_nil
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should have documentation for the response elements via the response itself" do
|
193
|
+
@service.response.elements.first.should_not be_nil
|
194
|
+
@service.response.elements.first.doc.should_not be_nil
|
195
|
+
@service.response.elements.first.doc.name.should == "player_creation_ratings"
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should have documentation for a response element attribute" do
|
199
|
+
@service.response.elements.first.doc.attributes.should_not be_empty
|
200
|
+
@service.response.elements.first.doc.attributes[:id].should == "id doc"
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should have documentation for a response element array" do
|
204
|
+
element = @service.response.elements.first
|
205
|
+
element.arrays.should_not be_empty
|
206
|
+
element.arrays.first.name.should == "player_creation_rating"
|
207
|
+
element.arrays.first.obj_type.should == "PlayerCreationRating"
|
208
|
+
element.arrays.first.attributes.should_not be_empty
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should have documentation for the attributes of an response element array" do
|
212
|
+
element = @service.response.elements.first
|
213
|
+
array = element.arrays.first
|
214
|
+
attribute = array.attributes.find{|att| att.name == :comments }
|
215
|
+
attribute.should_not be_nil
|
216
|
+
attribute.name.should == :comments # just in case we change the way to find the attribute
|
217
|
+
attribute.doc.should == "comments doc"
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
|
222
|
+
end
|
data/wsdsl.gemspec
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{wsdsl}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Matt Aimonetti"]
|
12
|
+
s.date = %q{2011-05-19}
|
13
|
+
s.description = %q{A Ruby DSL describing Web Services without implementation details.}
|
14
|
+
s.email = %q{mattaimonetti@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"LICENSE",
|
21
|
+
"README.md",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"lib/documentation.rb",
|
25
|
+
"lib/framework_ext/sinatra.rb",
|
26
|
+
"lib/framework_ext/sinatra_controller.rb",
|
27
|
+
"lib/inflection.rb",
|
28
|
+
"lib/params.rb",
|
29
|
+
"lib/params_verification.rb",
|
30
|
+
"lib/response.rb",
|
31
|
+
"lib/ws_list.rb",
|
32
|
+
"lib/wsdsl.rb",
|
33
|
+
"wsdsl.gemspec"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/mattetti/wsdsl}
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.3.7}
|
39
|
+
s.summary = %q{Web Service DSL}
|
40
|
+
s.test_files = [
|
41
|
+
"spec/hello_world_controller.rb",
|
42
|
+
"spec/hello_world_service.rb",
|
43
|
+
"spec/params_verification_spec.rb",
|
44
|
+
"spec/preferences_service.rb",
|
45
|
+
"spec/spec_helper.rb",
|
46
|
+
"spec/test_services.rb",
|
47
|
+
"spec/wsdsl_sinatra_ext_spec.rb",
|
48
|
+
"spec/wsdsl_spec.rb"
|
49
|
+
]
|
50
|
+
|
51
|
+
if s.respond_to? :specification_version then
|
52
|
+
s.specification_version = 3
|
53
|
+
|
54
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
+
else
|
56
|
+
end
|
57
|
+
else
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: playerconnect-wsdsl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Team SDOD
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-07-07 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: A Ruby DSL describing Web Services without implementation details.
|
15
|
+
email: sdod@scea.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files:
|
19
|
+
- LICENSE
|
20
|
+
- README.md
|
21
|
+
files:
|
22
|
+
- .rvmrc_example
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- VERSION
|
27
|
+
- lib/documentation.rb
|
28
|
+
- lib/framework_ext/sinatra.rb
|
29
|
+
- lib/framework_ext/sinatra_controller.rb
|
30
|
+
- lib/inflection.rb
|
31
|
+
- lib/params.rb
|
32
|
+
- lib/params_verification.rb
|
33
|
+
- lib/response.rb
|
34
|
+
- lib/ws_list.rb
|
35
|
+
- lib/wsdsl.rb
|
36
|
+
- playerconnect-wsdsl.gemspec
|
37
|
+
- spec/hello_world_controller.rb
|
38
|
+
- spec/hello_world_service.rb
|
39
|
+
- spec/params_verification_spec.rb
|
40
|
+
- spec/preferences_service.rb
|
41
|
+
- spec/spec_helper.rb
|
42
|
+
- spec/test_services.rb
|
43
|
+
- spec/wsdsl_sinatra_ext_spec.rb
|
44
|
+
- spec/wsdsl_spec.rb
|
45
|
+
- wsdsl.gemspec
|
46
|
+
homepage: http://github.com/playerconnect/wsdsl
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.5
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Web Service DSL
|
71
|
+
test_files: []
|