bmizerany-sinatra 0.9.0 → 0.9.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +40 -0
- data/CHANGES +43 -11
- data/README.rdoc +138 -91
- data/Rakefile +7 -1
- data/compat/events_test.rb +10 -7
- data/compat/helper.rb +13 -1
- data/lib/sinatra/base.rb +72 -26
- data/lib/sinatra/compat.rb +142 -44
- data/lib/sinatra/test/bacon.rb +17 -0
- data/lib/sinatra/test/rspec.rb +7 -0
- data/lib/sinatra/test/spec.rb +7 -0
- data/lib/sinatra/test/unit.rb +1 -1
- data/lib/sinatra/test.rb +94 -90
- data/lib/sinatra.rb +5 -0
- data/sinatra.gemspec +7 -3
- data/test/base_test.rb +33 -14
- data/test/builder_test.rb +12 -16
- data/test/erb_test.rb +11 -16
- data/test/filter_test.rb +48 -12
- data/test/haml_test.rb +14 -18
- data/test/helper.rb +25 -0
- data/test/helpers_test.rb +55 -62
- data/test/mapped_error_test.rb +43 -24
- data/test/middleware_test.rb +8 -13
- data/test/options_test.rb +29 -35
- data/test/reload_test.rb +16 -20
- data/test/request_test.rb +12 -5
- data/test/result_test.rb +16 -20
- data/test/routing_test.rb +124 -71
- data/test/sass_test.rb +8 -12
- data/test/sinatra_test.rb +2 -4
- data/test/static_test.rb +16 -19
- data/test/templates_test.rb +23 -19
- metadata +7 -4
data/test/static_test.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
require 'sinatra/base'
|
3
|
-
require 'sinatra/test'
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
4
2
|
|
5
3
|
describe 'Static' do
|
6
|
-
include Sinatra::Test
|
7
4
|
F = ::File
|
8
5
|
|
9
6
|
before do
|
10
|
-
|
7
|
+
mock_app {
|
11
8
|
set :static, true
|
12
9
|
set :public, F.dirname(__FILE__)
|
13
10
|
}
|
@@ -15,46 +12,46 @@ describe 'Static' do
|
|
15
12
|
|
16
13
|
it 'serves GET requests for files in the public directory' do
|
17
14
|
get "/#{F.basename(__FILE__)}"
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
response.headers.
|
15
|
+
assert ok?
|
16
|
+
assert_equal File.read(__FILE__), body
|
17
|
+
assert_equal File.size(__FILE__).to_s, response['Content-Length']
|
18
|
+
assert response.headers.include?('Last-Modified')
|
22
19
|
end
|
23
20
|
|
24
21
|
it 'serves HEAD requests for files in the public directory' do
|
25
22
|
head "/#{F.basename(__FILE__)}"
|
26
|
-
|
27
|
-
body
|
28
|
-
|
29
|
-
response.headers.
|
23
|
+
assert ok?
|
24
|
+
assert_equal '', body
|
25
|
+
assert_equal File.size(__FILE__).to_s, response['Content-Length']
|
26
|
+
assert response.headers.include?('Last-Modified')
|
30
27
|
end
|
31
28
|
|
32
29
|
it 'serves files in preference to custom routes' do
|
33
30
|
@app.get("/#{F.basename(__FILE__)}") { 'Hello World' }
|
34
31
|
get "/#{F.basename(__FILE__)}"
|
35
|
-
|
36
|
-
body
|
32
|
+
assert ok?
|
33
|
+
assert body != 'Hello World'
|
37
34
|
end
|
38
35
|
|
39
36
|
it 'does not serve directories' do
|
40
37
|
get "/"
|
41
|
-
|
38
|
+
assert not_found?
|
42
39
|
end
|
43
40
|
|
44
41
|
it 'passes to the next handler when the static option is disabled' do
|
45
42
|
@app.set :static, false
|
46
43
|
get "/#{F.basename(__FILE__)}"
|
47
|
-
|
44
|
+
assert not_found?
|
48
45
|
end
|
49
46
|
|
50
47
|
it 'passes to the next handler when the public option is nil' do
|
51
48
|
@app.set :public, nil
|
52
49
|
get "/#{F.basename(__FILE__)}"
|
53
|
-
|
50
|
+
assert not_found?
|
54
51
|
end
|
55
52
|
|
56
53
|
it '404s when a file is not found' do
|
57
54
|
get "/foobarbaz.txt"
|
58
|
-
|
55
|
+
assert not_found?
|
59
56
|
end
|
60
57
|
end
|
data/test/templates_test.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require 'sinatra/base'
|
3
|
-
require 'sinatra/test'
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
4
2
|
|
5
3
|
describe 'Templating' do
|
6
|
-
include Sinatra::Test
|
7
|
-
|
8
4
|
def render_app(&block)
|
9
5
|
mock_app {
|
10
6
|
def render_test(template, data, options, &block)
|
@@ -28,48 +24,56 @@ describe 'Templating' do
|
|
28
24
|
|
29
25
|
it 'renders String templates directly' do
|
30
26
|
render_app { render :test, 'Hello World' }
|
31
|
-
|
32
|
-
|
27
|
+
assert ok?
|
28
|
+
assert_equal 'Hello World', body
|
33
29
|
end
|
34
30
|
|
35
31
|
it 'renders Proc templates using the call result' do
|
36
32
|
render_app { render :test, Proc.new {'Hello World'} }
|
37
|
-
|
38
|
-
|
33
|
+
assert ok?
|
34
|
+
assert_equal 'Hello World', body
|
39
35
|
end
|
40
36
|
|
41
37
|
it 'looks up Symbol templates in views directory' do
|
42
38
|
render_app { render :test, :hello }
|
43
|
-
|
44
|
-
|
39
|
+
assert ok?
|
40
|
+
assert_equal "Hello World!\n", body
|
45
41
|
end
|
46
42
|
|
47
43
|
it 'uses the default layout template if not explicitly overridden' do
|
48
44
|
with_default_layout do
|
49
45
|
render_app { render :test, :hello }
|
50
|
-
|
51
|
-
|
46
|
+
assert ok?
|
47
|
+
assert_equal "Layout!\nHello World!\n", body
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'uses the default layout template if not really overriden' do
|
52
|
+
with_default_layout do
|
53
|
+
render_app { render :test, :hello, :layout => true }
|
54
|
+
assert ok?
|
55
|
+
assert_equal "Layout!\nHello World!\n", body
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
55
59
|
it 'uses the layout template specified' do
|
56
60
|
render_app { render :test, :hello, :layout => :layout2 }
|
57
|
-
|
58
|
-
|
61
|
+
assert ok?
|
62
|
+
assert_equal "Layout 2!\nHello World!\n", body
|
59
63
|
end
|
60
64
|
|
61
65
|
it 'uses layout templates defined with the #template method' do
|
62
66
|
render_app { render :test, :hello, :layout => :layout3 }
|
63
|
-
|
64
|
-
|
67
|
+
assert ok?
|
68
|
+
assert_equal "Layout 3!\nHello World!\n", body
|
65
69
|
end
|
66
70
|
|
67
71
|
it 'loads templates from source file with use_in_file_templates!' do
|
68
72
|
mock_app {
|
69
73
|
use_in_file_templates!
|
70
74
|
}
|
71
|
-
|
72
|
-
|
75
|
+
assert_equal "this is foo\n\n", @app.templates[:foo]
|
76
|
+
assert_equal "X\n= yield\nX\n", @app.templates[:layout]
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmizerany-sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.0
|
4
|
+
version: 0.9.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Mizerany
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-18 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -19,10 +19,10 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.9.
|
22
|
+
version: 0.9.1
|
23
23
|
version:
|
24
24
|
description: Classy web-development dressed in a DSL
|
25
|
-
email:
|
25
|
+
email: sinatrarb@googlegroups.com
|
26
26
|
executables: []
|
27
27
|
|
28
28
|
extensions: []
|
@@ -31,6 +31,7 @@ extra_rdoc_files:
|
|
31
31
|
- README.rdoc
|
32
32
|
- LICENSE
|
33
33
|
files:
|
34
|
+
- AUTHORS
|
34
35
|
- CHANGES
|
35
36
|
- LICENSE
|
36
37
|
- README.rdoc
|
@@ -76,6 +77,7 @@ files:
|
|
76
77
|
- lib/sinatra/images/500.png
|
77
78
|
- lib/sinatra/main.rb
|
78
79
|
- lib/sinatra/test.rb
|
80
|
+
- lib/sinatra/test/bacon.rb
|
79
81
|
- lib/sinatra/test/rspec.rb
|
80
82
|
- lib/sinatra/test/spec.rb
|
81
83
|
- lib/sinatra/test/unit.rb
|
@@ -86,6 +88,7 @@ files:
|
|
86
88
|
- test/erb_test.rb
|
87
89
|
- test/filter_test.rb
|
88
90
|
- test/haml_test.rb
|
91
|
+
- test/helper.rb
|
89
92
|
- test/helpers_test.rb
|
90
93
|
- test/mapped_error_test.rb
|
91
94
|
- test/middleware_test.rb
|