dzl 1.0.0.beta0

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.
Files changed (62) hide show
  1. data/.gitignore +6 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +9 -0
  5. data/README.md +44 -0
  6. data/Rakefile +15 -0
  7. data/config.ru +41 -0
  8. data/dzl.gemspec +21 -0
  9. data/lib/dzl/doc/endpoint_doc.rb +70 -0
  10. data/lib/dzl/doc/router_doc.rb +26 -0
  11. data/lib/dzl/doc/task.rb +5 -0
  12. data/lib/dzl/doc/templates/endpoint.erb +55 -0
  13. data/lib/dzl/doc/templates/home.erb +8 -0
  14. data/lib/dzl/doc.rb +58 -0
  15. data/lib/dzl/dsl_proxies/defaults.rb +10 -0
  16. data/lib/dzl/dsl_proxies/endpoint.rb +30 -0
  17. data/lib/dzl/dsl_proxies/parameter.rb +75 -0
  18. data/lib/dzl/dsl_proxies/parameter_block.rb +61 -0
  19. data/lib/dzl/dsl_proxies/protection.rb +6 -0
  20. data/lib/dzl/dsl_proxies/router.rb +62 -0
  21. data/lib/dzl/dsl_proxy.rb +8 -0
  22. data/lib/dzl/dsl_subject.rb +15 -0
  23. data/lib/dzl/dsl_subjects/defaults.rb +12 -0
  24. data/lib/dzl/dsl_subjects/endpoint.rb +79 -0
  25. data/lib/dzl/dsl_subjects/parameter/allowed_values.rb +60 -0
  26. data/lib/dzl/dsl_subjects/parameter/type_conversion.rb +59 -0
  27. data/lib/dzl/dsl_subjects/parameter.rb +100 -0
  28. data/lib/dzl/dsl_subjects/parameter_block.rb +64 -0
  29. data/lib/dzl/dsl_subjects/protection.rb +31 -0
  30. data/lib/dzl/dsl_subjects/router.rb +87 -0
  31. data/lib/dzl/errors.rb +33 -0
  32. data/lib/dzl/examples/base.rb +9 -0
  33. data/lib/dzl/examples/fun_with_handlers.rb +33 -0
  34. data/lib/dzl/examples/fun_with_hooks.rb +65 -0
  35. data/lib/dzl/examples/fun_with_params.rb +71 -0
  36. data/lib/dzl/examples/fun_with_requests.rb +47 -0
  37. data/lib/dzl/examples/route_profile.rb +158 -0
  38. data/lib/dzl/examples/trey.rb +97 -0
  39. data/lib/dzl/logger.rb +65 -0
  40. data/lib/dzl/rack_interface.rb +95 -0
  41. data/lib/dzl/request.rb +54 -0
  42. data/lib/dzl/response_context/request_helpers.rb +11 -0
  43. data/lib/dzl/response_context.rb +47 -0
  44. data/lib/dzl/validator.rb +10 -0
  45. data/lib/dzl/validators/size.rb +32 -0
  46. data/lib/dzl/validators/value.rb +30 -0
  47. data/lib/dzl/value_or_error.rb +32 -0
  48. data/lib/dzl/version.rb +3 -0
  49. data/lib/dzl.rb +96 -0
  50. data/spec/dsl_subject_spec.rb +14 -0
  51. data/spec/endpoint_doc_spec.rb +25 -0
  52. data/spec/fun_with_handlers_spec.rb +37 -0
  53. data/spec/fun_with_hooks_spec.rb +61 -0
  54. data/spec/fun_with_params_spec.rb +197 -0
  55. data/spec/fun_with_requests_spec.rb +101 -0
  56. data/spec/logger_spec.rb +48 -0
  57. data/spec/route_params_spec.rb +13 -0
  58. data/spec/router_doc_spec.rb +32 -0
  59. data/spec/spec_helper.rb +8 -0
  60. data/spec/trey_spec.rb +135 -0
  61. data/spec/value_or_error_spec.rb +44 -0
  62. metadata +142 -0
data/lib/dzl.rb ADDED
@@ -0,0 +1,96 @@
1
+ require 'active_support/core_ext'
2
+ require 'dzl/version'
3
+ require 'dzl/logger'
4
+ require 'dzl/errors'
5
+ require 'dzl/value_or_error'
6
+ require 'dzl/response_context'
7
+ require 'dzl/rack_interface'
8
+ require 'dzl/doc/router_doc'
9
+ require 'dzl/doc/endpoint_doc'
10
+
11
+ require 'dzl/dsl_subject'
12
+
13
+ require 'dzl/dsl_subjects/router'
14
+ require 'dzl/dsl_subjects/parameter'
15
+ require 'dzl/dsl_subjects/protection'
16
+ require 'dzl/dsl_subjects/parameter_block'
17
+ require 'dzl/dsl_subjects/endpoint'
18
+
19
+ module Dzl
20
+ class NYI < StandardError; end
21
+
22
+ def self.included(base)
23
+ unless base.respond_to?(:root)
24
+ raise ArgumentError.new(
25
+ "Please define #{base}.root to return the path to your app"
26
+ )
27
+ end
28
+
29
+ base.extend(RackInterface)
30
+
31
+ class << base
32
+ alias_method :orig_mm, :method_missing
33
+ alias_method :orig_respond_to?, :respond_to?
34
+
35
+ def __router
36
+ @__router ||= Dzl::DSLSubjects::Router.new(self)
37
+ end
38
+
39
+ def __logger
40
+ @__logger ||= begin
41
+ if self.orig_respond_to?(:logger) && self.logger.is_a?(ActiveSupport::BufferedLogger)
42
+ self.logger
43
+ else
44
+ Dzl::Logger.new(self.root)
45
+ end
46
+ end
47
+ end
48
+
49
+ def respond_to?(m)
50
+ orig_respond_to?(m) || (__router && __router.dsl_proxy.respond_to?(m))
51
+ end
52
+
53
+ def method_missing(m, *args, &block)
54
+ if __router.dsl_proxy.respond_to?(m)
55
+ __router.dsl_proxy.send(m, *args, &block)
56
+ elsif m == :logger
57
+ __logger
58
+ else
59
+ orig_mm(m, *args, &block)
60
+ end
61
+ end
62
+
63
+ def to_docs
64
+ app_name = self.name.split('::').last
65
+
66
+ `mkdir -p ./dzl_docs/#{app_name}/`
67
+
68
+ home = File.new("./dzl_docs/#{app_name}/Home.md", "w")
69
+ home.write(__router.to_md(app_name))
70
+ home.close
71
+
72
+ __router.endpoints.each do |endpoint|
73
+ endpoint_page = File.new("./dzl_docs/#{app_name}/#{endpoint.doc_file_name}.md", "w")
74
+ endpoint_page.write(endpoint.to_md)
75
+ endpoint_page.close
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ def self.env
82
+ ENV['RACK_ENV']
83
+ end
84
+
85
+ [:development?, :production?, :staging?, :test?].each do |m|
86
+ define_singleton_method(m) do
87
+ env == m.to_s[0..-2]
88
+ end
89
+ end
90
+
91
+ def self.development?
92
+ true
93
+ end
94
+ end
95
+
96
+ Diesel = Dzl
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dzl::DSLSubject do
4
+ it 'forwards DSL methods to its DSL proxy' do
5
+ Dzl::DSLSubject.any_instance.should_not_receive(:required)
6
+ Dzl::DSLProxies::ParameterBlock.any_instance.should_receive(:required).once
7
+
8
+ class DSLTest < Dzl::Examples::Base
9
+ pblock :foo do
10
+ required :bar
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'dzl/examples/fun_with_params'
3
+ require 'rack/test'
4
+
5
+ def app; Dzl::Examples::FunWithParams; end
6
+
7
+ describe 'endpoint doc functionality' do
8
+ it 'should use a template to generate markdown' do
9
+ File.should_receive(:read).with("./lib/dzl/doc/templates/home.erb").and_return("")
10
+
11
+ app.__router.to_md
12
+ end
13
+
14
+ it 'asks endpoints to generate thier docs' do
15
+ file_mock
16
+ app.__router.endpoints.each do |endpoint|
17
+ endpoint.should_receive(:to_md).and_return("")
18
+ end
19
+
20
+ app.__router.should_receive(:to_md).with("FunWithParams", anything).and_return("")
21
+ app.__router.should_receive(:'`').with(/FunWithParams/).and_return(nil)
22
+
23
+ app.__router.to_docs
24
+ end
25
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require 'rack/test'
3
+ require 'dzl/examples/fun_with_handlers'
4
+
5
+ describe 'handlers' do
6
+ include Rack::Test::Methods
7
+ def app; Dzl::Examples::FunWithHandlers; end
8
+
9
+ it 'have access to parameters and headers' do
10
+ get '/say_bar?baz=no&bam=nope&bar=Hello%2C%20world' do |response|
11
+ response.status.should == 200
12
+ response.body.should == 'Hello, world'
13
+ end
14
+
15
+ get('/say_bar_and_api_key', {bar: 'Hello, world'}, {'HTTP_ApI-keY' => 'open sesame'}) do |response|
16
+ response.status.should == 200
17
+ response['Content-Type'].should == 'application/json'
18
+ JSON.parse(response.body).should == {
19
+ 'bar' => 'Hello, world',
20
+ 'api_key' => 'open sesame'
21
+ }
22
+ end
23
+
24
+ get('/say_bar_and_api_key', {bar: 'whatever'}) do |response|
25
+ response.status.should == 404
26
+ JSON.parse(response.body)['errors']['/say_bar_and_api_key'].should == {
27
+ 'api_key' => 'missing_required_header'
28
+ }
29
+ end
30
+ end
31
+
32
+ it 'can raise exceptions without exploding everything' do
33
+ get '/raise' do |response|
34
+ response.status.should == 500
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+ require 'rack/test'
3
+ require 'dzl/examples/fun_with_hooks'
4
+
5
+ describe 'FunWithHooks' do
6
+ include Rack::Test::Methods
7
+ def app; Dzl::Examples::FunWithHooks; end
8
+
9
+ describe '/pre' do
10
+ it 'only transforms :foo == 1' do
11
+ get('/pre', {foo: 2}) do |response|
12
+ response.status.should == 404
13
+ JSON.parse(response.body)['errors']['/pre']['foo'].should == 'value_validation_failed'
14
+ end
15
+
16
+ get('/pre', {foo: 6}) do |response|
17
+ response.status.should == 200
18
+ end
19
+
20
+ get('/pre', {foo: 1}) do |response|
21
+ response.status.should == 200
22
+ JSON.parse(response.body)['params']['foo'].should == 4
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '/post' do
28
+ it 'can operate on parameters' do
29
+ get('/post?foo=4') do |response|
30
+ JSON.parse(response.body)['params']['foo'].should == 8
31
+ end
32
+ end
33
+ end
34
+
35
+ describe '/multiply' do
36
+ it 'can be used to fudge new parameters' do
37
+ get('/multiply?x=3&y=7') do |response|
38
+ JSON.parse(response.body)['params']['z'].should == 21
39
+ end
40
+ end
41
+
42
+ it 'runs multiple after_validate hooks in order' do
43
+ get('/omg_math?x=2&y=4&z=8&prefix=hello') do |response|
44
+ response.status.should == 200
45
+ params = JSON.parse(response.body)['params']
46
+ params['multiply_then_add'].should == 16
47
+ params['speak'].should == 'hello 16'
48
+ [params['x'], params['y'], params['z']].should == [2, 4, 8]
49
+ end
50
+ end
51
+ end
52
+
53
+ describe 'after validate hooks' do
54
+ it 'are good places to raise Dzl::BadRequest' do
55
+ get('/vomit') do |response|
56
+ response.status.should == 400
57
+ JSON.parse(response.body)['errors'].should == "This isn't quite what I was expecting"
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,197 @@
1
+ require 'spec_helper'
2
+ require 'rack/test'
3
+ require 'dzl/examples/fun_with_params'
4
+
5
+ describe Dzl::Examples::FunWithParams do
6
+ include Rack::Test::Methods
7
+
8
+ def app; Dzl::Examples::FunWithParams; end
9
+
10
+ describe '/foo' do
11
+ describe "understands disallowed values" do
12
+ it "for arrays" do
13
+ all_good = ['ok', 'sweet', 'awesome'].join(' ')
14
+ one_bad = ['zip'].join(' ')
15
+ all_bad = ['zip', 'zilch', 'nada'].join(' ')
16
+ mixed = ['ok', 'sweet', 'nada', 'nice'].join(' ')
17
+
18
+ get('/foo', {foo: all_good}) do |response|
19
+ response.status.should == 200
20
+ end
21
+
22
+ get('/foo', {foo: one_bad}) do |response|
23
+ response.status.should == 404
24
+ JSON.parse(response.body)['errors']['/foo'].should == {
25
+ 'foo' => 'disallowed_values_failed'
26
+ }
27
+ end
28
+
29
+ get('/foo', {foo: all_bad}) do |response|
30
+ response.status.should == 404
31
+ JSON.parse(response.body)['errors']['/foo'].should == {
32
+ 'foo' => 'disallowed_values_failed'
33
+ }
34
+ end
35
+
36
+ get('/foo', {foo: mixed}) do |response|
37
+ response.status.should == 404
38
+ JSON.parse(response.body)['errors']['/foo'].should == {
39
+ 'foo' => 'disallowed_values_failed'
40
+ }
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "required parameters" do
46
+ it "arrays cannot be empty" do
47
+ get('/foo', {foo: ''}) do |response|
48
+ response.status.should == 404
49
+ JSON.parse(response.body)['errors']['/foo'].should == {
50
+ 'foo' => 'empty_required_array'
51
+ }
52
+ end
53
+ end
54
+
55
+ it "strings cannot be empty" do
56
+ get('/bar', {foo: ''}) do |response|
57
+ response.status.should == 404
58
+ JSON.parse(response.body)['errors']['/bar'].should == {
59
+ 'foo' => 'missing_required_param'
60
+ }
61
+ end
62
+ end
63
+ end
64
+
65
+ describe "arbitrary array separator" do
66
+ it "can split arrays on +" do
67
+ ary = %w{one two three}
68
+ bad = ary.join(' ')
69
+ good = ary.join('+')
70
+
71
+ get('/bar', {foo: bad}) do |response|
72
+ response.status.should == 200
73
+ JSON.parse(response.body)['params']['foo'].should == ['one two three']
74
+ end
75
+
76
+ get('/bar', {foo: good}) do |response|
77
+ response.status.should == 200
78
+ JSON.parse(response.body)['params']['foo'].should == ary
79
+ end
80
+ end
81
+ end
82
+
83
+ it "can split arrays on ," do
84
+ ary = %w{one two three}
85
+ bad = ary.join(' ')
86
+ good = ary.join(',')
87
+
88
+ get('/baz', {foo: bad}) do |response|
89
+ response.status.should == 200
90
+ JSON.parse(response.body)['params']['foo'].should == ['one two three']
91
+ end
92
+
93
+ get('/baz', {foo: good}) do |response|
94
+ response.status.should == 200
95
+ JSON.parse(response.body)['params']['foo'].should == ary
96
+ end
97
+ end
98
+ end
99
+
100
+ describe '/foo/:bar (:bar as string)' do
101
+ it 'finds :bar properly' do
102
+ get '/foo/omg' do |response|
103
+ response.status.should == 200
104
+ JSON.parse(response.body)['params']['bar'].should == 'omg'
105
+ end
106
+ end
107
+ end
108
+
109
+ describe '/foo/:bar (:bar as time)' do
110
+ it 'converts :bar to time' do
111
+ get '/foo/2012-01-01' do |response|
112
+ response.status.should == 200
113
+ JSON.parse(response.body)['params']['bar'].should == '2012-01-01T00:00:00-05:00'
114
+ end
115
+ end
116
+ end
117
+
118
+ describe '/protected' do
119
+ it 'should present http basic challenge with no credentials' do
120
+ get '/protected' do |response|
121
+ response.status.should == 401
122
+ end
123
+ end
124
+
125
+ it 'should present the http basic challenge with invalid credentials' do
126
+ authorize('wrong', 'values')
127
+ get '/protected' do |response|
128
+ response.status.should == 401
129
+ end
130
+ end
131
+
132
+ it 'should process normally if credentials are correct' do
133
+ authorize('no', 'way')
134
+ get '/protected' do |response|
135
+ response.status.should == 200
136
+ end
137
+ end
138
+ end
139
+
140
+ describe '/arithmetic' do
141
+ it 'should not allow :int < 5' do
142
+ get('/arithmetic', {int: 4}) do |response|
143
+ response.status.should == 404
144
+ JSON.parse(response.body)['errors']['/arithmetic'].should == {
145
+ 'int' => 'value_validation_failed'
146
+ }
147
+ end
148
+
149
+ get('/arithmetic', {int: 5}) do |response|
150
+ response.status.should == 200
151
+ end
152
+ end
153
+
154
+ it "is called arithmetic but works on strings" do
155
+ get('/arithmetic', {str: 'goodbye'}) do |response|
156
+ response.status.should == 404
157
+ end
158
+
159
+ get('/arithmetic', {str: 'hello'}) do |response|
160
+ response.status.should == 200
161
+ end
162
+ end
163
+
164
+ it "also works on dates" do
165
+ get('/arithmetic', {date: '2011-12-25'}) do |response|
166
+ response.status.should == 404
167
+ end
168
+
169
+ get('/arithmetic', {date: '2012-01-02'}) do |response|
170
+ response.status.should == 200
171
+ end
172
+ end
173
+ end
174
+
175
+ describe '/defaults' do
176
+ it "handles default parameter values correctly" do
177
+ get('/defaults') do |response|
178
+ response.status.should == 200
179
+ JSON.parse(response.body)['params'].should == {
180
+ 'foo' => 'hello',
181
+ 'baz' => 'world',
182
+ 'nil' => nil
183
+ }
184
+ end
185
+
186
+ get('/defaults', {foo: 'world', baz: 'hello', bar: 'not nil', nil: 'not nil'}) do |response|
187
+ response.status.should == 200
188
+ JSON.parse(response.body)['params'].should == {
189
+ 'foo' => 'world',
190
+ 'baz' => 'hello',
191
+ 'bar' => 'not nil',
192
+ 'nil' => 'not nil'
193
+ }
194
+ end
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,101 @@
1
+ require 'spec_helper'
2
+ require 'rack/test'
3
+ require 'dzl/examples/fun_with_requests'
4
+
5
+ describe 'endpoint request method' do
6
+ include Rack::Test::Methods
7
+ def app; Dzl::Examples::FunWithRequests; end
8
+
9
+ it 'defaults to GET' do
10
+ get('/foo') do |response|
11
+ response.status.should == 200
12
+ response.body.should == 'get'
13
+ end
14
+ end
15
+
16
+ it 'allows specification through endpoint options' do
17
+ post('/post_op') do |response|
18
+ response.status.should == 200
19
+ response.body.should == 'post'
20
+ end
21
+
22
+ get('/post_op') do |response|
23
+ response.status.should == 404
24
+ JSON.parse(response.body)['errors']['/post_op'].should == 'request_method_not_supported'
25
+ end
26
+ end
27
+
28
+ it 'allows specification of multiple request methods' do
29
+ post('/multi_op') do |response|
30
+ response.status.should == 200
31
+ response.body.should == 'post'
32
+ end
33
+
34
+ put('/multi_op') do |response|
35
+ response.status.should == 200
36
+ response.body.should == 'put'
37
+ end
38
+
39
+ get('/multi_op') do |response|
40
+ response.status.should == 404
41
+ end
42
+ end
43
+
44
+ describe 'aliases' do
45
+ it 'work as expected' do
46
+ get('/get_only') do |response|
47
+ response.status.should == 200
48
+ end
49
+
50
+ post('/get_only') do |response|
51
+ response.status.should == 404
52
+ end
53
+
54
+ delete('/delete_only') do |response|
55
+ response.status.should == 200
56
+ end
57
+ end
58
+
59
+ it 'allow multiple methods the regular way' do
60
+ get('/get_and_post') do |response|
61
+ response.status.should == 200
62
+ end
63
+
64
+ post('/get_and_post') do |response|
65
+ response.status.should == 200
66
+ end
67
+ end
68
+ end
69
+
70
+ describe 'validating headers' do
71
+ it 'rejects invalid values' do
72
+ get('/validated_header', {}, {'HTTP_KEY' => 'hell'}) do |response|
73
+ response.status.should == 404
74
+ end
75
+ end
76
+
77
+ it 'accepts valid values' do
78
+ get('/validated_header', {}, {'HTTP_KEY' => 'hello'}) do |response|
79
+ response.status.should == 200
80
+ end
81
+ end
82
+ end
83
+
84
+ describe 'ambiguous routes' do
85
+ it 'should respond with the right endpoint' do
86
+ get('/ambiguous', {foo: 'foo'}) do |response|
87
+ response.status.should == 200
88
+ response.body.should == 'foo'
89
+ end
90
+
91
+ get('/ambiguous', {bar: 'bar'}) do |response|
92
+ response.status.should == 200
93
+ response.body.should == 'bar'
94
+ end
95
+
96
+ get('/ambiguous', {baz: 'baz'}) do |response|
97
+ response.status.should == 404
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+ require 'dzl/examples/base'
3
+ require 'rack/test'
4
+
5
+ class LogTestApp < Dzl::Examples::Base
6
+ get '/log_me' do
7
+ required :msg
8
+
9
+ handle do
10
+ logger.success.debug "message is #{params[:msg]}"
11
+ end
12
+ end
13
+ end
14
+
15
+ describe 'Modules including Dzl' do
16
+ it 'should have a logger object provided by Dzl' do
17
+ l = Dzl::Examples::Base.__logger.class.should == Dzl::Logger
18
+ end
19
+
20
+ it 'should use their own logger if it is provided' do
21
+ app = Class.new do
22
+ def self.root
23
+ '/'
24
+ end
25
+
26
+ def self.logger
27
+ @l ||= ActiveSupport::BufferedLogger.new('/dev/null', ::Logger::DEBUG)
28
+ end
29
+
30
+ include Dzl
31
+ end
32
+
33
+ app.__logger.class.should == ActiveSupport::BufferedLogger
34
+ end
35
+ end
36
+
37
+ describe 'LogTestApp' do
38
+ include Rack::Test::Methods
39
+
40
+ def app; LogTestApp; end
41
+
42
+ it 'drops logs' do
43
+ get('/log_me?msg=success')
44
+ last_response.status.should == 200
45
+
46
+ `tail -n 1 #{LogTestApp.root}/log/success.test.log`.match('success').should_not == nil
47
+ end
48
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'route parameters' do
4
+ it 'cannot be set to optional' do
5
+ expect {
6
+ class TestApp1 < Dzl::Examples::Base
7
+ endpoint '/foo/:bar' do
8
+ optional :bar
9
+ end
10
+ end
11
+ }.to raise_error(Dzl::ParameterError)
12
+ end
13
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'dzl/examples/base'
3
+ require 'rack/test'
4
+
5
+ def app; Dzl::Examples::FunWithParams; end
6
+
7
+ def file_mock
8
+ mock_file = mock "File"
9
+ mock_file.stub!(:write).with(anything).and_return(true)
10
+ mock_file.stub!(:close).and_return(true)
11
+ File.stub!(:new).and_return(mock_file)
12
+ end
13
+
14
+ describe 'router doc functionality' do
15
+ it 'should use a template to generate markdown' do
16
+ File.should_receive(:read).with("./lib/dzl/doc/templates/home.erb").and_return("")
17
+
18
+ app.__router.to_md
19
+ end
20
+
21
+ it 'asks endpoints to generate thier docs' do
22
+ file_mock
23
+ app.__router.endpoints.each do |endpoint|
24
+ endpoint.should_receive(:to_md).and_return("")
25
+ end
26
+
27
+ app.__router.should_receive(:to_md).with("FunWithParams", anything).and_return("")
28
+ app.__router.should_receive(:'`').with(/FunWithParams/).and_return(nil)
29
+
30
+ app.__router.to_docs
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ require 'dzl'
3
+
4
+ ENV['RACK_ENV'] ||= 'test'
5
+
6
+ RSpec.configure do |config|
7
+ config.mock_with :rspec
8
+ end