wsdsl 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -56,7 +56,7 @@ module JSONResponseVerification
56
56
  end
57
57
  else
58
58
  node.properties.each do |prop|
59
- if !array_item && !subhash.has_key?(prop.name.to_s)
59
+ if !array_item && !subhash.has_key?(prop.name.to_s) && (prop.opts && prop.respond_to?(:opts) && !prop.opts[:null])
60
60
  errors << json_response_error(prop, subhash)
61
61
  end
62
62
  errors << json_response_error(prop, subhash, true) unless valid_hash_type?(subhash, prop)
data/lib/response.rb CHANGED
@@ -360,7 +360,7 @@ class WSDSL
360
360
  end
361
361
  output << "<ul>"
362
362
  properties.each do |prop|
363
- output << "<li><span class='label notice'>#{prop.name}</span> of type <span class='label success'>#{prop.type}</span> "
363
+ output << "<li><span class='label notice'>#{prop.name}</span> of type <span class='label success'>#{prop.type}</span> #{'(Can be blank or missing) ' if prop.opts && prop.opts.respond_to?(:[]) && prop.opts[:null]} "
364
364
  output << prop.doc unless prop.doc.blank?
365
365
  output << "</li>"
366
366
  end
@@ -63,9 +63,19 @@ describe "JSON response verification" do
63
63
  end
64
64
  end
65
65
 
66
+ @optional_prop_service = describe_service "opt_prop_service" do |service|
67
+ service.response do |response|
68
+ response.object do |obj|
69
+ obj.string :email, :null => true
70
+ obj.integer :city_id, :null => true
71
+ obj.string :full_name, :null => true
72
+ end
73
+ end
74
+ end
66
75
 
67
76
  end
68
77
 
78
+
69
79
  def valid_response(namespaced=true)
70
80
  response = {
71
81
  "id" => 1,
@@ -148,23 +158,22 @@ describe "JSON response verification" do
148
158
 
149
159
  it "should detect that a string attribute value is nil [bug]" do
150
160
  response = valid_response
151
- response["user"]["name"] = nil
152
- # puts response.inspect
153
- valid, errors = @service.validate_hash_response(response)
154
- valid.should be_false
155
- errors.should_not be_empty
156
- errors.first.should match(/name/)
157
- errors.first.should match(/wrong type/)
161
+ response["user"]["name"] = nil
162
+ valid, errors = @service.validate_hash_response(response)
163
+ valid.should be_false
164
+ errors.should_not be_empty
165
+ errors.first.should match(/name/)
166
+ errors.first.should match(/wrong type/)
158
167
  end
159
168
 
160
169
 
161
170
  it "should detect that a nested object is missing" do
162
- response = valid_response
163
- response["user"].delete("creds")
164
- valid, errors = @service.validate_hash_response(response)
165
- valid.should be_false
166
- errors.first.should match(/creds/)
167
- errors.first.should match(/missing/)
171
+ response = valid_response
172
+ response["user"].delete("creds")
173
+ valid, errors = @service.validate_hash_response(response)
174
+ valid.should be_false
175
+ errors.first.should match(/creds/)
176
+ errors.first.should match(/missing/)
168
177
  end
169
178
 
170
179
  it "should validate non namespaced responses" do
@@ -207,4 +216,10 @@ describe "JSON response verification" do
207
216
  end
208
217
 
209
218
 
219
+ it "should respect optional properties" do
220
+ valid, errors = @optional_prop_service.validate_hash_response({})
221
+ valid.should be_true
222
+ end
223
+
224
+
210
225
  end
data/wsdsl.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "wsdsl"
8
- s.version = "0.5.1"
8
+ s.version = "0.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Aimonetti"]
12
- s.date = "2012-01-12"
12
+ s.date = "2012-02-25"
13
13
  s.description = "A Ruby DSL describing Web Services without implementation details."
14
14
  s.email = "mattaimonetti@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wsdsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-12 00:00:00.000000000 Z
12
+ date: 2012-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jeweler
16
- requirement: &70320885201320 !ruby/object:Gem::Requirement
16
+ requirement: &70096349076000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70320885201320
24
+ version_requirements: *70096349076000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70320885200840 !ruby/object:Gem::Requirement
27
+ requirement: &70096349075520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70320885200840
35
+ version_requirements: *70096349075520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rack-test
38
- requirement: &70320885200360 !ruby/object:Gem::Requirement
38
+ requirement: &70096349075040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70320885200360
46
+ version_requirements: *70096349075040
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sinatra
49
- requirement: &70320885199880 !ruby/object:Gem::Requirement
49
+ requirement: &70096349074560 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70320885199880
57
+ version_requirements: *70096349074560
58
58
  description: A Ruby DSL describing Web Services without implementation details.
59
59
  email: mattaimonetti@gmail.com
60
60
  executables: []