dzl 1.0.0.rc5 → 1.0.0.rc6
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/lib/dzl/errors.rb +1 -0
- data/lib/dzl/examples/fun_with_handlers.rb +9 -0
- data/lib/dzl/examples/fun_with_hooks.rb +6 -0
- data/lib/dzl/rack_interface.rb +2 -2
- data/lib/dzl/response_context.rb +8 -0
- data/lib/dzl/version.rb +1 -1
- data/spec/fun_with_handlers_spec.rb +10 -0
- data/spec/fun_with_hooks_spec.rb +10 -0
- metadata +5 -5
data/lib/dzl/errors.rb
CHANGED
@@ -62,4 +62,10 @@ class Dzl::Examples::FunWithHooks < Dzl::Examples::Base
|
|
62
62
|
raise Dzl::BadRequest.new("This isn't quite what I was expecting")
|
63
63
|
end
|
64
64
|
end
|
65
|
+
|
66
|
+
endpoint '/validation_error' do
|
67
|
+
after_validate do
|
68
|
+
raise Dzl::ValidationError.new(any: 'hash', i: 'want')
|
69
|
+
end
|
70
|
+
end
|
65
71
|
end
|
data/lib/dzl/rack_interface.rb
CHANGED
@@ -63,8 +63,8 @@ module Dzl::RackInterface
|
|
63
63
|
response = Rack::Response.new
|
64
64
|
response.headers['Content-Type'] = 'application/json'
|
65
65
|
|
66
|
-
if e.is_a?(Dzl::
|
67
|
-
response.status =
|
66
|
+
if e.is_a?(Dzl::ValidationError)
|
67
|
+
response.status = 404
|
68
68
|
response.write(e.to_json)
|
69
69
|
else
|
70
70
|
response.status = e.status
|
data/lib/dzl/response_context.rb
CHANGED
data/lib/dzl/version.rb
CHANGED
@@ -34,4 +34,14 @@ describe 'handlers' do
|
|
34
34
|
response.status.should == 500
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
it 'are good places to raise Dzl::ValidationError' do
|
39
|
+
get '/validation_error' do |response|
|
40
|
+
response.status.should == 404
|
41
|
+
JSON.parse(response.body)['errors']['/validation_error'].should == {
|
42
|
+
'any' => 'hash',
|
43
|
+
'i' => 'want'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
37
47
|
end
|
data/spec/fun_with_hooks_spec.rb
CHANGED
@@ -57,5 +57,15 @@ describe 'FunWithHooks' do
|
|
57
57
|
JSON.parse(response.body)['errors'].should == "This isn't quite what I was expecting"
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
it 'are good places to raise Dzl::ValidationError' do
|
62
|
+
get('/validation_error') do |response|
|
63
|
+
response.status.should == 404
|
64
|
+
JSON.parse(response.body)['errors']['/validation_error'].should == {
|
65
|
+
'any' => 'hash',
|
66
|
+
'i' => 'want'
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
60
70
|
end
|
61
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dzl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc6
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ date: 2012-04-18 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
17
|
-
requirement: &
|
17
|
+
requirement: &70264021734620 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 1.4.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70264021734620
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activesupport
|
28
|
-
requirement: &
|
28
|
+
requirement: &70264021734100 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 3.2.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70264021734100
|
37
37
|
description: Small, fast racktivesupport web framework with handy DSL and explicit
|
38
38
|
parameter validation.
|
39
39
|
email:
|