sinatra 1.0.a → 1.0.b

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.

@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'sinatra'
6
- s.version = '1.0.a'
7
- s.date = '2010-01-28'
6
+ s.version = '1.0.b'
7
+ s.date = '2010-03-07'
8
8
 
9
9
  s.description = "Classy web-development dressed in a DSL"
10
10
  s.summary = "Classy web-development dressed in a DSL"
@@ -38,6 +38,7 @@ Gem::Specification.new do |s|
38
38
  test/haml_test.rb
39
39
  test/helper.rb
40
40
  test/helpers_test.rb
41
+ test/less_test.rb
41
42
  test/mapped_error_test.rb
42
43
  test/middleware_test.rb
43
44
  test/public/favicon.ico
@@ -62,6 +63,7 @@ Gem::Specification.new do |s|
62
63
  test/views/hello.erb
63
64
  test/views/hello.erubis
64
65
  test/views/hello.haml
66
+ test/views/hello.less
65
67
  test/views/hello.sass
66
68
  test/views/hello.test
67
69
  test/views/layout2.builder
@@ -81,6 +83,7 @@ Gem::Specification.new do |s|
81
83
  s.add_development_dependency 'haml'
82
84
  s.add_development_dependency 'builder'
83
85
  s.add_development_dependency 'erubis'
86
+ s.add_development_dependency 'less'
84
87
 
85
88
  s.has_rdoc = true
86
89
  s.homepage = "http://sinatra.rubyforge.org"
@@ -451,6 +451,15 @@ class HelpersTest < Test::Unit::TestCase
451
451
  assert_equal 304, status
452
452
  assert_equal '', body
453
453
  end
454
+
455
+ it 'ignores nil' do
456
+ mock_app {
457
+ get '/' do last_modified nil; 200; end
458
+ }
459
+
460
+ get '/'
461
+ assert ! response['Last-Modified']
462
+ end
454
463
  end
455
464
 
456
465
  describe 'etag' do
@@ -0,0 +1,37 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+ require 'less'
3
+
4
+ class LessTest < Test::Unit::TestCase
5
+ def less_app(&block)
6
+ mock_app {
7
+ set :views, File.dirname(__FILE__) + '/views'
8
+ get '/', &block
9
+ }
10
+ get '/'
11
+ end
12
+
13
+ it 'renders inline Less strings' do
14
+ less_app { less "@white_color: #fff; #main { background-color: @white_color }"}
15
+ assert ok?
16
+ assert_equal "#main { background-color: #ffffff; }\n", body
17
+ end
18
+
19
+ it 'renders .less files in views path' do
20
+ less_app { less :hello }
21
+ assert ok?
22
+ assert_equal "#main { background-color: #ffffff; }\n", body
23
+ end
24
+
25
+ it 'ignores the layout option' do
26
+ less_app { less :hello, :layout => :layout2 }
27
+ assert ok?
28
+ assert_equal "#main { background-color: #ffffff; }\n", body
29
+ end
30
+
31
+ it "raises error if template not found" do
32
+ mock_app {
33
+ get('/') { less :no_such_template }
34
+ }
35
+ assert_raise(Errno::ENOENT) { get('/') }
36
+ end
37
+ end
@@ -55,10 +55,9 @@ class MappedErrorTest < Test::Unit::TestCase
55
55
  assert_equal 'looks good', body
56
56
  end
57
57
 
58
- it "raises without calling the handler when the raise_errors options is set" do
58
+ it "raises errors from the app when raise_errors set and no handler defined" do
59
59
  mock_app {
60
60
  set :raise_errors, true
61
- error(FooError) { "she's not there." }
62
61
  get '/' do
63
62
  raise FooError
64
63
  end
@@ -66,6 +65,18 @@ class MappedErrorTest < Test::Unit::TestCase
66
65
  assert_raise(FooError) { get '/' }
67
66
  end
68
67
 
68
+ it "calls error handlers before raising errors even when raise_errors is set" do
69
+ mock_app {
70
+ set :raise_errors, true
71
+ error(FooError) { "she's there." }
72
+ get '/' do
73
+ raise FooError
74
+ end
75
+ }
76
+ assert_nothing_raised { get '/' }
77
+ assert_equal 500, status
78
+ end
79
+
69
80
  it "never raises Sinatra::NotFound beyond the application" do
70
81
  mock_app {
71
82
  set :raise_errors, true
@@ -22,7 +22,7 @@ class ServerTest < Test::Unit::TestCase
22
22
  setup do
23
23
  mock_app {
24
24
  set :server, 'mock'
25
- set :host, 'foo.local'
25
+ set :bind, 'foo.local'
26
26
  set :port, 9001
27
27
  }
28
28
  $stdout = File.open('/dev/null', 'wb')
@@ -21,6 +21,19 @@ class SettingsTest < Test::Unit::TestCase
21
21
  assert_equal 'baz', @base.foo
22
22
  end
23
23
 
24
+ it 'sets settings using a block' do
25
+ @base.set(:foo){ 'baz' }
26
+ assert @base.respond_to?(:foo)
27
+ assert_equal 'baz', @base.foo
28
+ end
29
+
30
+ it 'raises an error with a value and a block' do
31
+ assert_raise ArgumentError do
32
+ @base.set(:fiz, 'boom!'){ 'baz' }
33
+ end
34
+ assert !@base.respond_to?(:fiz)
35
+ end
36
+
24
37
  it "sets multiple settings with a Hash" do
25
38
  @base.set :foo => 1234,
26
39
  :bar => 'Hello World',
@@ -93,28 +106,33 @@ class SettingsTest < Test::Unit::TestCase
93
106
  assert !@base.bar
94
107
  end
95
108
 
96
-
97
109
  it 'is accessible from instances via #settings' do
98
110
  assert_equal :foo, @base.new.settings.environment
99
111
  end
100
112
 
101
113
  describe 'methodoverride' do
102
114
  it 'is disabled on Base' do
103
- assert ! @base.methodoverride?
115
+ assert ! @base.method_override?
104
116
  end
105
117
 
106
118
  it 'is enabled on Application' do
107
- assert @application.methodoverride?
119
+ assert @application.method_override?
108
120
  end
109
121
 
110
122
  it 'enables MethodOverride middleware' do
111
- @base.set :methodoverride, true
123
+ @base.set :method_override, true
112
124
  @base.put('/') { 'okay' }
113
125
  @app = @base
114
126
  post '/', {'_method'=>'PUT'}, {}
115
127
  assert_equal 200, status
116
128
  assert_equal 'okay', body
117
129
  end
130
+
131
+ it 'is backward compatible with methodoverride' do
132
+ assert ! @base.methodoverride?
133
+ @base.enable :methodoverride
134
+ assert @base.methodoverride?
135
+ end
118
136
  end
119
137
 
120
138
  describe 'clean_trace' do
@@ -177,10 +195,11 @@ class SettingsTest < Test::Unit::TestCase
177
195
  end
178
196
 
179
197
  describe 'raise_errors' do
180
- it 'is enabled on Base except under development' do
198
+ it 'is enabled on Base only in test' do
199
+ assert ! @base.raise_errors?
200
+
201
+ @base.set(:environment, :test)
181
202
  assert @base.raise_errors?
182
- @base.environment = :development
183
- assert !@base.raise_errors?
184
203
  end
185
204
 
186
205
  it 'is enabled on Application only in test' do
@@ -223,20 +242,20 @@ class SettingsTest < Test::Unit::TestCase
223
242
  end
224
243
 
225
244
  describe 'dump_errors' do
226
- it 'is disabled on Base except in development' do
245
+ it 'is disabled on Base in test' do
246
+ @base.environment = :test
227
247
  assert ! @base.dump_errors?
228
248
  @base.environment = :development
229
249
  assert @base.dump_errors?
230
- end
231
-
232
- it 'is enabled on Application' do
233
- assert @application.dump_errors?
250
+ @base.environment = :production
251
+ assert @base.dump_errors?
234
252
  end
235
253
 
236
254
  it 'dumps exception with backtrace to rack.errors' do
237
255
  klass = Sinatra.new(Sinatra::Application)
238
256
 
239
257
  mock_app(klass) {
258
+ enable :dump_errors
240
259
  disable :raise_errors
241
260
 
242
261
  error do
@@ -296,15 +315,27 @@ class SettingsTest < Test::Unit::TestCase
296
315
  assert @base.static?
297
316
  end
298
317
 
299
- it 'is enabled on Application' do
318
+ it 'is disabled on Application by default' do
319
+ assert ! @application.static?
320
+ end
321
+
322
+ it 'is enabled on Application when public is set and exists' do
323
+ @application.set :environment, :development
324
+ @application.set :public, File.dirname(__FILE__)
325
+ assert @application.static?
326
+ end
327
+
328
+ it 'is enabled on Application when root is set and root/public exists' do
329
+ @application.set :environment, :development
330
+ @application.set :root, File.dirname(__FILE__)
300
331
  assert @application.static?
301
332
  end
302
333
  end
303
334
 
304
- describe 'host' do
335
+ describe 'bind' do
305
336
  it 'defaults to 0.0.0.0' do
306
- assert_equal '0.0.0.0', @base.host
307
- assert_equal '0.0.0.0', @application.host
337
+ assert_equal '0.0.0.0', @base.bind
338
+ assert_equal '0.0.0.0', @application.bind
308
339
  end
309
340
  end
310
341
 
@@ -1,8 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  class TestTemplate < Tilt::Template
4
- def compile!
4
+ def prepare
5
5
  end
6
+ alias compile! prepare # for tilt < 0.7
6
7
 
7
8
  def evaluate(scope, locals={}, &block)
8
9
  inner = block ? block.call : ''
@@ -76,21 +77,18 @@ class TemplatesTest < Test::Unit::TestCase
76
77
  assert_equal "Layout 3!\nHello World!\n", body
77
78
  end
78
79
 
79
- it 'loads templates from source file with inline_templates enabled' do
80
- mock_app {
81
- enable :inline_templates
82
- }
80
+ it 'loads templates from source file' do
81
+ mock_app { enable :inline_templates }
83
82
  assert_equal "this is foo\n\n", @app.templates[:foo][0]
84
83
  assert_equal "X\n= yield\nX\n", @app.templates[:layout][0]
85
84
  end
86
85
 
87
- it 'loads templates from specified views directory' do
88
- render_app { render :test, :hello, :views => options.views + '/foo' }
89
-
90
- assert_equal "from another views directory\n", body
86
+ it 'loads templates from given source file' do
87
+ mock_app { set :inline_templates, __FILE__ }
88
+ assert_equal "this is foo\n\n", @app.templates[:foo][0]
91
89
  end
92
90
 
93
- test 'use_in_file_templates simply ignores IO errors' do
91
+ test 'inline_templates ignores IO errors' do
94
92
  assert_nothing_raised {
95
93
  mock_app {
96
94
  set :inline_templates, '/foo/bar'
@@ -100,6 +98,12 @@ class TemplatesTest < Test::Unit::TestCase
100
98
  assert @app.templates.empty?
101
99
  end
102
100
 
101
+ it 'loads templates from specified views directory' do
102
+ render_app { render :test, :hello, :views => options.views + '/foo' }
103
+
104
+ assert_equal "from another views directory\n", body
105
+ end
106
+
103
107
  it 'passes locals to the layout' do
104
108
  mock_app {
105
109
  template :my_layout do
@@ -0,0 +1,5 @@
1
+ @white_colour: #fff;
2
+
3
+ #main {
4
+ background-color: @white_colour;
5
+ }
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.a
4
+ prerelease: true
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - b
9
+ version: 1.0.b
5
10
  platform: ruby
6
11
  authors:
7
12
  - Blake Mizerany
@@ -11,72 +16,103 @@ autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
18
 
14
- date: 2010-01-28 00:00:00 -08:00
19
+ date: 2010-03-07 00:00:00 -08:00
15
20
  default_executable:
16
21
  dependencies:
17
22
  - !ruby/object:Gem::Dependency
18
23
  name: rack
19
- type: :runtime
20
- version_requirement:
21
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
22
26
  requirements:
23
27
  - - ">="
24
28
  - !ruby/object:Gem::Version
29
+ segments:
30
+ - 1
31
+ - 0
25
32
  version: "1.0"
26
- version:
33
+ type: :runtime
34
+ version_requirements: *id001
27
35
  - !ruby/object:Gem::Dependency
28
36
  name: shotgun
29
- type: :development
30
- version_requirement:
31
- version_requirements: !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
32
39
  requirements:
33
40
  - - ">="
34
41
  - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ - 6
35
45
  version: "0.6"
36
46
  - - <
37
47
  - !ruby/object:Gem::Version
48
+ segments:
49
+ - 1
50
+ - 0
38
51
  version: "1.0"
39
- version:
52
+ type: :development
53
+ version_requirements: *id002
40
54
  - !ruby/object:Gem::Dependency
41
55
  name: rack-test
42
- type: :development
43
- version_requirement:
44
- version_requirements: !ruby/object:Gem::Requirement
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
45
58
  requirements:
46
59
  - - ">="
47
60
  - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
63
+ - 3
64
+ - 0
48
65
  version: 0.3.0
49
- version:
66
+ type: :development
67
+ version_requirements: *id003
50
68
  - !ruby/object:Gem::Dependency
51
69
  name: haml
52
- type: :development
53
- version_requirement:
54
- version_requirements: !ruby/object:Gem::Requirement
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
55
72
  requirements:
56
73
  - - ">="
57
74
  - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
58
77
  version: "0"
59
- version:
78
+ type: :development
79
+ version_requirements: *id004
60
80
  - !ruby/object:Gem::Dependency
61
81
  name: builder
62
- type: :development
63
- version_requirement:
64
- version_requirements: !ruby/object:Gem::Requirement
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
65
84
  requirements:
66
85
  - - ">="
67
86
  - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
68
89
  version: "0"
69
- version:
90
+ type: :development
91
+ version_requirements: *id005
70
92
  - !ruby/object:Gem::Dependency
71
93
  name: erubis
94
+ prerelease: false
95
+ requirement: &id006 !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ segments:
100
+ - 0
101
+ version: "0"
72
102
  type: :development
73
- version_requirement:
74
- version_requirements: !ruby/object:Gem::Requirement
103
+ version_requirements: *id006
104
+ - !ruby/object:Gem::Dependency
105
+ name: less
106
+ prerelease: false
107
+ requirement: &id007 !ruby/object:Gem::Requirement
75
108
  requirements:
76
109
  - - ">="
77
110
  - !ruby/object:Gem::Version
111
+ segments:
112
+ - 0
78
113
  version: "0"
79
- version:
114
+ type: :development
115
+ version_requirements: *id007
80
116
  description: Classy web-development dressed in a DSL
81
117
  email: sinatrarb@googlegroups.com
82
118
  executables: []
@@ -111,6 +147,7 @@ files:
111
147
  - test/haml_test.rb
112
148
  - test/helper.rb
113
149
  - test/helpers_test.rb
150
+ - test/less_test.rb
114
151
  - test/mapped_error_test.rb
115
152
  - test/middleware_test.rb
116
153
  - test/public/favicon.ico
@@ -135,6 +172,7 @@ files:
135
172
  - test/views/hello.erb
136
173
  - test/views/hello.erubis
137
174
  - test/views/hello.haml
175
+ - test/views/hello.less
138
176
  - test/views/hello.sass
139
177
  - test/views/hello.test
140
178
  - test/views/layout2.builder
@@ -160,18 +198,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
198
  requirements:
161
199
  - - ">="
162
200
  - !ruby/object:Gem::Version
201
+ segments:
202
+ - 0
163
203
  version: "0"
164
- version:
165
204
  required_rubygems_version: !ruby/object:Gem::Requirement
166
205
  requirements:
167
206
  - - ">"
168
207
  - !ruby/object:Gem::Version
208
+ segments:
209
+ - 1
210
+ - 3
211
+ - 1
169
212
  version: 1.3.1
170
- version:
171
213
  requirements: []
172
214
 
173
215
  rubyforge_project: sinatra
174
- rubygems_version: 1.3.5
216
+ rubygems_version: 1.3.6
175
217
  signing_key:
176
218
  specification_version: 2
177
219
  summary: Classy web-development dressed in a DSL
@@ -184,6 +226,7 @@ test_files:
184
226
  - test/filter_test.rb
185
227
  - test/haml_test.rb
186
228
  - test/helpers_test.rb
229
+ - test/less_test.rb
187
230
  - test/mapped_error_test.rb
188
231
  - test/middleware_test.rb
189
232
  - test/request_test.rb