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.

@@ -1,65 +1,85 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
- require 'rbconfig'
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
- def app_file
8
- File.expand_path('../integration/app.rb', __FILE__)
9
- end
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
- def port
12
- 5000 + (Process.pid % 1000)
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
- def command
16
- cmd = ['exec']
17
- if RbConfig.respond_to? :ruby
18
- cmd << RbConfig.ruby.inspect
19
- else
20
- file, dir = RbConfig::CONFIG.values_at('ruby_install_name', 'bindir')
21
- cmd << File.expand_path(file, dir).inspect
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
- cmd << "-I" << File.expand_path('../../lib', __FILE__).inspect
24
- cmd << app_file.inspect << '-p' << port << '2>&1'
25
- cmd.join(" ")
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
- def display_output(pipe)
29
- out = ""
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
- def kill(pid, signal = "TERM")
36
- Process.kill(signal, pid)
37
- rescue NotImplementedError
38
- system "kill -s #{signal} #{pid}"
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
- def with_server
42
- pipe = IO.popen(command)
43
- error = nil
44
- Timeout.timeout(120) do
45
- begin
46
- yield
47
- rescue Errno::ECONNREFUSED => e
48
- error = e
49
- sleep 0.1
50
- retry
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 a top level application' do
61
- with_server do
62
- assert_equal open("http://127.0.0.1:#{port}/app_file").read, app_file
63
- end
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
@@ -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
@@ -1,6 +1,7 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  begin
4
+ raise LoadError, 'sass not supported on Ruby 2.0' if RUBY_VERSION >= '2.0'
4
5
  require 'sass'
5
6
 
6
7
  class SassTest < Test::Unit::TestCase
@@ -1,6 +1,7 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  begin
4
+ raise LoadError, 'sass not supported on Ruby 2.0' if RUBY_VERSION >= '2.0'
4
5
  require 'sass'
5
6
 
6
7
  class ScssTest < Test::Unit::TestCase
@@ -37,6 +37,7 @@ class StaticTest < Test::Unit::TestCase
37
37
  assert ok?
38
38
  assert_equal '', body
39
39
  assert response.headers.include?('Last-Modified')
40
+ assert_equal File.size(__FILE__).to_s, response['Content-Length']
40
41
  end
41
42
 
42
43
  %w[POST PUT DELETE].each do |verb|
@@ -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
- version: 1.3.2
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
- date: 2011-12-30 00:00:00.000000000 Z
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
18
- name: rack
19
- requirement: &2153237200 !ruby/object:Gem::Requirement
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
- version: '1.3'
25
- - - ! '>='
26
- - !ruby/object:Gem::Version
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
- type: :runtime
43
+ requirement: *id001
29
44
  prerelease: false
30
- version_requirements: *2153237200
31
- - !ruby/object:Gem::Dependency
32
- name: rack-protection
33
- requirement: &2153236060 !ruby/object:Gem::Requirement
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
- version: '1.2'
39
- type: :runtime
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
- version_requirements: *2153236060
42
- - !ruby/object:Gem::Dependency
43
- name: tilt
44
- requirement: &2153235320 !ruby/object:Gem::Requirement
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
- version: '1.3'
50
- - - ! '>='
51
- - !ruby/object:Gem::Version
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
- type: :runtime
81
+ requirement: *id003
54
82
  prerelease: false
55
- version_requirements: *2153235320
56
- description: Sinatra is a DSL for quickly creating web applications in Ruby with minimal
57
- effort.
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
- extra_rdoc_files:
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
- require_paths:
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
- version: '0'
201
- segments:
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ hash: 3
237
+ segments:
202
238
  - 0
203
- hash: 2805773660361067313
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
- version: '0'
210
- segments:
242
+ requirements:
243
+ - - ">="
244
+ - !ruby/object:Gem::Version
245
+ hash: 3
246
+ segments:
211
247
  - 0
212
- hash: 2805773660361067313
248
+ version: "0"
213
249
  requirements: []
250
+
214
251
  rubyforge_project:
215
- rubygems_version: 1.8.10
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