Syd-sinatra 0.3.2 → 0.9.0.2
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/AUTHORS +40 -0
- data/CHANGES +189 -0
- data/README.rdoc +148 -119
- data/Rakefile +34 -10
- data/{test → compat}/app_test.rb +11 -10
- data/{test → compat}/application_test.rb +21 -5
- data/compat/builder_test.rb +101 -0
- data/compat/erb_test.rb +136 -0
- data/{test → compat}/events_test.rb +16 -3
- data/compat/filter_test.rb +30 -0
- data/compat/haml_test.rb +233 -0
- data/compat/helper.rb +30 -0
- data/compat/mapped_error_test.rb +72 -0
- data/{test → compat}/pipeline_test.rb +9 -4
- data/compat/sass_test.rb +57 -0
- data/{test → compat}/streaming_test.rb +4 -1
- data/lib/sinatra/base.rb +843 -0
- data/lib/sinatra/compat.rb +239 -0
- data/lib/sinatra/main.rb +48 -0
- data/lib/sinatra/test/bacon.rb +17 -0
- data/lib/sinatra/test/rspec.rb +7 -8
- data/lib/sinatra/test/spec.rb +3 -4
- data/lib/sinatra/test/unit.rb +3 -5
- data/lib/sinatra/test.rb +114 -0
- data/lib/sinatra.rb +6 -1468
- data/sinatra.gemspec +68 -35
- data/test/base_test.rb +68 -0
- data/test/builder_test.rb +50 -87
- data/test/data/reload_app_file.rb +3 -0
- data/test/erb_test.rb +38 -124
- data/test/filter_test.rb +65 -20
- data/test/haml_test.rb +51 -216
- data/test/helper.rb +23 -5
- data/test/helpers_test.rb +361 -0
- data/test/mapped_error_test.rb +137 -49
- data/test/middleware_test.rb +58 -0
- data/test/options_test.rb +97 -0
- data/test/reload_test.rb +61 -0
- data/test/request_test.rb +18 -0
- data/test/result_test.rb +88 -0
- data/test/routing_test.rb +391 -0
- data/test/sass_test.rb +27 -48
- data/test/sinatra_test.rb +13 -0
- data/test/static_test.rb +57 -0
- data/test/templates_test.rb +88 -0
- data/test/views/hello.builder +1 -0
- data/test/views/hello.erb +1 -0
- data/test/views/hello.haml +1 -0
- data/test/views/hello.sass +2 -0
- data/test/views/hello.test +1 -0
- data/test/views/layout2.builder +3 -0
- data/test/views/layout2.erb +2 -0
- data/test/views/layout2.haml +2 -0
- data/test/views/layout2.test +1 -0
- metadata +79 -47
- data/ChangeLog +0 -78
- data/lib/sinatra/test/methods.rb +0 -76
- data/test/event_context_test.rb +0 -15
- /data/{test → compat}/custom_error_test.rb +0 -0
- /data/{test → compat}/public/foo.xml +0 -0
- /data/{test → compat}/sessions_test.rb +0 -0
- /data/{test → compat}/sym_params_test.rb +0 -0
- /data/{test → compat}/template_test.rb +0 -0
- /data/{test → compat}/use_in_file_templates_test.rb +0 -0
- /data/{test → compat}/views/foo.builder +0 -0
- /data/{test → compat}/views/foo.erb +0 -0
- /data/{test → compat}/views/foo.haml +0 -0
- /data/{test → compat}/views/foo.sass +0 -0
- /data/{test → compat}/views/foo_layout.erb +0 -0
- /data/{test → compat}/views/foo_layout.haml +0 -0
- /data/{test → compat}/views/layout_test/foo.builder +0 -0
- /data/{test → compat}/views/layout_test/foo.erb +0 -0
- /data/{test → compat}/views/layout_test/foo.haml +0 -0
- /data/{test → compat}/views/layout_test/foo.sass +0 -0
- /data/{test → compat}/views/layout_test/layout.builder +0 -0
- /data/{test → compat}/views/layout_test/layout.erb +0 -0
- /data/{test → compat}/views/layout_test/layout.haml +0 -0
- /data/{test → compat}/views/layout_test/layout.sass +0 -0
- /data/{test → compat}/views/no_layout/no_layout.builder +0 -0
- /data/{test → compat}/views/no_layout/no_layout.haml +0 -0
- /data/{images → lib/sinatra/images}/404.png +0 -0
- /data/{images → lib/sinatra/images}/500.png +0 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class FooError < RuntimeError; end
|
4
|
+
|
5
|
+
context "Mapped errors" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
Sinatra.application = nil
|
9
|
+
Sinatra.application.options.raise_errors = false
|
10
|
+
end
|
11
|
+
|
12
|
+
specify "are rescued and run in context" do
|
13
|
+
|
14
|
+
error FooError do
|
15
|
+
'MAPPED ERROR!'
|
16
|
+
end
|
17
|
+
|
18
|
+
get '/' do
|
19
|
+
raise FooError
|
20
|
+
end
|
21
|
+
|
22
|
+
get_it '/'
|
23
|
+
|
24
|
+
should.be.server_error
|
25
|
+
body.should.equal 'MAPPED ERROR!'
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
specify "renders empty if no each method on result" do
|
30
|
+
|
31
|
+
error FooError do
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
get '/' do
|
36
|
+
raise FooError
|
37
|
+
end
|
38
|
+
|
39
|
+
get_it '/'
|
40
|
+
|
41
|
+
should.be.server_error
|
42
|
+
body.should.be.empty
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
specify "doesn't override status if set" do
|
47
|
+
|
48
|
+
error FooError do
|
49
|
+
status(200)
|
50
|
+
end
|
51
|
+
|
52
|
+
get '/' do
|
53
|
+
raise FooError
|
54
|
+
end
|
55
|
+
|
56
|
+
get_it '/'
|
57
|
+
|
58
|
+
should.be.ok
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
specify "raises errors when the raise_errors option is set" do
|
63
|
+
Sinatra.application.options.raise_errors = true
|
64
|
+
error FooError do
|
65
|
+
end
|
66
|
+
get '/' do
|
67
|
+
raise FooError
|
68
|
+
end
|
69
|
+
assert_raises(FooError) { get_it('/') }
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -23,24 +23,29 @@ context "Middleware Pipelines" do
|
|
23
23
|
Sinatra.application = nil
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
# Sessions and logging are tested elsewhere. This is a bad test because it
|
27
|
+
# asserts things about the implementation and not the effect.
|
28
|
+
xspecify "includes default middleware with options set" do
|
27
29
|
@app.set_options :sessions => true, :logging => true
|
28
30
|
@app.send(:optional_middleware).should.include([Rack::Session::Cookie, [], nil])
|
29
31
|
@app.send(:optional_middleware).should.include([Rack::CommonLogger, [], nil])
|
30
32
|
end
|
31
33
|
|
32
|
-
|
34
|
+
# Bad test.
|
35
|
+
xspecify "does not include default middleware with options unset" do
|
33
36
|
@app.set_options :sessions => false, :logging => false
|
34
37
|
@app.send(:optional_middleware).should.not.include([Rack::Session::Cookie, [], nil])
|
35
38
|
@app.send(:optional_middleware).should.not.include([Rack::CommonLogger, [], nil])
|
36
39
|
end
|
37
40
|
|
38
|
-
|
41
|
+
# Bad test.
|
42
|
+
xspecify "includes only optional middleware when no explicit middleware added" do
|
39
43
|
@app.set_options :sessions => true, :logging => true
|
40
44
|
@app.send(:middleware).should.equal @app.send(:optional_middleware)
|
41
45
|
end
|
42
46
|
|
43
|
-
|
47
|
+
# Bad test.
|
48
|
+
xspecify "should clear middleware before reload" do
|
44
49
|
@app.clearables.should.include(@app.send(:explicit_middleware))
|
45
50
|
end
|
46
51
|
|
data/compat/sass_test.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
context "Sass" do
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Sinatra.application = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Templates (in general)" do
|
10
|
+
|
11
|
+
setup do
|
12
|
+
Sinatra.application = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
specify "are read from files if Symbols" do
|
16
|
+
|
17
|
+
get '/from_file' do
|
18
|
+
sass :foo, :views_directory => File.dirname(__FILE__) + "/views"
|
19
|
+
end
|
20
|
+
|
21
|
+
get_it '/from_file'
|
22
|
+
should.be.ok
|
23
|
+
body.should.equal "#sass {\n background_color: #FFF; }\n"
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
specify "raise an error if template not found" do
|
28
|
+
get '/' do
|
29
|
+
sass :not_found
|
30
|
+
end
|
31
|
+
|
32
|
+
lambda { get_it '/' }.should.raise(Errno::ENOENT)
|
33
|
+
end
|
34
|
+
|
35
|
+
specify "ignore default layout file with .sass extension" do
|
36
|
+
get '/' do
|
37
|
+
sass :foo, :views_directory => File.dirname(__FILE__) + "/views/layout_test"
|
38
|
+
end
|
39
|
+
|
40
|
+
get_it '/'
|
41
|
+
should.be.ok
|
42
|
+
body.should.equal "#sass {\n background_color: #FFF; }\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
specify "ignore explicitly specified layout file" do
|
46
|
+
get '/' do
|
47
|
+
sass :foo, :layout => :layout, :views_directory => File.dirname(__FILE__) + "/views/layout_test"
|
48
|
+
end
|
49
|
+
|
50
|
+
get_it '/'
|
51
|
+
should.be.ok
|
52
|
+
body.should.equal "#sass {\n background_color: #FFF; }\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -62,6 +62,7 @@ context "Static files (by default)" do
|
|
62
62
|
headers['Last-Modified'].should.equal last_modified.httpdate
|
63
63
|
end
|
64
64
|
|
65
|
+
# Deprecated. Use: ConditionalGet middleware.
|
65
66
|
specify "are not served when If-Modified-Since matches" do
|
66
67
|
last_modified = File.mtime(Sinatra.application.options.public + '/foo.xml')
|
67
68
|
@request = Rack::MockRequest.new(Sinatra.application)
|
@@ -91,7 +92,8 @@ context "SendData" do
|
|
91
92
|
Sinatra.application = nil
|
92
93
|
end
|
93
94
|
|
94
|
-
|
95
|
+
# Deprecated. send_data is going away.
|
96
|
+
xspecify "should send the data with options" do
|
95
97
|
get '/' do
|
96
98
|
send_data 'asdf', :status => 500
|
97
99
|
end
|
@@ -102,6 +104,7 @@ context "SendData" do
|
|
102
104
|
body.should.equal 'asdf'
|
103
105
|
end
|
104
106
|
|
107
|
+
# Deprecated. The Content-Disposition is no longer handled by sendfile.
|
105
108
|
specify "should include a Content-Disposition header" do
|
106
109
|
get '/' do
|
107
110
|
send_file File.dirname(__FILE__) + '/public/foo.xml'
|