sinatra 1.2.6 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sinatra might be problematic. Click here for more details.
- data/CHANGES +34 -1
- data/Gemfile +18 -16
- data/README.de.rdoc +4 -4
- data/README.es.rdoc +4 -4
- data/README.fr.rdoc +4 -4
- data/README.jp.rdoc +7 -1
- data/README.rdoc +66 -27
- data/README.ru.rdoc +2 -2
- data/README.zh.rdoc +4 -4
- data/Rakefile +25 -6
- data/lib/sinatra/base.rb +49 -28
- data/lib/sinatra/main.rb +1 -1
- data/lib/sinatra/showexceptions.rb +2 -2
- data/sinatra.gemspec +2 -2
- data/test/delegator_test.rb +2 -0
- data/test/helpers_test.rb +1 -0
- data/test/nokogiri_test.rb +5 -6
- data/test/rack_test.rb +45 -0
- data/test/result_test.rb +4 -4
- data/test/routing_test.rb +1 -1
- data/test/server_test.rb +3 -2
- data/test/settings_test.rb +8 -0
- data/test/slim_test.rb +15 -25
- metadata +46 -49
data/test/rack_test.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
require 'rack'
|
3
|
+
|
4
|
+
class RackTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
@foo = Sinatra.new { get('/foo') { 'foo' }}
|
7
|
+
@bar = Sinatra.new { get('/bar') { 'bar' }}
|
8
|
+
end
|
9
|
+
|
10
|
+
def build(*middleware)
|
11
|
+
endpoint = middleware.pop
|
12
|
+
@app = Rack::Builder.app do
|
13
|
+
middleware.each { |m| use m }
|
14
|
+
run endpoint
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def check(*middleware)
|
19
|
+
build(*middleware)
|
20
|
+
assert get('/foo').ok?
|
21
|
+
assert_body 'foo'
|
22
|
+
assert get('/bar').ok?
|
23
|
+
assert_body 'bar'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'works as middleware in front of Rack::Lock, with lock enabled' do
|
27
|
+
@foo.enable :lock
|
28
|
+
check(@foo, Rack::Lock, @bar)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'works as middleware behind Rack::Lock, with lock enabled' do
|
32
|
+
@foo.enable :lock
|
33
|
+
check(Rack::Lock, @foo, @bar)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'works as middleware in front of Rack::Lock, with lock disabled' do
|
37
|
+
@foo.disable :lock
|
38
|
+
check(@foo, Rack::Lock, @bar)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'works as middleware behind Rack::Lock, with lock disabled' do
|
42
|
+
@foo.disable :lock
|
43
|
+
check(Rack::Lock, @foo, @bar)
|
44
|
+
end
|
45
|
+
end
|
data/test/result_test.rb
CHANGED
@@ -54,12 +54,12 @@ class ResultTest < Test::Unit::TestCase
|
|
54
54
|
it "sets status, headers, and body when result is a Rack response tuple" do
|
55
55
|
mock_app {
|
56
56
|
get '/' do
|
57
|
-
[
|
57
|
+
[203, {'Content-Type' => 'foo/bar'}, 'Hello World']
|
58
58
|
end
|
59
59
|
}
|
60
60
|
|
61
61
|
get '/'
|
62
|
-
assert_equal
|
62
|
+
assert_equal 203, status
|
63
63
|
assert_equal 'foo/bar', response['Content-Type']
|
64
64
|
assert_equal 'Hello World', body
|
65
65
|
end
|
@@ -88,11 +88,11 @@ class ResultTest < Test::Unit::TestCase
|
|
88
88
|
|
89
89
|
it "sets status when result is a Fixnum status code" do
|
90
90
|
mock_app {
|
91
|
-
get('/') {
|
91
|
+
get('/') { 204 }
|
92
92
|
}
|
93
93
|
|
94
94
|
get '/'
|
95
|
-
assert_equal
|
95
|
+
assert_equal 204, status
|
96
96
|
assert_equal '', body
|
97
97
|
end
|
98
98
|
end
|
data/test/routing_test.rb
CHANGED
@@ -1047,7 +1047,7 @@ class RoutingTest < Test::Unit::TestCase
|
|
1047
1047
|
mock_app do
|
1048
1048
|
get '/foo' do
|
1049
1049
|
status, headers, body = call env.merge("PATH_INFO" => '/bar')
|
1050
|
-
[status, headers, body.map
|
1050
|
+
[status, headers, body.map { |e| e.upcase }]
|
1051
1051
|
end
|
1052
1052
|
|
1053
1053
|
get '/bar' do
|
data/test/server_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/helper'
|
2
|
+
require 'stringio'
|
2
3
|
|
3
4
|
module Rack::Handler
|
4
5
|
class Mock
|
@@ -25,11 +26,11 @@ class ServerTest < Test::Unit::TestCase
|
|
25
26
|
set :bind, 'foo.local'
|
26
27
|
set :port, 9001
|
27
28
|
}
|
28
|
-
$
|
29
|
+
$stderr = StringIO.new
|
29
30
|
end
|
30
31
|
|
31
32
|
def teardown
|
32
|
-
$
|
33
|
+
$stderr = STDERR
|
33
34
|
end
|
34
35
|
|
35
36
|
it "locates the appropriate Rack handler and calls ::run" do
|
data/test/settings_test.rb
CHANGED
@@ -334,6 +334,14 @@ class SettingsTest < Test::Unit::TestCase
|
|
334
334
|
@application.set :root, File.dirname(__FILE__)
|
335
335
|
assert @application.static?
|
336
336
|
end
|
337
|
+
|
338
|
+
it 'is possible to use Module#public' do
|
339
|
+
@base.send(:define_method, :foo) { }
|
340
|
+
@base.send(:private, :foo)
|
341
|
+
assert !@base.method_defined?(:foo)
|
342
|
+
@base.send(:public, :foo)
|
343
|
+
assert @base.method_defined?(:foo)
|
344
|
+
end
|
337
345
|
end
|
338
346
|
|
339
347
|
describe 'bind' do
|
data/test/slim_test.rb
CHANGED
@@ -52,44 +52,34 @@ class SlimTest < Test::Unit::TestCase
|
|
52
52
|
HTML4_DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"
|
53
53
|
|
54
54
|
it "passes slim options to the slim engine" do
|
55
|
-
mock_app {
|
56
|
-
get '/' do
|
57
|
-
slim "! doctype html\nh1 Hello World", :format => :html4
|
58
|
-
end
|
59
|
-
}
|
55
|
+
mock_app { get('/') { slim "x foo='bar'", :attr_wrapper => "'" }}
|
60
56
|
get '/'
|
61
57
|
assert ok?
|
62
|
-
|
58
|
+
assert_body "<x foo='bar'></x>"
|
63
59
|
end
|
64
60
|
|
65
61
|
it "passes default slim options to the slim engine" do
|
66
|
-
mock_app
|
67
|
-
set :slim,
|
68
|
-
get
|
69
|
-
|
70
|
-
end
|
71
|
-
}
|
62
|
+
mock_app do
|
63
|
+
set :slim, :attr_wrapper => "'"
|
64
|
+
get('/') { slim "x foo='bar'" }
|
65
|
+
end
|
72
66
|
get '/'
|
73
67
|
assert ok?
|
74
|
-
|
68
|
+
assert_body "<x foo='bar'></x>"
|
75
69
|
end
|
76
70
|
|
77
71
|
it "merges the default slim options with the overrides and passes them to the slim engine" do
|
78
|
-
mock_app
|
79
|
-
set :slim,
|
80
|
-
get
|
81
|
-
|
82
|
-
|
83
|
-
get '/html5' do
|
84
|
-
slim "! doctype html\nh1.header Hello World", :format => :html5
|
85
|
-
end
|
86
|
-
}
|
72
|
+
mock_app do
|
73
|
+
set :slim, :attr_wrapper => "'"
|
74
|
+
get('/') { slim "x foo='bar'" }
|
75
|
+
get('/other') { slim "x foo='bar'", :attr_wrapper => '"' }
|
76
|
+
end
|
87
77
|
get '/'
|
88
78
|
assert ok?
|
89
|
-
|
90
|
-
get '/
|
79
|
+
assert_body "<x foo='bar'></x>"
|
80
|
+
get '/other'
|
91
81
|
assert ok?
|
92
|
-
|
82
|
+
assert_body '<x foo="bar"></x>'
|
93
83
|
end
|
94
84
|
end
|
95
85
|
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.7
|
4
5
|
prerelease:
|
5
|
-
version: 1.2.6
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Blake Mizerany
|
9
9
|
- Ryan Tomayko
|
10
10
|
- Simon Rozet
|
@@ -12,52 +12,49 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
- !ruby/object:Gem::Dependency
|
15
|
+
date: 2011-10-01 00:00:00.000000000Z
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
19
18
|
name: rack
|
20
|
-
requirement: &
|
19
|
+
requirement: &2157377220 !ruby/object:Gem::Requirement
|
21
20
|
none: false
|
22
|
-
requirements:
|
21
|
+
requirements:
|
23
22
|
- - ~>
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version:
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '1.1'
|
26
25
|
type: :runtime
|
27
26
|
prerelease: false
|
28
|
-
version_requirements: *
|
29
|
-
- !ruby/object:Gem::Dependency
|
27
|
+
version_requirements: *2157377220
|
28
|
+
- !ruby/object:Gem::Dependency
|
30
29
|
name: tilt
|
31
|
-
requirement: &
|
30
|
+
requirement: &2157376740 !ruby/object:Gem::Requirement
|
32
31
|
none: false
|
33
|
-
requirements:
|
34
|
-
- -
|
35
|
-
- !ruby/object:Gem::Version
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
36
35
|
version: 1.2.2
|
37
36
|
- - <
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version:
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '2.0'
|
40
39
|
type: :runtime
|
41
40
|
prerelease: false
|
42
|
-
version_requirements: *
|
43
|
-
- !ruby/object:Gem::Dependency
|
41
|
+
version_requirements: *2157376740
|
42
|
+
- !ruby/object:Gem::Dependency
|
44
43
|
name: shotgun
|
45
|
-
requirement: &
|
44
|
+
requirement: &2157376020 !ruby/object:Gem::Requirement
|
46
45
|
none: false
|
47
|
-
requirements:
|
46
|
+
requirements:
|
48
47
|
- - ~>
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version:
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.6'
|
51
50
|
type: :development
|
52
51
|
prerelease: false
|
53
|
-
version_requirements: *
|
52
|
+
version_requirements: *2157376020
|
54
53
|
description: Classy web-development dressed in a DSL
|
55
54
|
email: sinatrarb@googlegroups.com
|
56
55
|
executables: []
|
57
|
-
|
58
56
|
extensions: []
|
59
|
-
|
60
|
-
extra_rdoc_files:
|
57
|
+
extra_rdoc_files:
|
61
58
|
- README.rdoc
|
62
59
|
- README.de.rdoc
|
63
60
|
- README.jp.rdoc
|
@@ -66,7 +63,7 @@ extra_rdoc_files:
|
|
66
63
|
- README.hu.rdoc
|
67
64
|
- README.zh.rdoc
|
68
65
|
- LICENSE
|
69
|
-
files:
|
66
|
+
files:
|
70
67
|
- AUTHORS
|
71
68
|
- CHANGES
|
72
69
|
- Gemfile
|
@@ -111,6 +108,7 @@ files:
|
|
111
108
|
- test/middleware_test.rb
|
112
109
|
- test/nokogiri_test.rb
|
113
110
|
- test/public/favicon.ico
|
111
|
+
- test/rack_test.rb
|
114
112
|
- test/radius_test.rb
|
115
113
|
- test/rdoc_test.rb
|
116
114
|
- test/request_test.rb
|
@@ -171,40 +169,38 @@ files:
|
|
171
169
|
- test/views/utf8.erb
|
172
170
|
homepage: http://sinatra.rubyforge.org
|
173
171
|
licenses: []
|
174
|
-
|
175
172
|
post_install_message:
|
176
|
-
rdoc_options:
|
173
|
+
rdoc_options:
|
177
174
|
- --line-numbers
|
178
175
|
- --inline-source
|
179
176
|
- --title
|
180
177
|
- Sinatra
|
181
178
|
- --main
|
182
179
|
- README.rdoc
|
183
|
-
require_paths:
|
180
|
+
require_paths:
|
184
181
|
- lib
|
185
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
186
183
|
none: false
|
187
|
-
requirements:
|
188
|
-
- -
|
189
|
-
- !ruby/object:Gem::Version
|
190
|
-
|
191
|
-
segments:
|
184
|
+
requirements:
|
185
|
+
- - ! '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
segments:
|
192
189
|
- 0
|
193
|
-
|
194
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
|
+
hash: 134946586241568196
|
191
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
192
|
none: false
|
196
|
-
requirements:
|
197
|
-
- -
|
198
|
-
- !ruby/object:Gem::Version
|
199
|
-
version:
|
193
|
+
requirements:
|
194
|
+
- - ! '>='
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0'
|
200
197
|
requirements: []
|
201
|
-
|
202
198
|
rubyforge_project: sinatra
|
203
|
-
rubygems_version: 1.
|
199
|
+
rubygems_version: 1.8.10
|
204
200
|
signing_key:
|
205
201
|
specification_version: 2
|
206
202
|
summary: Classy web-development dressed in a DSL
|
207
|
-
test_files:
|
203
|
+
test_files:
|
208
204
|
- test/base_test.rb
|
209
205
|
- test/builder_test.rb
|
210
206
|
- test/coffee_test.rb
|
@@ -223,6 +219,7 @@ test_files:
|
|
223
219
|
- test/markdown_test.rb
|
224
220
|
- test/middleware_test.rb
|
225
221
|
- test/nokogiri_test.rb
|
222
|
+
- test/rack_test.rb
|
226
223
|
- test/radius_test.rb
|
227
224
|
- test/rdoc_test.rb
|
228
225
|
- test/request_test.rb
|