sinatra 1.3.2 → 1.3.3
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 +27 -0
- data/Gemfile +11 -6
- data/README.de.rdoc +332 -196
- data/README.es.rdoc +41 -6
- data/README.fr.rdoc +58 -5
- data/README.jp.rdoc +1 -1
- data/README.ko.rdoc +1926 -0
- data/README.pt-br.rdoc +1 -1
- data/README.pt-pt.rdoc +1 -1
- data/README.rdoc +94 -71
- data/README.ru.rdoc +1 -1
- data/README.zh.rdoc +1 -1
- data/Rakefile +2 -1
- data/lib/sinatra.rb +0 -3
- data/lib/sinatra/base.rb +91 -33
- data/lib/sinatra/version.rb +1 -1
- data/sinatra.gemspec +1 -1
- data/test/delegator_test.rb +1 -1
- data/test/filter_test.rb +3 -3
- data/test/helpers_test.rb +5 -5
- data/test/integration/app.rb +57 -1
- data/test/integration_helper.rb +214 -0
- data/test/integration_test.rb +68 -48
- data/test/routing_test.rb +6 -0
- data/test/sass_test.rb +1 -0
- data/test/scss_test.rb +1 -0
- data/test/static_test.rb +1 -0
- data/test/streaming_test.rb +17 -0
- metadata +93 -56
data/test/integration_test.rb
CHANGED
@@ -1,65 +1,85 @@
|
|
1
1
|
require File.expand_path('../helper', __FILE__)
|
2
|
-
require '
|
3
|
-
require 'open-uri'
|
4
|
-
require 'timeout'
|
2
|
+
require File.expand_path('../integration_helper', __FILE__)
|
5
3
|
|
4
|
+
# These tests start a real server and talk to it over TCP.
|
5
|
+
# Every test runs with every detected server.
|
6
|
+
#
|
7
|
+
# See test/integration/app.rb for the code of the app we test against.
|
6
8
|
class IntegrationTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
extend IntegrationHelper
|
10
|
+
attr_accessor :server
|
11
|
+
|
12
|
+
it('sets the app_file') { assert_equal server.app_file, server.get("/app_file") }
|
10
13
|
|
11
|
-
|
12
|
-
|
14
|
+
it 'logs once in development mode' do
|
15
|
+
random = "%064x" % Kernel.rand(2**256-1)
|
16
|
+
server.get "/ping?x=#{random}"
|
17
|
+
count = server.log.scan("GET /ping?x=#{random}").count
|
18
|
+
server.webrick? ? assert(count > 0) : assert_equal(1, count)
|
13
19
|
end
|
14
20
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
it 'streams' do
|
22
|
+
next if server.webrick?
|
23
|
+
times, chunks = [Time.now], []
|
24
|
+
server.get_stream do |chunk|
|
25
|
+
next if chunk.empty?
|
26
|
+
chunks << chunk
|
27
|
+
times << Time.now
|
22
28
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
29
|
+
assert_equal ["a", "b"], chunks
|
30
|
+
assert times[1] - times[0] < 1
|
31
|
+
assert times[2] - times[1] > 1
|
26
32
|
end
|
27
33
|
|
28
|
-
|
29
|
-
|
30
|
-
loop { out << pipe.read_nonblock(1) }
|
31
|
-
rescue
|
32
|
-
$stderr.puts command, out unless out.empty?
|
33
|
-
end
|
34
|
+
it 'streams async' do
|
35
|
+
next unless server.thin?
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
Timeout.timeout(3) do
|
38
|
+
chunks = []
|
39
|
+
server.get_stream '/async' do |chunk|
|
40
|
+
next if chunk.empty?
|
41
|
+
chunks << chunk
|
42
|
+
case chunk
|
43
|
+
when "hi!" then server.get "/send?msg=hello"
|
44
|
+
when "hello" then server.get "/send?close=1"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_equal ['hi!', 'hello'], chunks
|
49
|
+
end
|
39
50
|
end
|
40
51
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
Timeout.timeout(
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
52
|
+
it 'streams async from subclass' do
|
53
|
+
next unless server.thin?
|
54
|
+
|
55
|
+
Timeout.timeout(3) do
|
56
|
+
chunks = []
|
57
|
+
server.get_stream '/subclass/async' do |chunk|
|
58
|
+
next if chunk.empty?
|
59
|
+
chunks << chunk
|
60
|
+
case chunk
|
61
|
+
when "hi!" then server.get "/subclass/send?msg=hello"
|
62
|
+
when "hello" then server.get "/subclass/send?close=1"
|
63
|
+
end
|
51
64
|
end
|
65
|
+
|
66
|
+
assert_equal ['hi!', 'hello'], chunks
|
52
67
|
end
|
53
|
-
kill(pipe.pid) if pipe
|
54
|
-
rescue Timeout::Error => e
|
55
|
-
display_output pipe
|
56
|
-
kill(pipe.pid, "KILL") if pipe
|
57
|
-
raise error || e
|
58
68
|
end
|
59
69
|
|
60
|
-
it 'starts
|
61
|
-
|
62
|
-
|
63
|
-
|
70
|
+
it 'starts the correct server' do
|
71
|
+
exp = %r{
|
72
|
+
==\sSinatra/#{Sinatra::VERSION}\s
|
73
|
+
has\staken\sthe\sstage\son\s\d+\sfor\sdevelopment\s
|
74
|
+
with\sbackup\sfrom\s#{server}
|
75
|
+
}ix
|
76
|
+
|
77
|
+
assert_match exp, server.log
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'does not generate warnings' do
|
81
|
+
assert_raise(OpenURI::HTTPError) { server.get '/' }
|
82
|
+
server.get '/app_file'
|
83
|
+
assert_equal [], server.warnings
|
64
84
|
end
|
65
|
-
end
|
85
|
+
end
|
data/test/routing_test.rb
CHANGED
@@ -236,6 +236,12 @@ class RoutingTest < Test::Unit::TestCase
|
|
236
236
|
assert_equal "format=", body
|
237
237
|
end
|
238
238
|
|
239
|
+
it 'does not concatinate params with the same name' do
|
240
|
+
mock_app { get('/:foo') { params[:foo] } }
|
241
|
+
get '/a?foo=b'
|
242
|
+
assert_body 'a'
|
243
|
+
end
|
244
|
+
|
239
245
|
it "supports single splat params like /*" do
|
240
246
|
mock_app {
|
241
247
|
get '/*' do
|
data/test/sass_test.rb
CHANGED
data/test/scss_test.rb
CHANGED
data/test/static_test.rb
CHANGED
data/test/streaming_test.rb
CHANGED
@@ -120,4 +120,21 @@ class StreamingTest < Test::Unit::TestCase
|
|
120
120
|
get '/foo'
|
121
121
|
assert_body 'foo'
|
122
122
|
end
|
123
|
+
|
124
|
+
it 'sets up async.close if available' do
|
125
|
+
ran = false
|
126
|
+
mock_app do
|
127
|
+
get('/') do
|
128
|
+
close = Object.new
|
129
|
+
def close.callback; yield end
|
130
|
+
def close.errback; end
|
131
|
+
env['async.close'] = close
|
132
|
+
stream(:keep_open) do |out|
|
133
|
+
out.callback { ran = true }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
get '/'
|
138
|
+
assert ran
|
139
|
+
end
|
123
140
|
end
|
metadata
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 3
|
9
|
+
- 3
|
10
|
+
version: 1.3.3
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Blake Mizerany
|
9
14
|
- Ryan Tomayko
|
10
15
|
- Simon Rozet
|
@@ -12,65 +17,91 @@ authors:
|
|
12
17
|
autorequire:
|
13
18
|
bindir: bin
|
14
19
|
cert_chain: []
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
|
21
|
+
date: 2012-08-19 00:00:00 +02:00
|
22
|
+
default_executable:
|
23
|
+
dependencies:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
20
26
|
none: false
|
21
|
-
requirements:
|
27
|
+
requirements:
|
22
28
|
- - ~>
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
|
25
|
-
|
26
|
-
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 9
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 3
|
34
|
+
version: "1.3"
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
hash: 23
|
38
|
+
segments:
|
39
|
+
- 1
|
40
|
+
- 3
|
41
|
+
- 6
|
27
42
|
version: 1.3.6
|
28
|
-
|
43
|
+
requirement: *id001
|
29
44
|
prerelease: false
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
45
|
+
name: rack
|
46
|
+
type: :runtime
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
34
49
|
none: false
|
35
|
-
requirements:
|
50
|
+
requirements:
|
36
51
|
- - ~>
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
|
39
|
-
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 11
|
54
|
+
segments:
|
55
|
+
- 1
|
56
|
+
- 2
|
57
|
+
version: "1.2"
|
58
|
+
requirement: *id002
|
40
59
|
prerelease: false
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
60
|
+
name: rack-protection
|
61
|
+
type: :runtime
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
45
64
|
none: false
|
46
|
-
requirements:
|
65
|
+
requirements:
|
47
66
|
- - ~>
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
|
50
|
-
|
51
|
-
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
hash: 9
|
69
|
+
segments:
|
70
|
+
- 1
|
71
|
+
- 3
|
72
|
+
version: "1.3"
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 29
|
76
|
+
segments:
|
77
|
+
- 1
|
78
|
+
- 3
|
79
|
+
- 3
|
52
80
|
version: 1.3.3
|
53
|
-
|
81
|
+
requirement: *id003
|
54
82
|
prerelease: false
|
55
|
-
|
56
|
-
|
57
|
-
|
83
|
+
name: tilt
|
84
|
+
type: :runtime
|
85
|
+
description: Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort.
|
58
86
|
email: sinatrarb@googlegroups.com
|
59
87
|
executables: []
|
88
|
+
|
60
89
|
extensions: []
|
61
|
-
|
90
|
+
|
91
|
+
extra_rdoc_files:
|
62
92
|
- README.de.rdoc
|
63
93
|
- README.es.rdoc
|
64
94
|
- README.fr.rdoc
|
65
95
|
- README.hu.rdoc
|
66
96
|
- README.jp.rdoc
|
97
|
+
- README.ko.rdoc
|
67
98
|
- README.pt-br.rdoc
|
68
99
|
- README.pt-pt.rdoc
|
69
100
|
- README.rdoc
|
70
101
|
- README.ru.rdoc
|
71
102
|
- README.zh.rdoc
|
72
103
|
- LICENSE
|
73
|
-
files:
|
104
|
+
files:
|
74
105
|
- .yardopts
|
75
106
|
- AUTHORS
|
76
107
|
- CHANGES
|
@@ -81,6 +112,7 @@ files:
|
|
81
112
|
- README.fr.rdoc
|
82
113
|
- README.hu.rdoc
|
83
114
|
- README.jp.rdoc
|
115
|
+
- README.ko.rdoc
|
84
116
|
- README.pt-br.rdoc
|
85
117
|
- README.pt-pt.rdoc
|
86
118
|
- README.rdoc
|
@@ -112,6 +144,7 @@ files:
|
|
112
144
|
- test/helper.rb
|
113
145
|
- test/helpers_test.rb
|
114
146
|
- test/integration/app.rb
|
147
|
+
- test/integration_helper.rb
|
115
148
|
- test/integration_test.rb
|
116
149
|
- test/less_test.rb
|
117
150
|
- test/liquid_test.rb
|
@@ -180,43 +213,47 @@ files:
|
|
180
213
|
- test/views/layout2.test
|
181
214
|
- test/views/nested.str
|
182
215
|
- test/views/utf8.erb
|
216
|
+
has_rdoc: true
|
183
217
|
homepage: http://www.sinatrarb.com/
|
184
218
|
licenses: []
|
219
|
+
|
185
220
|
post_install_message:
|
186
|
-
rdoc_options:
|
221
|
+
rdoc_options:
|
187
222
|
- --line-numbers
|
188
223
|
- --inline-source
|
189
224
|
- --title
|
190
225
|
- Sinatra
|
191
226
|
- --main
|
192
227
|
- README.rdoc
|
193
|
-
|
228
|
+
- --encoding=UTF-8
|
229
|
+
require_paths:
|
194
230
|
- lib
|
195
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
231
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
196
232
|
none: false
|
197
|
-
requirements:
|
198
|
-
- -
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
|
201
|
-
segments:
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
hash: 3
|
237
|
+
segments:
|
202
238
|
- 0
|
203
|
-
|
204
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
|
+
version: "0"
|
240
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
241
|
none: false
|
206
|
-
requirements:
|
207
|
-
- -
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
|
210
|
-
segments:
|
242
|
+
requirements:
|
243
|
+
- - ">="
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
hash: 3
|
246
|
+
segments:
|
211
247
|
- 0
|
212
|
-
|
248
|
+
version: "0"
|
213
249
|
requirements: []
|
250
|
+
|
214
251
|
rubyforge_project:
|
215
|
-
rubygems_version: 1.
|
252
|
+
rubygems_version: 1.6.2
|
216
253
|
signing_key:
|
217
254
|
specification_version: 3
|
218
255
|
summary: Classy web-development dressed in a DSL
|
219
|
-
test_files:
|
256
|
+
test_files:
|
220
257
|
- test/base_test.rb
|
221
258
|
- test/builder_test.rb
|
222
259
|
- test/coffee_test.rb
|