adamwiggins-sinatra 0.8.9
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 +167 -0
- data/LICENSE +22 -0
- data/README.rdoc +529 -0
- data/Rakefile +180 -0
- data/compat/app_test.rb +300 -0
- data/compat/application_test.rb +334 -0
- data/compat/builder_test.rb +101 -0
- data/compat/custom_error_test.rb +62 -0
- data/compat/erb_test.rb +136 -0
- data/compat/events_test.rb +75 -0
- data/compat/filter_test.rb +30 -0
- data/compat/haml_test.rb +233 -0
- data/compat/helper.rb +21 -0
- data/compat/mapped_error_test.rb +72 -0
- data/compat/pipeline_test.rb +71 -0
- data/compat/public/foo.xml +1 -0
- data/compat/sass_test.rb +57 -0
- data/compat/sessions_test.rb +39 -0
- data/compat/streaming_test.rb +121 -0
- data/compat/sym_params_test.rb +19 -0
- data/compat/template_test.rb +30 -0
- data/compat/use_in_file_templates_test.rb +47 -0
- data/compat/views/foo.builder +1 -0
- data/compat/views/foo.erb +1 -0
- data/compat/views/foo.haml +1 -0
- data/compat/views/foo.sass +2 -0
- data/compat/views/foo_layout.erb +2 -0
- data/compat/views/foo_layout.haml +2 -0
- data/compat/views/layout_test/foo.builder +1 -0
- data/compat/views/layout_test/foo.erb +1 -0
- data/compat/views/layout_test/foo.haml +1 -0
- data/compat/views/layout_test/foo.sass +2 -0
- data/compat/views/layout_test/layout.builder +3 -0
- data/compat/views/layout_test/layout.erb +1 -0
- data/compat/views/layout_test/layout.haml +1 -0
- data/compat/views/layout_test/layout.sass +2 -0
- data/compat/views/no_layout/no_layout.builder +1 -0
- data/compat/views/no_layout/no_layout.haml +1 -0
- data/lib/sinatra/base.rb +818 -0
- data/lib/sinatra/compat.rb +239 -0
- data/lib/sinatra/images/404.png +0 -0
- data/lib/sinatra/images/500.png +0 -0
- data/lib/sinatra/main.rb +48 -0
- data/lib/sinatra/test/rspec.rb +2 -0
- data/lib/sinatra/test/spec.rb +2 -0
- data/lib/sinatra/test/unit.rb +11 -0
- data/lib/sinatra/test.rb +112 -0
- data/lib/sinatra.rb +3 -0
- data/sinatra.gemspec +107 -0
- data/test/base_test.rb +72 -0
- data/test/builder_test.rb +68 -0
- data/test/data/reload_app_file.rb +3 -0
- data/test/erb_test.rb +55 -0
- data/test/filter_test.rb +39 -0
- data/test/haml_test.rb +72 -0
- data/test/helpers_test.rb +368 -0
- data/test/mapped_error_test.rb +164 -0
- data/test/middleware_test.rb +63 -0
- data/test/options_test.rb +103 -0
- data/test/reload_test.rb +65 -0
- data/test/request_test.rb +11 -0
- data/test/result_test.rb +92 -0
- data/test/routing_test.rb +338 -0
- data/test/sass_test.rb +40 -0
- data/test/sinatra_test.rb +15 -0
- data/test/static_test.rb +60 -0
- data/test/templates_test.rb +92 -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 +159 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'test/spec'
|
|
2
|
+
require 'sinatra/base'
|
|
3
|
+
require 'sinatra/test'
|
|
4
|
+
|
|
5
|
+
describe 'Sinatra' do
|
|
6
|
+
it 'creates a new Sinatra::Base subclass on new' do
|
|
7
|
+
app =
|
|
8
|
+
Sinatra.new do
|
|
9
|
+
get '/' do
|
|
10
|
+
'Hello World'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
app.superclass.should.be Sinatra::Base
|
|
14
|
+
end
|
|
15
|
+
end
|
data/test/static_test.rb
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'test/spec'
|
|
2
|
+
require 'sinatra/base'
|
|
3
|
+
require 'sinatra/test'
|
|
4
|
+
|
|
5
|
+
describe 'Static' do
|
|
6
|
+
include Sinatra::Test
|
|
7
|
+
F = ::File
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
@app = mock_app {
|
|
11
|
+
set :static, true
|
|
12
|
+
set :public, F.dirname(__FILE__)
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'serves GET requests for files in the public directory' do
|
|
17
|
+
get "/#{F.basename(__FILE__)}"
|
|
18
|
+
should.be.ok
|
|
19
|
+
body.should.equal File.read(__FILE__)
|
|
20
|
+
response['Content-Length'].should.equal File.size(__FILE__).to_s
|
|
21
|
+
response.headers.should.include 'Last-Modified'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'serves HEAD requests for files in the public directory' do
|
|
25
|
+
head "/#{F.basename(__FILE__)}"
|
|
26
|
+
should.be.ok
|
|
27
|
+
body.should.be.empty
|
|
28
|
+
response['Content-Length'].should.equal File.size(__FILE__).to_s
|
|
29
|
+
response.headers.should.include 'Last-Modified'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'serves files in preference to custom routes' do
|
|
33
|
+
@app.get("/#{F.basename(__FILE__)}") { 'Hello World' }
|
|
34
|
+
get "/#{F.basename(__FILE__)}"
|
|
35
|
+
should.be.ok
|
|
36
|
+
body.should.not.equal 'Hello World'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'does not serve directories' do
|
|
40
|
+
get "/"
|
|
41
|
+
should.be.not_found
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'passes to the next handler when the static option is disabled' do
|
|
45
|
+
@app.set :static, false
|
|
46
|
+
get "/#{F.basename(__FILE__)}"
|
|
47
|
+
should.be.not_found
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'passes to the next handler when the public option is nil' do
|
|
51
|
+
@app.set :public, nil
|
|
52
|
+
get "/#{F.basename(__FILE__)}"
|
|
53
|
+
should.be.not_found
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it '404s when a file is not found' do
|
|
57
|
+
get "/foobarbaz.txt"
|
|
58
|
+
should.be.not_found
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require 'test/spec'
|
|
2
|
+
require 'sinatra/base'
|
|
3
|
+
require 'sinatra/test'
|
|
4
|
+
|
|
5
|
+
describe 'Templating' do
|
|
6
|
+
include Sinatra::Test
|
|
7
|
+
|
|
8
|
+
def render_app(&block)
|
|
9
|
+
mock_app {
|
|
10
|
+
def render_test(template, data, options, &block)
|
|
11
|
+
inner = block ? block.call : ''
|
|
12
|
+
data + inner
|
|
13
|
+
end
|
|
14
|
+
set :views, File.dirname(__FILE__) + '/views'
|
|
15
|
+
get '/', &block
|
|
16
|
+
template(:layout3) { "Layout 3!\n" }
|
|
17
|
+
}
|
|
18
|
+
get '/'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def with_default_layout
|
|
22
|
+
layout = File.dirname(__FILE__) + '/views/layout.test'
|
|
23
|
+
File.open(layout, 'wb') { |io| io.write "Layout!\n" }
|
|
24
|
+
yield
|
|
25
|
+
ensure
|
|
26
|
+
File.unlink(layout) rescue nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'renders String templates directly' do
|
|
30
|
+
render_app { render :test, 'Hello World' }
|
|
31
|
+
should.be.ok
|
|
32
|
+
body.should.equal 'Hello World'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'renders Proc templates using the call result' do
|
|
36
|
+
render_app { render :test, Proc.new {'Hello World'} }
|
|
37
|
+
should.be.ok
|
|
38
|
+
body.should.equal 'Hello World'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'looks up Symbol templates in views directory' do
|
|
42
|
+
render_app { render :test, :hello }
|
|
43
|
+
should.be.ok
|
|
44
|
+
body.should.equal "Hello World!\n"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'uses the default layout template if not explicitly overridden' do
|
|
48
|
+
with_default_layout do
|
|
49
|
+
render_app { render :test, :hello }
|
|
50
|
+
should.be.ok
|
|
51
|
+
body.should.equal "Layout!\nHello World!\n"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'uses the default layout template if not really overriden' do
|
|
56
|
+
with_default_layout do
|
|
57
|
+
render_app { render :test, :hello, :layout => true }
|
|
58
|
+
should.be.ok
|
|
59
|
+
body.should.equal "Layout!\nHello World!\n"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'uses the layout template specified' do
|
|
64
|
+
render_app { render :test, :hello, :layout => :layout2 }
|
|
65
|
+
should.be.ok
|
|
66
|
+
body.should.equal "Layout 2!\nHello World!\n"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'uses layout templates defined with the #template method' do
|
|
70
|
+
render_app { render :test, :hello, :layout => :layout3 }
|
|
71
|
+
should.be.ok
|
|
72
|
+
body.should.equal "Layout 3!\nHello World!\n"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'loads templates from source file with use_in_file_templates!' do
|
|
76
|
+
mock_app {
|
|
77
|
+
use_in_file_templates!
|
|
78
|
+
}
|
|
79
|
+
@app.templates[:foo].should.equal "this is foo\n\n"
|
|
80
|
+
@app.templates[:layout].should.equal "X\n= yield\nX\n"
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
__END__
|
|
85
|
+
|
|
86
|
+
@@ foo
|
|
87
|
+
this is foo
|
|
88
|
+
|
|
89
|
+
@@ layout
|
|
90
|
+
X
|
|
91
|
+
= yield
|
|
92
|
+
X
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
xml.exclaim "You're my boy, #{@name}!"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hello <%= 'World' %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
%h1 Hello From Haml
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hello World!
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Layout 2!
|
metadata
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: adamwiggins-sinatra
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.8.9
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Blake Mizerany
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-01-13 00:00:00 -08:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: rack
|
|
17
|
+
version_requirement:
|
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
19
|
+
requirements:
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 0.9.0
|
|
23
|
+
version:
|
|
24
|
+
description: Classy web-development dressed in a DSL
|
|
25
|
+
email:
|
|
26
|
+
executables: []
|
|
27
|
+
|
|
28
|
+
extensions: []
|
|
29
|
+
|
|
30
|
+
extra_rdoc_files:
|
|
31
|
+
- README.rdoc
|
|
32
|
+
- LICENSE
|
|
33
|
+
files:
|
|
34
|
+
- AUTHORS
|
|
35
|
+
- CHANGES
|
|
36
|
+
- LICENSE
|
|
37
|
+
- README.rdoc
|
|
38
|
+
- Rakefile
|
|
39
|
+
- compat/app_test.rb
|
|
40
|
+
- compat/application_test.rb
|
|
41
|
+
- compat/builder_test.rb
|
|
42
|
+
- compat/custom_error_test.rb
|
|
43
|
+
- compat/erb_test.rb
|
|
44
|
+
- compat/events_test.rb
|
|
45
|
+
- compat/filter_test.rb
|
|
46
|
+
- compat/haml_test.rb
|
|
47
|
+
- compat/helper.rb
|
|
48
|
+
- compat/mapped_error_test.rb
|
|
49
|
+
- compat/pipeline_test.rb
|
|
50
|
+
- compat/public/foo.xml
|
|
51
|
+
- compat/sass_test.rb
|
|
52
|
+
- compat/sessions_test.rb
|
|
53
|
+
- compat/streaming_test.rb
|
|
54
|
+
- compat/sym_params_test.rb
|
|
55
|
+
- compat/template_test.rb
|
|
56
|
+
- compat/use_in_file_templates_test.rb
|
|
57
|
+
- compat/views/foo.builder
|
|
58
|
+
- compat/views/foo.erb
|
|
59
|
+
- compat/views/foo.haml
|
|
60
|
+
- compat/views/foo.sass
|
|
61
|
+
- compat/views/foo_layout.erb
|
|
62
|
+
- compat/views/foo_layout.haml
|
|
63
|
+
- compat/views/layout_test/foo.builder
|
|
64
|
+
- compat/views/layout_test/foo.erb
|
|
65
|
+
- compat/views/layout_test/foo.haml
|
|
66
|
+
- compat/views/layout_test/foo.sass
|
|
67
|
+
- compat/views/layout_test/layout.builder
|
|
68
|
+
- compat/views/layout_test/layout.erb
|
|
69
|
+
- compat/views/layout_test/layout.haml
|
|
70
|
+
- compat/views/layout_test/layout.sass
|
|
71
|
+
- compat/views/no_layout/no_layout.builder
|
|
72
|
+
- compat/views/no_layout/no_layout.haml
|
|
73
|
+
- lib/sinatra.rb
|
|
74
|
+
- lib/sinatra/base.rb
|
|
75
|
+
- lib/sinatra/compat.rb
|
|
76
|
+
- lib/sinatra/images/404.png
|
|
77
|
+
- lib/sinatra/images/500.png
|
|
78
|
+
- lib/sinatra/main.rb
|
|
79
|
+
- lib/sinatra/test.rb
|
|
80
|
+
- lib/sinatra/test/rspec.rb
|
|
81
|
+
- lib/sinatra/test/spec.rb
|
|
82
|
+
- lib/sinatra/test/unit.rb
|
|
83
|
+
- sinatra.gemspec
|
|
84
|
+
- test/base_test.rb
|
|
85
|
+
- test/builder_test.rb
|
|
86
|
+
- test/data/reload_app_file.rb
|
|
87
|
+
- test/erb_test.rb
|
|
88
|
+
- test/filter_test.rb
|
|
89
|
+
- test/haml_test.rb
|
|
90
|
+
- test/helpers_test.rb
|
|
91
|
+
- test/mapped_error_test.rb
|
|
92
|
+
- test/middleware_test.rb
|
|
93
|
+
- test/options_test.rb
|
|
94
|
+
- test/reload_test.rb
|
|
95
|
+
- test/request_test.rb
|
|
96
|
+
- test/result_test.rb
|
|
97
|
+
- test/routing_test.rb
|
|
98
|
+
- test/sass_test.rb
|
|
99
|
+
- test/sinatra_test.rb
|
|
100
|
+
- test/static_test.rb
|
|
101
|
+
- test/templates_test.rb
|
|
102
|
+
- test/views/hello.builder
|
|
103
|
+
- test/views/hello.erb
|
|
104
|
+
- test/views/hello.haml
|
|
105
|
+
- test/views/hello.sass
|
|
106
|
+
- test/views/hello.test
|
|
107
|
+
- test/views/layout2.builder
|
|
108
|
+
- test/views/layout2.erb
|
|
109
|
+
- test/views/layout2.haml
|
|
110
|
+
- test/views/layout2.test
|
|
111
|
+
has_rdoc: true
|
|
112
|
+
homepage: http://sinatra.rubyforge.org
|
|
113
|
+
post_install_message:
|
|
114
|
+
rdoc_options:
|
|
115
|
+
- --line-numbers
|
|
116
|
+
- --inline-source
|
|
117
|
+
- --title
|
|
118
|
+
- Sinatra
|
|
119
|
+
- --main
|
|
120
|
+
- README.rdoc
|
|
121
|
+
require_paths:
|
|
122
|
+
- lib
|
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
|
+
requirements:
|
|
125
|
+
- - ">="
|
|
126
|
+
- !ruby/object:Gem::Version
|
|
127
|
+
version: "0"
|
|
128
|
+
version:
|
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
|
+
requirements:
|
|
131
|
+
- - ">="
|
|
132
|
+
- !ruby/object:Gem::Version
|
|
133
|
+
version: "0"
|
|
134
|
+
version:
|
|
135
|
+
requirements: []
|
|
136
|
+
|
|
137
|
+
rubyforge_project: sinatra
|
|
138
|
+
rubygems_version: 1.2.0
|
|
139
|
+
signing_key:
|
|
140
|
+
specification_version: 2
|
|
141
|
+
summary: Classy web-development dressed in a DSL
|
|
142
|
+
test_files:
|
|
143
|
+
- test/base_test.rb
|
|
144
|
+
- test/builder_test.rb
|
|
145
|
+
- test/erb_test.rb
|
|
146
|
+
- test/filter_test.rb
|
|
147
|
+
- test/haml_test.rb
|
|
148
|
+
- test/helpers_test.rb
|
|
149
|
+
- test/mapped_error_test.rb
|
|
150
|
+
- test/middleware_test.rb
|
|
151
|
+
- test/options_test.rb
|
|
152
|
+
- test/reload_test.rb
|
|
153
|
+
- test/request_test.rb
|
|
154
|
+
- test/result_test.rb
|
|
155
|
+
- test/routing_test.rb
|
|
156
|
+
- test/sass_test.rb
|
|
157
|
+
- test/sinatra_test.rb
|
|
158
|
+
- test/static_test.rb
|
|
159
|
+
- test/templates_test.rb
|