sinatra-bundles 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/lib/sinatra/bundles/bundle.rb +36 -0
- data/lib/sinatra/bundles/helpers.rb +22 -0
- data/lib/sinatra/bundles/javascript_bundle.rb +37 -0
- data/lib/sinatra/bundles/stylesheet_bundle.rb +36 -0
- data/lib/sinatra/bundles.rb +4 -114
- data/sinatra-bundles.gemspec +11 -58
- data/spec/app.rb +1 -1
- data/spec/production_app.rb +1 -1
- data/spec/public/javascripts/eval.js +5 -0
- data/spec/sinatra-bundles_spec.rb +10 -1
- data/spec/spec_helper.rb +5 -6
- metadata +17 -57
- data/vendor/cache/sinatra-0.10.1.gem +0 -0
- data/vendor/gems/sinatra-0.10.1/AUTHORS +0 -43
- data/vendor/gems/sinatra-0.10.1/CHANGES +0 -467
- data/vendor/gems/sinatra-0.10.1/LICENSE +0 -22
- data/vendor/gems/sinatra-0.10.1/README.jp.rdoc +0 -552
- data/vendor/gems/sinatra-0.10.1/README.rdoc +0 -622
- data/vendor/gems/sinatra-0.10.1/Rakefile +0 -129
- data/vendor/gems/sinatra-0.10.1/lib/sinatra/base.rb +0 -1143
- data/vendor/gems/sinatra-0.10.1/lib/sinatra/images/404.png +0 -0
- data/vendor/gems/sinatra-0.10.1/lib/sinatra/images/500.png +0 -0
- data/vendor/gems/sinatra-0.10.1/lib/sinatra/main.rb +0 -28
- data/vendor/gems/sinatra-0.10.1/lib/sinatra/showexceptions.rb +0 -303
- data/vendor/gems/sinatra-0.10.1/lib/sinatra/tilt.rb +0 -509
- data/vendor/gems/sinatra-0.10.1/lib/sinatra.rb +0 -7
- data/vendor/gems/sinatra-0.10.1/sinatra.gemspec +0 -86
- data/vendor/gems/sinatra-0.10.1/test/base_test.rb +0 -160
- data/vendor/gems/sinatra-0.10.1/test/builder_test.rb +0 -65
- data/vendor/gems/sinatra-0.10.1/test/contest.rb +0 -64
- data/vendor/gems/sinatra-0.10.1/test/erb_test.rb +0 -81
- data/vendor/gems/sinatra-0.10.1/test/erubis_test.rb +0 -82
- data/vendor/gems/sinatra-0.10.1/test/extensions_test.rb +0 -100
- data/vendor/gems/sinatra-0.10.1/test/filter_test.rb +0 -195
- data/vendor/gems/sinatra-0.10.1/test/haml_test.rb +0 -90
- data/vendor/gems/sinatra-0.10.1/test/helper.rb +0 -76
- data/vendor/gems/sinatra-0.10.1/test/helpers_test.rb +0 -573
- data/vendor/gems/sinatra-0.10.1/test/mapped_error_test.rb +0 -186
- data/vendor/gems/sinatra-0.10.1/test/middleware_test.rb +0 -68
- data/vendor/gems/sinatra-0.10.1/test/request_test.rb +0 -33
- data/vendor/gems/sinatra-0.10.1/test/response_test.rb +0 -42
- data/vendor/gems/sinatra-0.10.1/test/result_test.rb +0 -98
- data/vendor/gems/sinatra-0.10.1/test/route_added_hook_test.rb +0 -59
- data/vendor/gems/sinatra-0.10.1/test/routing_test.rb +0 -878
- data/vendor/gems/sinatra-0.10.1/test/sass_test.rb +0 -79
- data/vendor/gems/sinatra-0.10.1/test/server_test.rb +0 -47
- data/vendor/gems/sinatra-0.10.1/test/sinatra_test.rb +0 -13
- data/vendor/gems/sinatra-0.10.1/test/static_test.rb +0 -87
- data/vendor/gems/sinatra-0.10.1/test/templates_test.rb +0 -155
- data/vendor/gems/sinatra-0.10.1/test/views/error.builder +0 -3
- data/vendor/gems/sinatra-0.10.1/test/views/error.erb +0 -3
- data/vendor/gems/sinatra-0.10.1/test/views/error.erubis +0 -3
- data/vendor/gems/sinatra-0.10.1/test/views/error.haml +0 -3
- data/vendor/gems/sinatra-0.10.1/test/views/error.sass +0 -2
- data/vendor/gems/sinatra-0.10.1/test/views/foo/hello.test +0 -1
- data/vendor/gems/sinatra-0.10.1/test/views/hello.builder +0 -1
- data/vendor/gems/sinatra-0.10.1/test/views/hello.erb +0 -1
- data/vendor/gems/sinatra-0.10.1/test/views/hello.erubis +0 -1
- data/vendor/gems/sinatra-0.10.1/test/views/hello.haml +0 -1
- data/vendor/gems/sinatra-0.10.1/test/views/hello.sass +0 -2
- data/vendor/gems/sinatra-0.10.1/test/views/hello.test +0 -1
- data/vendor/gems/sinatra-0.10.1/test/views/layout2.builder +0 -3
- data/vendor/gems/sinatra-0.10.1/test/views/layout2.erb +0 -2
- data/vendor/gems/sinatra-0.10.1/test/views/layout2.erubis +0 -2
- data/vendor/gems/sinatra-0.10.1/test/views/layout2.haml +0 -2
- data/vendor/gems/sinatra-0.10.1/test/views/layout2.test +0 -1
- data/vendor/specifications/sinatra-0.10.1.gemspec +0 -40
@@ -1,186 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
class FooError < RuntimeError
|
4
|
-
end
|
5
|
-
|
6
|
-
class FooNotFound < Sinatra::NotFound
|
7
|
-
end
|
8
|
-
|
9
|
-
class MappedErrorTest < Test::Unit::TestCase
|
10
|
-
def test_default
|
11
|
-
assert true
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'Exception Mappings' do
|
15
|
-
it 'invokes handlers registered with ::error when raised' do
|
16
|
-
mock_app {
|
17
|
-
set :raise_errors, false
|
18
|
-
error(FooError) { 'Foo!' }
|
19
|
-
get '/' do
|
20
|
-
raise FooError
|
21
|
-
end
|
22
|
-
}
|
23
|
-
get '/'
|
24
|
-
assert_equal 500, status
|
25
|
-
assert_equal 'Foo!', body
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'uses the Exception handler if no matching handler found' do
|
29
|
-
mock_app {
|
30
|
-
set :raise_errors, false
|
31
|
-
error(Exception) { 'Exception!' }
|
32
|
-
get '/' do
|
33
|
-
raise FooError
|
34
|
-
end
|
35
|
-
}
|
36
|
-
|
37
|
-
get '/'
|
38
|
-
assert_equal 500, status
|
39
|
-
assert_equal 'Exception!', body
|
40
|
-
end
|
41
|
-
|
42
|
-
it "sets env['sinatra.error'] to the rescued exception" do
|
43
|
-
mock_app {
|
44
|
-
set :raise_errors, false
|
45
|
-
error(FooError) {
|
46
|
-
assert env.include?('sinatra.error')
|
47
|
-
assert env['sinatra.error'].kind_of?(FooError)
|
48
|
-
'looks good'
|
49
|
-
}
|
50
|
-
get '/' do
|
51
|
-
raise FooError
|
52
|
-
end
|
53
|
-
}
|
54
|
-
get '/'
|
55
|
-
assert_equal 'looks good', body
|
56
|
-
end
|
57
|
-
|
58
|
-
it "raises without calling the handler when the raise_errors options is set" do
|
59
|
-
mock_app {
|
60
|
-
set :raise_errors, true
|
61
|
-
error(FooError) { "she's not there." }
|
62
|
-
get '/' do
|
63
|
-
raise FooError
|
64
|
-
end
|
65
|
-
}
|
66
|
-
assert_raise(FooError) { get '/' }
|
67
|
-
end
|
68
|
-
|
69
|
-
it "never raises Sinatra::NotFound beyond the application" do
|
70
|
-
mock_app {
|
71
|
-
set :raise_errors, true
|
72
|
-
get '/' do
|
73
|
-
raise Sinatra::NotFound
|
74
|
-
end
|
75
|
-
}
|
76
|
-
assert_nothing_raised { get '/' }
|
77
|
-
assert_equal 404, status
|
78
|
-
end
|
79
|
-
|
80
|
-
it "cascades for subclasses of Sinatra::NotFound" do
|
81
|
-
mock_app {
|
82
|
-
set :raise_errors, true
|
83
|
-
error(FooNotFound) { "foo! not found." }
|
84
|
-
get '/' do
|
85
|
-
raise FooNotFound
|
86
|
-
end
|
87
|
-
}
|
88
|
-
assert_nothing_raised { get '/' }
|
89
|
-
assert_equal 404, status
|
90
|
-
assert_equal 'foo! not found.', body
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'has a not_found method for backwards compatibility' do
|
94
|
-
mock_app {
|
95
|
-
not_found do
|
96
|
-
"Lost, are we?"
|
97
|
-
end
|
98
|
-
}
|
99
|
-
|
100
|
-
get '/test'
|
101
|
-
assert_equal 404, status
|
102
|
-
assert_equal "Lost, are we?", body
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'inherits error mappings from base class' do
|
106
|
-
base = Class.new(Sinatra::Base)
|
107
|
-
base.error(FooError) { 'base class' }
|
108
|
-
|
109
|
-
mock_app(base) {
|
110
|
-
set :raise_errors, false
|
111
|
-
get '/' do
|
112
|
-
raise FooError
|
113
|
-
end
|
114
|
-
}
|
115
|
-
|
116
|
-
get '/'
|
117
|
-
assert_equal 'base class', body
|
118
|
-
end
|
119
|
-
|
120
|
-
it 'overrides error mappings in base class' do
|
121
|
-
base = Class.new(Sinatra::Base)
|
122
|
-
base.error(FooError) { 'base class' }
|
123
|
-
|
124
|
-
mock_app(base) {
|
125
|
-
set :raise_errors, false
|
126
|
-
error(FooError) { 'subclass' }
|
127
|
-
get '/' do
|
128
|
-
raise FooError
|
129
|
-
end
|
130
|
-
}
|
131
|
-
|
132
|
-
get '/'
|
133
|
-
assert_equal 'subclass', body
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe 'Custom Error Pages' do
|
138
|
-
it 'allows numeric status code mappings to be registered with ::error' do
|
139
|
-
mock_app {
|
140
|
-
set :raise_errors, false
|
141
|
-
error(500) { 'Foo!' }
|
142
|
-
get '/' do
|
143
|
-
[500, {}, 'Internal Foo Error']
|
144
|
-
end
|
145
|
-
}
|
146
|
-
get '/'
|
147
|
-
assert_equal 500, status
|
148
|
-
assert_equal 'Foo!', body
|
149
|
-
end
|
150
|
-
|
151
|
-
it 'allows ranges of status code mappings to be registered with :error' do
|
152
|
-
mock_app {
|
153
|
-
set :raise_errors, false
|
154
|
-
error(500..550) { "Error: #{response.status}" }
|
155
|
-
get '/' do
|
156
|
-
[507, {}, 'A very special error']
|
157
|
-
end
|
158
|
-
}
|
159
|
-
get '/'
|
160
|
-
assert_equal 507, status
|
161
|
-
assert_equal 'Error: 507', body
|
162
|
-
end
|
163
|
-
|
164
|
-
class FooError < RuntimeError
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'runs after exception mappings and overwrites body' do
|
168
|
-
mock_app {
|
169
|
-
set :raise_errors, false
|
170
|
-
error FooError do
|
171
|
-
response.status = 502
|
172
|
-
'from exception mapping'
|
173
|
-
end
|
174
|
-
error(500) { 'from 500 handler' }
|
175
|
-
error(502) { 'from custom error page' }
|
176
|
-
|
177
|
-
get '/' do
|
178
|
-
raise FooError
|
179
|
-
end
|
180
|
-
}
|
181
|
-
get '/'
|
182
|
-
assert_equal 502, status
|
183
|
-
assert_equal 'from custom error page', body
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
class MiddlewareTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@app = mock_app(Sinatra::Application) {
|
6
|
-
get '/*' do
|
7
|
-
response.headers['X-Tests'] = env['test.ran'].
|
8
|
-
map { |n| n.split('::').last }.
|
9
|
-
join(', ')
|
10
|
-
env['PATH_INFO']
|
11
|
-
end
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
class MockMiddleware < Struct.new(:app)
|
16
|
-
def call(env)
|
17
|
-
(env['test.ran'] ||= []) << self.class.to_s
|
18
|
-
app.call(env)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class UpcaseMiddleware < MockMiddleware
|
23
|
-
def call(env)
|
24
|
-
env['PATH_INFO'] = env['PATH_INFO'].upcase
|
25
|
-
super
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "is added with Sinatra::Application.use" do
|
30
|
-
@app.use UpcaseMiddleware
|
31
|
-
get '/hello-world'
|
32
|
-
assert ok?
|
33
|
-
assert_equal '/HELLO-WORLD', body
|
34
|
-
end
|
35
|
-
|
36
|
-
class DowncaseMiddleware < MockMiddleware
|
37
|
-
def call(env)
|
38
|
-
env['PATH_INFO'] = env['PATH_INFO'].downcase
|
39
|
-
super
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
it "runs in the order defined" do
|
44
|
-
@app.use UpcaseMiddleware
|
45
|
-
@app.use DowncaseMiddleware
|
46
|
-
get '/Foo'
|
47
|
-
assert_equal "/foo", body
|
48
|
-
assert_equal "UpcaseMiddleware, DowncaseMiddleware", response['X-Tests']
|
49
|
-
end
|
50
|
-
|
51
|
-
it "resets the prebuilt pipeline when new middleware is added" do
|
52
|
-
@app.use UpcaseMiddleware
|
53
|
-
get '/Foo'
|
54
|
-
assert_equal "/FOO", body
|
55
|
-
@app.use DowncaseMiddleware
|
56
|
-
get '/Foo'
|
57
|
-
assert_equal '/foo', body
|
58
|
-
assert_equal "UpcaseMiddleware, DowncaseMiddleware", response['X-Tests']
|
59
|
-
end
|
60
|
-
|
61
|
-
it "works when app is used as middleware" do
|
62
|
-
@app.use UpcaseMiddleware
|
63
|
-
@app = @app.new
|
64
|
-
get '/Foo'
|
65
|
-
assert_equal "/FOO", body
|
66
|
-
assert_equal "UpcaseMiddleware", response['X-Tests']
|
67
|
-
end
|
68
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
class RequestTest < Test::Unit::TestCase
|
4
|
-
it 'responds to #user_agent' do
|
5
|
-
request = Sinatra::Request.new({'HTTP_USER_AGENT' => 'Test'})
|
6
|
-
assert request.respond_to?(:user_agent)
|
7
|
-
assert_equal 'Test', request.user_agent
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'parses POST params when Content-Type is form-dataish' do
|
11
|
-
request = Sinatra::Request.new(
|
12
|
-
'REQUEST_METHOD' => 'PUT',
|
13
|
-
'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
|
14
|
-
'rack.input' => StringIO.new('foo=bar')
|
15
|
-
)
|
16
|
-
assert_equal 'bar', request.params['foo']
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'is secure when the url scheme is https' do
|
20
|
-
request = Sinatra::Request.new('rack.url_scheme' => 'https')
|
21
|
-
assert request.secure?
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'is not secure when the url scheme is http' do
|
25
|
-
request = Sinatra::Request.new('rack.url_scheme' => 'http')
|
26
|
-
assert !request.secure?
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'respects X-Forwarded-Proto header for proxied SSL' do
|
30
|
-
request = Sinatra::Request.new('HTTP_X_FORWARDED_PROTO' => 'https')
|
31
|
-
assert request.secure?
|
32
|
-
end
|
33
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/helper'
|
4
|
-
|
5
|
-
class ResponseTest < Test::Unit::TestCase
|
6
|
-
setup do
|
7
|
-
@response = Sinatra::Response.new
|
8
|
-
end
|
9
|
-
|
10
|
-
it "initializes with 200, text/html, and empty body" do
|
11
|
-
assert_equal 200, @response.status
|
12
|
-
assert_equal 'text/html', @response['Content-Type']
|
13
|
-
assert_equal [], @response.body
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'uses case insensitive headers' do
|
17
|
-
@response['content-type'] = 'application/foo'
|
18
|
-
assert_equal 'application/foo', @response['Content-Type']
|
19
|
-
assert_equal 'application/foo', @response['CONTENT-TYPE']
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'writes to body' do
|
23
|
-
@response.body = 'Hello'
|
24
|
-
@response.write ' World'
|
25
|
-
assert_equal 'Hello World', @response.body
|
26
|
-
end
|
27
|
-
|
28
|
-
[204, 304].each do |status_code|
|
29
|
-
it "removes the Content-Type header and body when response status is #{status_code}" do
|
30
|
-
@response.status = status_code
|
31
|
-
@response.body = ['Hello World']
|
32
|
-
assert_equal [status_code, {}, []], @response.finish
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'Calculates the Content-Length using the bytesize of the body' do
|
37
|
-
@response.body = ['Hello', 'World!', '✈']
|
38
|
-
status, headers, body = @response.finish
|
39
|
-
assert_equal '14', headers['Content-Length']
|
40
|
-
assert_equal @response.body, body
|
41
|
-
end
|
42
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
class ResultTest < Test::Unit::TestCase
|
4
|
-
it "sets response.body when result is a String" do
|
5
|
-
mock_app {
|
6
|
-
get '/' do
|
7
|
-
'Hello World'
|
8
|
-
end
|
9
|
-
}
|
10
|
-
|
11
|
-
get '/'
|
12
|
-
assert ok?
|
13
|
-
assert_equal 'Hello World', body
|
14
|
-
end
|
15
|
-
|
16
|
-
it "sets response.body when result is an Array of Strings" do
|
17
|
-
mock_app {
|
18
|
-
get '/' do
|
19
|
-
['Hello', 'World']
|
20
|
-
end
|
21
|
-
}
|
22
|
-
|
23
|
-
get '/'
|
24
|
-
assert ok?
|
25
|
-
assert_equal 'HelloWorld', body
|
26
|
-
end
|
27
|
-
|
28
|
-
it "sets response.body when result responds to #each" do
|
29
|
-
mock_app {
|
30
|
-
get '/' do
|
31
|
-
res = lambda { 'Hello World' }
|
32
|
-
def res.each ; yield call ; end
|
33
|
-
res
|
34
|
-
end
|
35
|
-
}
|
36
|
-
|
37
|
-
get '/'
|
38
|
-
assert ok?
|
39
|
-
assert_equal 'Hello World', body
|
40
|
-
end
|
41
|
-
|
42
|
-
it "sets response.body to [] when result is nil" do
|
43
|
-
mock_app {
|
44
|
-
get '/' do
|
45
|
-
nil
|
46
|
-
end
|
47
|
-
}
|
48
|
-
|
49
|
-
get '/'
|
50
|
-
assert ok?
|
51
|
-
assert_equal '', body
|
52
|
-
end
|
53
|
-
|
54
|
-
it "sets status, headers, and body when result is a Rack response tuple" do
|
55
|
-
mock_app {
|
56
|
-
get '/' do
|
57
|
-
[205, {'Content-Type' => 'foo/bar'}, 'Hello World']
|
58
|
-
end
|
59
|
-
}
|
60
|
-
|
61
|
-
get '/'
|
62
|
-
assert_equal 205, status
|
63
|
-
assert_equal 'foo/bar', response['Content-Type']
|
64
|
-
assert_equal 'Hello World', body
|
65
|
-
end
|
66
|
-
|
67
|
-
it "sets status and body when result is a two-tuple" do
|
68
|
-
mock_app {
|
69
|
-
get '/' do
|
70
|
-
[409, 'formula of']
|
71
|
-
end
|
72
|
-
}
|
73
|
-
|
74
|
-
get '/'
|
75
|
-
assert_equal 409, status
|
76
|
-
assert_equal 'formula of', body
|
77
|
-
end
|
78
|
-
|
79
|
-
it "raises a TypeError when result is a non two or three tuple Array" do
|
80
|
-
mock_app {
|
81
|
-
get '/' do
|
82
|
-
[409, 'formula of', 'something else', 'even more']
|
83
|
-
end
|
84
|
-
}
|
85
|
-
|
86
|
-
assert_raise(TypeError) { get '/' }
|
87
|
-
end
|
88
|
-
|
89
|
-
it "sets status when result is a Fixnum status code" do
|
90
|
-
mock_app {
|
91
|
-
get('/') { 205 }
|
92
|
-
}
|
93
|
-
|
94
|
-
get '/'
|
95
|
-
assert_equal 205, status
|
96
|
-
assert_equal '', body
|
97
|
-
end
|
98
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
module RouteAddedTest
|
4
|
-
@routes, @procs = [], []
|
5
|
-
def self.routes ; @routes ; end
|
6
|
-
def self.procs ; @procs ; end
|
7
|
-
def self.route_added(verb, path, proc)
|
8
|
-
@routes << [verb, path]
|
9
|
-
@procs << proc
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class RouteAddedHookTest < Test::Unit::TestCase
|
14
|
-
setup {
|
15
|
-
RouteAddedTest.routes.clear
|
16
|
-
RouteAddedTest.procs.clear
|
17
|
-
}
|
18
|
-
|
19
|
-
it "should be notified of an added route" do
|
20
|
-
mock_app(Class.new(Sinatra::Base)) {
|
21
|
-
register RouteAddedTest
|
22
|
-
get('/') {}
|
23
|
-
}
|
24
|
-
|
25
|
-
assert_equal [["GET", "/"], ["HEAD", "/"]],
|
26
|
-
RouteAddedTest.routes
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should include hooks from superclass" do
|
30
|
-
a = Class.new(Class.new(Sinatra::Base))
|
31
|
-
b = Class.new(a)
|
32
|
-
|
33
|
-
a.register RouteAddedTest
|
34
|
-
b.class_eval { post("/sub_app_route") {} }
|
35
|
-
|
36
|
-
assert_equal [["POST", "/sub_app_route"]],
|
37
|
-
RouteAddedTest.routes
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should only run once per extension" do
|
41
|
-
mock_app(Class.new(Sinatra::Base)) {
|
42
|
-
register RouteAddedTest
|
43
|
-
register RouteAddedTest
|
44
|
-
get('/') {}
|
45
|
-
}
|
46
|
-
|
47
|
-
assert_equal [["GET", "/"], ["HEAD", "/"]],
|
48
|
-
RouteAddedTest.routes
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should pass route blocks as an argument" do
|
52
|
-
mock_app(Class.new(Sinatra::Base)) {
|
53
|
-
register RouteAddedTest
|
54
|
-
get('/') {}
|
55
|
-
}
|
56
|
-
|
57
|
-
assert_kind_of Proc, RouteAddedTest.procs.first
|
58
|
-
end
|
59
|
-
end
|