bmizerany-sinatra 0.8.10 → 0.9.0
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/CHANGES +10 -38
- data/README.rdoc +87 -135
- data/compat/events_test.rb +7 -10
- data/compat/helper.rb +1 -13
- data/lib/sinatra/base.rb +24 -72
- data/lib/sinatra/compat.rb +44 -142
- data/lib/sinatra/test/rspec.rb +0 -7
- data/lib/sinatra/test/spec.rb +0 -7
- data/lib/sinatra/test/unit.rb +1 -1
- data/lib/sinatra/test.rb +90 -94
- data/lib/sinatra.rb +0 -3
- data/sinatra.gemspec +3 -7
- data/test/base_test.rb +14 -33
- data/test/builder_test.rb +16 -12
- data/test/erb_test.rb +16 -11
- data/test/filter_test.rb +12 -8
- data/test/haml_test.rb +18 -14
- data/test/helpers_test.rb +62 -55
- data/test/mapped_error_test.rb +24 -43
- data/test/middleware_test.rb +13 -8
- data/test/options_test.rb +35 -29
- data/test/reload_test.rb +20 -16
- data/test/request_test.rb +5 -12
- data/test/result_test.rb +20 -16
- data/test/routing_test.rb +71 -124
- data/test/sass_test.rb +12 -8
- data/test/sinatra_test.rb +4 -2
- data/test/static_test.rb +19 -16
- data/test/templates_test.rb +19 -23
- metadata +4 -7
- data/AUTHORS +0 -40
- data/lib/sinatra/test/bacon.rb +0 -17
- data/test/helper.rb +0 -25
data/test/static_test.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require 'test/spec'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'sinatra/test'
|
2
4
|
|
3
5
|
describe 'Static' do
|
6
|
+
include Sinatra::Test
|
4
7
|
F = ::File
|
5
8
|
|
6
9
|
before do
|
7
|
-
mock_app {
|
10
|
+
@app = mock_app {
|
8
11
|
set :static, true
|
9
12
|
set :public, F.dirname(__FILE__)
|
10
13
|
}
|
@@ -12,46 +15,46 @@ describe 'Static' do
|
|
12
15
|
|
13
16
|
it 'serves GET requests for files in the public directory' do
|
14
17
|
get "/#{F.basename(__FILE__)}"
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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'
|
19
22
|
end
|
20
23
|
|
21
24
|
it 'serves HEAD requests for files in the public directory' do
|
22
25
|
head "/#{F.basename(__FILE__)}"
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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'
|
27
30
|
end
|
28
31
|
|
29
32
|
it 'serves files in preference to custom routes' do
|
30
33
|
@app.get("/#{F.basename(__FILE__)}") { 'Hello World' }
|
31
34
|
get "/#{F.basename(__FILE__)}"
|
32
|
-
|
33
|
-
|
35
|
+
should.be.ok
|
36
|
+
body.should.not.equal 'Hello World'
|
34
37
|
end
|
35
38
|
|
36
39
|
it 'does not serve directories' do
|
37
40
|
get "/"
|
38
|
-
|
41
|
+
should.be.not_found
|
39
42
|
end
|
40
43
|
|
41
44
|
it 'passes to the next handler when the static option is disabled' do
|
42
45
|
@app.set :static, false
|
43
46
|
get "/#{F.basename(__FILE__)}"
|
44
|
-
|
47
|
+
should.be.not_found
|
45
48
|
end
|
46
49
|
|
47
50
|
it 'passes to the next handler when the public option is nil' do
|
48
51
|
@app.set :public, nil
|
49
52
|
get "/#{F.basename(__FILE__)}"
|
50
|
-
|
53
|
+
should.be.not_found
|
51
54
|
end
|
52
55
|
|
53
56
|
it '404s when a file is not found' do
|
54
57
|
get "/foobarbaz.txt"
|
55
|
-
|
58
|
+
should.be.not_found
|
56
59
|
end
|
57
60
|
end
|
data/test/templates_test.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'test/spec'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'sinatra/test'
|
2
4
|
|
3
5
|
describe 'Templating' do
|
6
|
+
include Sinatra::Test
|
7
|
+
|
4
8
|
def render_app(&block)
|
5
9
|
mock_app {
|
6
10
|
def render_test(template, data, options, &block)
|
@@ -24,56 +28,48 @@ describe 'Templating' do
|
|
24
28
|
|
25
29
|
it 'renders String templates directly' do
|
26
30
|
render_app { render :test, 'Hello World' }
|
27
|
-
|
28
|
-
|
31
|
+
should.be.ok
|
32
|
+
body.should.equal 'Hello World'
|
29
33
|
end
|
30
34
|
|
31
35
|
it 'renders Proc templates using the call result' do
|
32
36
|
render_app { render :test, Proc.new {'Hello World'} }
|
33
|
-
|
34
|
-
|
37
|
+
should.be.ok
|
38
|
+
body.should.equal 'Hello World'
|
35
39
|
end
|
36
40
|
|
37
41
|
it 'looks up Symbol templates in views directory' do
|
38
42
|
render_app { render :test, :hello }
|
39
|
-
|
40
|
-
|
43
|
+
should.be.ok
|
44
|
+
body.should.equal "Hello World!\n"
|
41
45
|
end
|
42
46
|
|
43
47
|
it 'uses the default layout template if not explicitly overridden' do
|
44
48
|
with_default_layout do
|
45
49
|
render_app { render :test, :hello }
|
46
|
-
|
47
|
-
|
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
|
50
|
+
should.be.ok
|
51
|
+
body.should.equal "Layout!\nHello World!\n"
|
56
52
|
end
|
57
53
|
end
|
58
54
|
|
59
55
|
it 'uses the layout template specified' do
|
60
56
|
render_app { render :test, :hello, :layout => :layout2 }
|
61
|
-
|
62
|
-
|
57
|
+
should.be.ok
|
58
|
+
body.should.equal "Layout 2!\nHello World!\n"
|
63
59
|
end
|
64
60
|
|
65
61
|
it 'uses layout templates defined with the #template method' do
|
66
62
|
render_app { render :test, :hello, :layout => :layout3 }
|
67
|
-
|
68
|
-
|
63
|
+
should.be.ok
|
64
|
+
body.should.equal "Layout 3!\nHello World!\n"
|
69
65
|
end
|
70
66
|
|
71
67
|
it 'loads templates from source file with use_in_file_templates!' do
|
72
68
|
mock_app {
|
73
69
|
use_in_file_templates!
|
74
70
|
}
|
75
|
-
|
76
|
-
|
71
|
+
@app.templates[:foo].should.equal "this is foo\n\n"
|
72
|
+
@app.templates[:layout].should.equal "X\n= yield\nX\n"
|
77
73
|
end
|
78
74
|
end
|
79
75
|
|
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.
|
4
|
+
version: 0.9.0
|
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-06 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.0
|
23
23
|
version:
|
24
24
|
description: Classy web-development dressed in a DSL
|
25
|
-
email:
|
25
|
+
email:
|
26
26
|
executables: []
|
27
27
|
|
28
28
|
extensions: []
|
@@ -31,7 +31,6 @@ extra_rdoc_files:
|
|
31
31
|
- README.rdoc
|
32
32
|
- LICENSE
|
33
33
|
files:
|
34
|
-
- AUTHORS
|
35
34
|
- CHANGES
|
36
35
|
- LICENSE
|
37
36
|
- README.rdoc
|
@@ -77,7 +76,6 @@ files:
|
|
77
76
|
- lib/sinatra/images/500.png
|
78
77
|
- lib/sinatra/main.rb
|
79
78
|
- lib/sinatra/test.rb
|
80
|
-
- lib/sinatra/test/bacon.rb
|
81
79
|
- lib/sinatra/test/rspec.rb
|
82
80
|
- lib/sinatra/test/spec.rb
|
83
81
|
- lib/sinatra/test/unit.rb
|
@@ -88,7 +86,6 @@ files:
|
|
88
86
|
- test/erb_test.rb
|
89
87
|
- test/filter_test.rb
|
90
88
|
- test/haml_test.rb
|
91
|
-
- test/helper.rb
|
92
89
|
- test/helpers_test.rb
|
93
90
|
- test/mapped_error_test.rb
|
94
91
|
- test/middleware_test.rb
|
data/AUTHORS
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
Sinatra was designed and developed by Blake Mizerany (bmizerany) in
|
2
|
-
California. Continued development would not be possible without the ongoing
|
3
|
-
financial support provided by Heroku <heroku.com> and the emotional support
|
4
|
-
provided by Adam Wiggins (adamwiggins), Chris Wanstrath (defunkt), PJ Hyett (pjhyett), and
|
5
|
-
the rest of the Github crew.
|
6
|
-
|
7
|
-
Special thanks to the following extraordinary individuals, who-out which
|
8
|
-
Sinatra would not be possible:
|
9
|
-
|
10
|
-
* Ryan Tomayko (rtomayko) for constantly fixing whitespace errors 60d5006
|
11
|
-
* Ezra Zygmuntowicz (ezmobius) for initial help and letting Blake steal
|
12
|
-
some of merbs internal code.
|
13
|
-
* Christopher Schneid (cschneid) for The Book, the blog (gittr.com),
|
14
|
-
irclogger.com, and a bunch of useful patches.
|
15
|
-
* Markus Prinz (cypher) for patches over the years, caring about
|
16
|
-
the README, and hanging in there when times were rough.
|
17
|
-
* Simon Rozet (sr) for a ton of doc patches, HAML options, and all that
|
18
|
-
advocacy stuff he's going to do for 1.0.
|
19
|
-
* Erik Kastner (kastner) for fixing MIME_TYPES under Rack 0.5.
|
20
|
-
* Ben Bleything (bleything) for caring about HTTP status codes and doc fixes.
|
21
|
-
* Igal Koshevoy (igal) for root path detection under Thin/Passenger.
|
22
|
-
* Jon Crosby (jcrosby) for coffee breaks, doc fixes, and just because, man.
|
23
|
-
* Karel Minarik (karmi) for screaming until the website came back up.
|
24
|
-
* Jeremy Evans (jeremyevans) for unbreaking optional path params (twice!)
|
25
|
-
* The GitHub guys for stealing Blake's table.
|
26
|
-
* Nickolas Means (nmeans) for Sass template support.
|
27
|
-
* Victor Hugo Borja (vic) for splat'n routes specs and doco.
|
28
|
-
* Avdi Grimm (avdi) for basic RSpec support.
|
29
|
-
* Jack Danger Canty for a more accurate root directory and for making me
|
30
|
-
watch this just now: http://www.youtube.com/watch?v=ueaHLHgskkw.
|
31
|
-
* Mathew Walker for making escaped paths work with static files.
|
32
|
-
* Millions of Us for having the problem that led to Sinatra's conception.
|
33
|
-
* Songbird for the problems that helped Sinatra's future become realized.
|
34
|
-
* Rick Olsen (technoweenie) for the killer plug at RailsConf '08.
|
35
|
-
* Steven Garcia for the amazing custom artwork you see on 404's and 500's
|
36
|
-
|
37
|
-
and last but not least:
|
38
|
-
|
39
|
-
* Frank Sinatra (chairman of the board) for having so much class he
|
40
|
-
deserves a web-framework named after him.
|
data/lib/sinatra/test/bacon.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'bacon'
|
2
|
-
require 'sinatra/test'
|
3
|
-
|
4
|
-
Sinatra::Default.set(
|
5
|
-
:env => :test,
|
6
|
-
:run => false,
|
7
|
-
:raise_errors => true,
|
8
|
-
:logging => false
|
9
|
-
)
|
10
|
-
|
11
|
-
module Sinatra::Test
|
12
|
-
def should
|
13
|
-
@response.should
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
Bacon::Context.send(:include, Sinatra::Test)
|
data/test/helper.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'test/spec'
|
3
|
-
rescue LoadError
|
4
|
-
require 'rubygems'
|
5
|
-
require 'test/spec'
|
6
|
-
end
|
7
|
-
|
8
|
-
$:.unshift File.dirname(File.dirname(__FILE__)) + '/lib'
|
9
|
-
require 'sinatra/base'
|
10
|
-
require 'sinatra/test'
|
11
|
-
require 'sinatra/test/spec'
|
12
|
-
|
13
|
-
module Sinatra::Test
|
14
|
-
# Sets up a Sinatra::Base subclass defined with the block
|
15
|
-
# given. Used in setup or individual spec methods to establish
|
16
|
-
# the application.
|
17
|
-
def mock_app(base=Sinatra::Base, &block)
|
18
|
-
@app = Sinatra.new(base, &block)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class Sinatra::Base
|
23
|
-
# Allow assertions in request context
|
24
|
-
include Test::Unit::Assertions
|
25
|
-
end
|