sinatra 1.4.5 → 1.4.6
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.
- checksums.yaml +4 -4
- data/AUTHORS.md +77 -0
- data/CHANGES +30 -0
- data/Gemfile +5 -5
- data/README.de.md +186 -56
- data/README.es.md +76 -76
- data/README.fr.md +120 -56
- data/README.hu.md +19 -19
- data/README.ja.md +44 -46
- data/README.ko.md +163 -67
- data/README.md +151 -127
- data/README.pt-br.md +905 -144
- data/README.pt-pt.md +17 -17
- data/README.ru.md +88 -52
- data/README.zh.md +76 -68
- data/lib/sinatra.rb +0 -1
- data/lib/sinatra/base.rb +21 -15
- data/lib/sinatra/show_exceptions.rb +10 -4
- data/lib/sinatra/version.rb +1 -1
- data/sinatra.gemspec +1 -1
- data/test/asciidoctor_test.rb +2 -2
- data/test/base_test.rb +1 -5
- data/test/builder_test.rb +2 -2
- data/test/coffee_test.rb +8 -2
- data/test/compile_test.rb +1 -1
- data/test/contest.rb +3 -12
- data/test/creole_test.rb +2 -2
- data/test/delegator_test.rb +1 -1
- data/test/encoding_test.rb +1 -1
- data/test/erb_test.rb +1 -1
- data/test/extensions_test.rb +1 -1
- data/test/filter_test.rb +2 -2
- data/test/haml_test.rb +2 -2
- data/test/helper.rb +8 -7
- data/test/helpers_test.rb +6 -6
- data/test/integration_test.rb +3 -3
- data/test/less_test.rb +2 -2
- data/test/liquid_test.rb +3 -3
- data/test/mapped_error_test.rb +5 -5
- data/test/markaby_test.rb +2 -2
- data/test/markdown_test.rb +6 -3
- data/test/mediawiki_test.rb +2 -2
- data/test/middleware_test.rb +1 -1
- data/test/nokogiri_test.rb +2 -2
- data/test/rabl_test.rb +2 -2
- data/test/rack_test.rb +1 -1
- data/test/radius_test.rb +2 -2
- data/test/rdoc_test.rb +4 -4
- data/test/readme_test.rb +1 -1
- data/test/request_test.rb +4 -1
- data/test/response_test.rb +1 -1
- data/test/result_test.rb +2 -2
- data/test/route_added_hook_test.rb +1 -1
- data/test/routing_test.rb +7 -7
- data/test/sass_test.rb +3 -3
- data/test/scss_test.rb +2 -2
- data/test/server_test.rb +10 -2
- data/test/settings_test.rb +4 -4
- data/test/sinatra_test.rb +1 -1
- data/test/slim_test.rb +2 -2
- data/test/static_test.rb +2 -2
- data/test/streaming_test.rb +2 -2
- data/test/stylus_test.rb +2 -2
- data/test/templates_test.rb +3 -3
- data/test/textile_test.rb +2 -2
- data/test/wlang_test.rb +1 -1
- data/test/yajl_test.rb +2 -2
- metadata +10 -11
- data/AUTHORS +0 -61
data/test/integration_test.rb
CHANGED
@@ -5,7 +5,7 @@ require File.expand_path('../integration_helper', __FILE__)
|
|
5
5
|
# Every test runs with every detected server.
|
6
6
|
#
|
7
7
|
# See test/integration/app.rb for the code of the app we test against.
|
8
|
-
class IntegrationTest < Test
|
8
|
+
class IntegrationTest < Minitest::Test
|
9
9
|
extend IntegrationHelper
|
10
10
|
attr_accessor :server
|
11
11
|
|
@@ -77,7 +77,7 @@ class IntegrationTest < Test::Unit::TestCase
|
|
77
77
|
|
78
78
|
it 'starts the correct server' do
|
79
79
|
exp = %r{
|
80
|
-
==\sSinatra
|
80
|
+
==\sSinatra\s\(v#{Sinatra::VERSION}\)\s
|
81
81
|
has\staken\sthe\sstage\son\s\d+\sfor\sdevelopment\s
|
82
82
|
with\sbackup\sfrom\s#{server}
|
83
83
|
}ix
|
@@ -87,7 +87,7 @@ class IntegrationTest < Test::Unit::TestCase
|
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'does not generate warnings' do
|
90
|
-
|
90
|
+
assert_raises(OpenURI::HTTPError) { server.get '/' }
|
91
91
|
server.get '/app_file'
|
92
92
|
assert_equal [], server.warnings
|
93
93
|
end
|
data/test/less_test.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../helper', __FILE__)
|
|
3
3
|
begin
|
4
4
|
require 'less'
|
5
5
|
|
6
|
-
class LessTest < Test
|
6
|
+
class LessTest < Minitest::Test
|
7
7
|
def less_app(options = {}, &block)
|
8
8
|
mock_app do
|
9
9
|
set :views, File.dirname(__FILE__) + '/views'
|
@@ -60,7 +60,7 @@ class LessTest < Test::Unit::TestCase
|
|
60
60
|
|
61
61
|
it "raises error if template not found" do
|
62
62
|
mock_app { get('/') { less :no_such_template } }
|
63
|
-
|
63
|
+
assert_raises(Errno::ENOENT) { get('/') }
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
data/test/liquid_test.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../helper', __FILE__)
|
|
3
3
|
begin
|
4
4
|
require 'liquid'
|
5
5
|
|
6
|
-
class LiquidTest < Test
|
6
|
+
class LiquidTest < Minitest::Test
|
7
7
|
def liquid_app(&block)
|
8
8
|
mock_app do
|
9
9
|
set :views, File.dirname(__FILE__) + '/views'
|
@@ -42,7 +42,7 @@ class LiquidTest < Test::Unit::TestCase
|
|
42
42
|
|
43
43
|
it "raises error if template not found" do
|
44
44
|
mock_app { get('/') { liquid :no_such_template } }
|
45
|
-
|
45
|
+
assert_raises(Errno::ENOENT) { get('/') }
|
46
46
|
end
|
47
47
|
|
48
48
|
it "allows passing locals" do
|
@@ -53,7 +53,7 @@ class LiquidTest < Test::Unit::TestCase
|
|
53
53
|
assert_equal 'foo', body
|
54
54
|
end
|
55
55
|
|
56
|
-
it "can
|
56
|
+
it "can render truly nested layouts by accepting a layout and a block with the contents" do
|
57
57
|
mock_app do
|
58
58
|
template(:main_outer_layout) { "<h1>Title</h1>\n{{ yield }}" }
|
59
59
|
template(:an_inner_layout) { "<h2>Subtitle</h2>\n{{ yield }}" }
|
data/test/mapped_error_test.rb
CHANGED
@@ -21,7 +21,7 @@ end
|
|
21
21
|
class FirstError < RuntimeError; end
|
22
22
|
class SecondError < RuntimeError; end
|
23
23
|
|
24
|
-
class MappedErrorTest < Test
|
24
|
+
class MappedErrorTest < Minitest::Test
|
25
25
|
def test_default
|
26
26
|
assert true
|
27
27
|
end
|
@@ -104,7 +104,7 @@ class MappedErrorTest < Test::Unit::TestCase
|
|
104
104
|
set :raise_errors, true
|
105
105
|
get('/') { raise FooError }
|
106
106
|
end
|
107
|
-
|
107
|
+
assert_raises(FooError) { get '/' }
|
108
108
|
end
|
109
109
|
|
110
110
|
it "calls error handlers before raising errors even when raise_errors is set" do
|
@@ -113,7 +113,7 @@ class MappedErrorTest < Test::Unit::TestCase
|
|
113
113
|
error(FooError) { "she's there." }
|
114
114
|
get('/') { raise FooError }
|
115
115
|
end
|
116
|
-
|
116
|
+
get '/'
|
117
117
|
assert_equal 500, status
|
118
118
|
end
|
119
119
|
|
@@ -121,7 +121,7 @@ class MappedErrorTest < Test::Unit::TestCase
|
|
121
121
|
mock_app(Sinatra::Application) do
|
122
122
|
get('/') { raise Sinatra::NotFound }
|
123
123
|
end
|
124
|
-
|
124
|
+
get '/'
|
125
125
|
assert_equal 404, status
|
126
126
|
end
|
127
127
|
|
@@ -131,7 +131,7 @@ class MappedErrorTest < Test::Unit::TestCase
|
|
131
131
|
error(FooNotFound) { "foo! not found." }
|
132
132
|
get('/') { raise FooNotFound }
|
133
133
|
end
|
134
|
-
|
134
|
+
get '/'
|
135
135
|
assert_equal 404, status
|
136
136
|
assert_equal 'foo! not found.', body
|
137
137
|
end
|
data/test/markaby_test.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../helper', __FILE__)
|
|
3
3
|
begin
|
4
4
|
require 'markaby'
|
5
5
|
|
6
|
-
class MarkabyTest < Test
|
6
|
+
class MarkabyTest < Minitest::Test
|
7
7
|
def markaby_app(&block)
|
8
8
|
mock_app do
|
9
9
|
set :views, File.dirname(__FILE__) + '/views'
|
@@ -63,7 +63,7 @@ class MarkabyTest < Test::Unit::TestCase
|
|
63
63
|
|
64
64
|
it "raises error if template not found" do
|
65
65
|
mock_app { get('/') { markaby :no_such_template } }
|
66
|
-
|
66
|
+
assert_raises(Errno::ENOENT) { get('/') }
|
67
67
|
end
|
68
68
|
|
69
69
|
it "allows passing locals" do
|
data/test/markdown_test.rb
CHANGED
@@ -34,7 +34,7 @@ MarkdownTest = proc do
|
|
34
34
|
|
35
35
|
it "raises error if template not found" do
|
36
36
|
mock_app { get('/') { markdown :no_such_template } }
|
37
|
-
|
37
|
+
assert_raises(Errno::ENOENT) { get('/') }
|
38
38
|
end
|
39
39
|
|
40
40
|
it "renders with inline layouts" do
|
@@ -69,10 +69,13 @@ MarkdownTest = proc do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
# Will generate RDiscountTest, KramdownTest, etc.
|
72
|
-
Tilt.
|
72
|
+
map = Tilt.respond_to?(:lazy_map) ? Tilt.lazy_map['md'].map(&:first) : Tilt.mappings['md']
|
73
|
+
|
74
|
+
map.each do |t|
|
73
75
|
begin
|
76
|
+
t = eval(t) if t.is_a? String
|
74
77
|
t.new { "" }
|
75
|
-
klass = Class.new(Test
|
78
|
+
klass = Class.new(Minitest::Test) { define_method(:engine) { t }}
|
76
79
|
klass.class_eval(&MarkdownTest)
|
77
80
|
name = t.name[/[^:]+$/].sub(/Template$/, '') << "Test"
|
78
81
|
Object.const_set name, klass
|
data/test/mediawiki_test.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../helper', __FILE__)
|
|
3
3
|
begin
|
4
4
|
require 'wikicloth'
|
5
5
|
|
6
|
-
class MediaWikiTest < Test
|
6
|
+
class MediaWikiTest < Minitest::Test
|
7
7
|
def mediawiki_app(&block)
|
8
8
|
mock_app do
|
9
9
|
set :views, File.dirname(__FILE__) + '/views'
|
@@ -30,7 +30,7 @@ begin
|
|
30
30
|
|
31
31
|
it 'raises error if template not found' do
|
32
32
|
mock_app { get('/') { mediawiki :no_such_template } }
|
33
|
-
|
33
|
+
assert_raises(Errno::ENOENT) { get('/') }
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'renders with inline layouts' do
|
data/test/middleware_test.rb
CHANGED
data/test/nokogiri_test.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../helper', __FILE__)
|
|
3
3
|
begin
|
4
4
|
require 'nokogiri'
|
5
5
|
|
6
|
-
class NokogiriTest < Test
|
6
|
+
class NokogiriTest < Minitest::Test
|
7
7
|
def nokogiri_app(&block)
|
8
8
|
mock_app do
|
9
9
|
set :views, File.dirname(__FILE__) + '/views'
|
@@ -58,7 +58,7 @@ class NokogiriTest < Test::Unit::TestCase
|
|
58
58
|
|
59
59
|
it "raises error if template not found" do
|
60
60
|
mock_app { get('/') { nokogiri :no_such_template } }
|
61
|
-
|
61
|
+
assert_raises(Errno::ENOENT) { get('/') }
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
data/test/rabl_test.rb
CHANGED
@@ -6,7 +6,7 @@ require 'ostruct'
|
|
6
6
|
require 'json'
|
7
7
|
require 'active_support/core_ext/hash/conversions'
|
8
8
|
|
9
|
-
class RablTest < Test
|
9
|
+
class RablTest < Minitest::Test
|
10
10
|
def rabl_app(&block)
|
11
11
|
mock_app {
|
12
12
|
set :views, File.dirname(__FILE__) + '/views'
|
@@ -48,7 +48,7 @@ class RablTest < Test::Unit::TestCase
|
|
48
48
|
mock_app {
|
49
49
|
get('/') { rabl :no_such_template }
|
50
50
|
}
|
51
|
-
|
51
|
+
assert_raises(Errno::ENOENT) { get('/') }
|
52
52
|
end
|
53
53
|
|
54
54
|
it "passes rabl options to the rabl engine" do
|
data/test/rack_test.rb
CHANGED
data/test/radius_test.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../helper', __FILE__)
|
|
3
3
|
begin
|
4
4
|
require 'radius'
|
5
5
|
|
6
|
-
class RadiusTest < Test
|
6
|
+
class RadiusTest < Minitest::Test
|
7
7
|
def radius_app(&block)
|
8
8
|
mock_app do
|
9
9
|
set :views, File.dirname(__FILE__) + '/views'
|
@@ -42,7 +42,7 @@ class RadiusTest < Test::Unit::TestCase
|
|
42
42
|
|
43
43
|
it "raises error if template not found" do
|
44
44
|
mock_app { get('/') { radius :no_such_template } }
|
45
|
-
|
45
|
+
assert_raises(Errno::ENOENT) { get('/') }
|
46
46
|
end
|
47
47
|
|
48
48
|
it "allows passing locals" do
|
data/test/rdoc_test.rb
CHANGED
@@ -4,7 +4,7 @@ begin
|
|
4
4
|
require 'rdoc'
|
5
5
|
require 'rdoc/markup/to_html'
|
6
6
|
|
7
|
-
class RdocTest < Test
|
7
|
+
class RdocTest < Minitest::Test
|
8
8
|
def rdoc_app(&block)
|
9
9
|
mock_app do
|
10
10
|
set :views, File.dirname(__FILE__) + '/views'
|
@@ -16,18 +16,18 @@ class RdocTest < Test::Unit::TestCase
|
|
16
16
|
it 'renders inline rdoc strings' do
|
17
17
|
rdoc_app { rdoc '= Hiya' }
|
18
18
|
assert ok?
|
19
|
-
assert_body(/<h1[^>]*>Hiya(<span><a href=\"#label-Hiya\">¶<\/a> <a href=\"#documentation\">↑<\/a><\/span>)?<\/h1>/)
|
19
|
+
assert_body(/<h1[^>]*>Hiya(<span><a href=\"#label-Hiya\">¶<\/a> <a href=\"#(documentation|top)\">↑<\/a><\/span>)?<\/h1>/)
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'renders .rdoc files in views path' do
|
23
23
|
rdoc_app { rdoc :hello }
|
24
24
|
assert ok?
|
25
|
-
assert_body(/<h1[^>]*>Hello From RDoc(<span><a href=\"#label-Hello\+From\+RDoc\">¶<\/a> <a href=\"#documentation\">↑<\/a><\/span>)?<\/h1>/)
|
25
|
+
assert_body(/<h1[^>]*>Hello From RDoc(<span><a href=\"#label-Hello\+From\+RDoc\">¶<\/a> <a href=\"#(documentation|top)\">↑<\/a><\/span>)?<\/h1>/)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "raises error if template not found" do
|
29
29
|
mock_app { get('/') { rdoc :no_such_template } }
|
30
|
-
|
30
|
+
assert_raises(Errno::ENOENT) { get('/') }
|
31
31
|
end
|
32
32
|
|
33
33
|
it "renders with inline layouts" do
|
data/test/readme_test.rb
CHANGED
data/test/request_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path('../helper', __FILE__)
|
2
2
|
require 'stringio'
|
3
3
|
|
4
|
-
class RequestTest < Test
|
4
|
+
class RequestTest < Minitest::Test
|
5
5
|
it 'responds to #user_agent' do
|
6
6
|
request = Sinatra::Request.new({'HTTP_USER_AGENT' => 'Test'})
|
7
7
|
assert request.respond_to?(:user_agent)
|
@@ -54,6 +54,7 @@ class RequestTest < Test::Unit::TestCase
|
|
54
54
|
request = Sinatra::Request.new('HTTP_ACCEPT' => 'image/jpeg; compress=0.25')
|
55
55
|
assert request.accept?('image/jpeg')
|
56
56
|
assert_equal 'image/jpeg', request.preferred_type.to_s
|
57
|
+
assert_equal 'image/jpeg; compress=0.25', request.preferred_type.to_s(true)
|
57
58
|
assert_equal 'image/jpeg', request.preferred_type.to_str
|
58
59
|
assert_equal 'image', request.preferred_type.split('/').first
|
59
60
|
|
@@ -81,6 +82,7 @@ class RequestTest < Test::Unit::TestCase
|
|
81
82
|
assert_equal 1, request.accept.size
|
82
83
|
assert request.accept?('text/html')
|
83
84
|
assert_equal '*/*', request.preferred_type.to_s
|
85
|
+
assert_equal '*/*', request.preferred_type.to_s(true)
|
84
86
|
end
|
85
87
|
|
86
88
|
it 'accepts */* when HTTP_ACCEPT is blank in the request' do
|
@@ -88,6 +90,7 @@ class RequestTest < Test::Unit::TestCase
|
|
88
90
|
assert_equal 1, request.accept.size
|
89
91
|
assert request.accept?('text/html')
|
90
92
|
assert_equal '*/*', request.preferred_type.to_s
|
93
|
+
assert_equal '*/*', request.preferred_type.to_s(true)
|
91
94
|
end
|
92
95
|
|
93
96
|
it 'will not accept types not specified in HTTP_ACCEPT when HTTP_ACCEPT is provided' do
|
data/test/response_test.rb
CHANGED
data/test/result_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
|
-
class ResultTest < Test
|
3
|
+
class ResultTest < Minitest::Test
|
4
4
|
it "sets response.body when result is a String" do
|
5
5
|
mock_app { get('/') { 'Hello World' } }
|
6
6
|
|
@@ -63,7 +63,7 @@ class ResultTest < Test::Unit::TestCase
|
|
63
63
|
get('/') { [409, 'formula of', 'something else', 'even more'] }
|
64
64
|
}
|
65
65
|
|
66
|
-
|
66
|
+
assert_raises(ArgumentError) { get '/' }
|
67
67
|
end
|
68
68
|
|
69
69
|
it "sets status when result is a Fixnum status code" do
|
data/test/routing_test.rb
CHANGED
@@ -22,7 +22,7 @@ class RegexpLookAlike
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
class RoutingTest < Test
|
25
|
+
class RoutingTest < Minitest::Test
|
26
26
|
%w[get put post delete options patch link unlink].each do |verb|
|
27
27
|
it "defines #{verb.upcase} request handlers with #{verb}" do
|
28
28
|
mock_app {
|
@@ -263,7 +263,7 @@ class RoutingTest < Test::Unit::TestCase
|
|
263
263
|
assert_equal "format=", body
|
264
264
|
end
|
265
265
|
|
266
|
-
it 'does not
|
266
|
+
it 'does not concatenate params with the same name' do
|
267
267
|
mock_app { get('/:foo') { params[:foo] } }
|
268
268
|
get '/a?foo=b'
|
269
269
|
assert_body 'a'
|
@@ -557,7 +557,7 @@ class RoutingTest < Test::Unit::TestCase
|
|
557
557
|
end
|
558
558
|
|
559
559
|
it 'raises a TypeError when pattern is not a String or Regexp' do
|
560
|
-
|
560
|
+
assert_raises(TypeError) {
|
561
561
|
mock_app { get(42){} }
|
562
562
|
}
|
563
563
|
end
|
@@ -1184,7 +1184,7 @@ class RoutingTest < Test::Unit::TestCase
|
|
1184
1184
|
end
|
1185
1185
|
end
|
1186
1186
|
|
1187
|
-
|
1187
|
+
assert_raises(ArgumentError) { get '/a/b/c' }
|
1188
1188
|
end
|
1189
1189
|
|
1190
1190
|
it 'raises an ArgumentError with block param arity > 1 and too few values' do
|
@@ -1194,7 +1194,7 @@ class RoutingTest < Test::Unit::TestCase
|
|
1194
1194
|
end
|
1195
1195
|
}
|
1196
1196
|
|
1197
|
-
|
1197
|
+
assert_raises(ArgumentError) { get '/a/b' }
|
1198
1198
|
end
|
1199
1199
|
|
1200
1200
|
it 'succeeds if no block parameters are specified' do
|
@@ -1269,7 +1269,7 @@ class RoutingTest < Test::Unit::TestCase
|
|
1269
1269
|
end
|
1270
1270
|
}
|
1271
1271
|
|
1272
|
-
|
1272
|
+
assert_raises(ArgumentError) { get '/foo' }
|
1273
1273
|
end
|
1274
1274
|
|
1275
1275
|
it 'raises an ArgumentError with block param arity 1 and too many values' do
|
@@ -1279,7 +1279,7 @@ class RoutingTest < Test::Unit::TestCase
|
|
1279
1279
|
end
|
1280
1280
|
}
|
1281
1281
|
|
1282
|
-
|
1282
|
+
assert_raises(ArgumentError) { get '/a/b/c' }
|
1283
1283
|
end
|
1284
1284
|
|
1285
1285
|
else
|
data/test/sass_test.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../helper', __FILE__)
|
|
3
3
|
begin
|
4
4
|
require 'sass'
|
5
5
|
|
6
|
-
class SassTest < Test
|
6
|
+
class SassTest < Minitest::Test
|
7
7
|
def sass_app(options = {}, &block)
|
8
8
|
mock_app do
|
9
9
|
set :views, File.dirname(__FILE__) + '/views'
|
@@ -56,7 +56,7 @@ class SassTest < Test::Unit::TestCase
|
|
56
56
|
|
57
57
|
it "raises error if template not found" do
|
58
58
|
mock_app { get('/') { sass :no_such_template } }
|
59
|
-
|
59
|
+
assert_raises(Errno::ENOENT) { get('/') }
|
60
60
|
end
|
61
61
|
|
62
62
|
it "passes SASS options to the Sass engine" do
|
@@ -102,7 +102,7 @@ class SassTest < Test::Unit::TestCase
|
|
102
102
|
get '/'
|
103
103
|
assert ok?
|
104
104
|
assert_equal "#sass { background-color: white; color: black; }\n", body
|
105
|
-
|
105
|
+
assert_raises(Sass::SyntaxError) { get('/raised') }
|
106
106
|
get '/expanded_normal'
|
107
107
|
assert ok?
|
108
108
|
assert_equal "#sass {\n background-color: white;\n color: black;\n}\n",
|