sinatra 1.3.0.c → 1.3.0.d

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.

@@ -313,6 +313,20 @@ class HelpersTest < Test::Unit::TestCase
313
313
  assert_body 'ok'
314
314
  end
315
315
 
316
+ it 'allows disabling session secret' do
317
+ mock_app do
318
+ enable :sessions
319
+ disable :session_secret
320
+ get '/' do
321
+ assert !env['rack.session.options'].include?(:session_secret)
322
+ 'ok'
323
+ end
324
+ end
325
+
326
+ get '/'
327
+ assert_body 'ok'
328
+ end
329
+
316
330
  it 'accepts an options hash' do
317
331
  mock_app do
318
332
  set :sessions, :foo => :bar
@@ -1,10 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
- begin
4
- fail LoadError, "rdiscount not available" if defined? JRuby
5
- require 'rdiscount'
6
-
7
- class MarkdownTest < Test::Unit::TestCase
3
+ MarkdownTest = proc do
8
4
  def markdown_app(&block)
9
5
  mock_app do
10
6
  set :views, File.dirname(__FILE__) + '/views'
@@ -13,24 +9,73 @@ class MarkdownTest < Test::Unit::TestCase
13
9
  get '/'
14
10
  end
15
11
 
12
+ def setup
13
+ Tilt.prefer engine, 'markdown', 'mkd', 'md'
14
+ super
15
+ end
16
+
17
+ it 'uses the correct engine' do
18
+ assert_equal engine, Tilt[:md]
19
+ assert_equal engine, Tilt[:mkd]
20
+ assert_equal engine, Tilt[:markdown]
21
+ end
22
+
16
23
  it 'renders inline markdown strings' do
17
24
  markdown_app { markdown '# Hiya' }
18
25
  assert ok?
19
- assert_equal "<h1>Hiya</h1>\n", body
26
+ assert_like "<h1>Hiya</h1>\n", body
20
27
  end
21
28
 
22
29
  it 'renders .markdown files in views path' do
23
30
  markdown_app { markdown :hello }
24
31
  assert ok?
25
- assert_equal "<h1>Hello From Markdown</h1>\n", body
32
+ assert_like "<h1>Hello From Markdown</h1>", body
26
33
  end
27
34
 
28
35
  it "raises error if template not found" do
29
36
  mock_app { get('/') { markdown :no_such_template } }
30
37
  assert_raise(Errno::ENOENT) { get('/') }
31
38
  end
39
+
40
+ it "renders with inline layouts" do
41
+ mock_app do
42
+ layout { 'THIS. IS. #{yield.upcase}!' }
43
+ get('/') { markdown 'Sparta', :layout_engine => :str }
44
+ end
45
+ get '/'
46
+ assert ok?
47
+ assert_like 'THIS. IS. <P>SPARTA</P>!', body
48
+ end
49
+
50
+ it "renders with file layouts" do
51
+ markdown_app { markdown 'Hello World', :layout => :layout2, :layout_engine => :erb }
52
+ assert ok?
53
+ assert_body "ERB Layout!\n<p>Hello World</p>"
54
+ end
55
+
56
+ it "can be used in a nested fashion for partials and whatnot" do
57
+ mock_app do
58
+ template(:inner) { "hi" }
59
+ template(:outer) { "<outer><%= markdown :inner %></outer>" }
60
+ get '/' do
61
+ erb :outer
62
+ end
63
+ end
64
+
65
+ get '/'
66
+ assert ok?
67
+ assert_like '<outer><p>hi</p></outer>', body
68
+ end
32
69
  end
33
70
 
34
- rescue LoadError
35
- warn "#{$!.to_s}: skipping markdown tests"
71
+ # Will generate RDiscountTest, KramdownTest, etc.
72
+ Tilt.mappings['md'].each do |t|
73
+ begin
74
+ t.new { "" }
75
+ klass = Class.new(Test::Unit::TestCase) { define_method(:engine) { t }}
76
+ klass.class_eval(&MarkdownTest)
77
+ Object.const_set t.name[/[^:]+(?=Template$)/] << "Test", klass
78
+ rescue LoadError
79
+ warn "#{$!}: skipping markdown tests with #{t}"
80
+ end
36
81
  end
@@ -1,7 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  begin
4
- fail LoadError, 'Radius broken on 1.9.' if RUBY_VERSION >= '1.9.1'
5
4
  require 'radius'
6
5
 
7
6
  class RadiusTest < Test::Unit::TestCase
@@ -28,6 +28,36 @@ class RdocTest < Test::Unit::TestCase
28
28
  mock_app { get('/') { rdoc :no_such_template } }
29
29
  assert_raise(Errno::ENOENT) { get('/') }
30
30
  end
31
+
32
+ it "renders with inline layouts" do
33
+ mock_app do
34
+ layout { 'THIS. IS. #{yield.upcase}!' }
35
+ get('/') { rdoc 'Sparta', :layout_engine => :str }
36
+ end
37
+ get '/'
38
+ assert ok?
39
+ assert_like 'THIS. IS.<P>SPARTA</P>!', body
40
+ end
41
+
42
+ it "renders with file layouts" do
43
+ rdoc_app { rdoc 'Hello World', :layout => :layout2, :layout_engine => :erb }
44
+ assert ok?
45
+ assert_body "ERB Layout!\n<p>Hello World</p>"
46
+ end
47
+
48
+ it "can be used in a nested fashion for partials and whatnot" do
49
+ mock_app do
50
+ template(:inner) { "hi" }
51
+ template(:outer) { "<outer><%= rdoc :inner %></outer>" }
52
+ get '/' do
53
+ erb :outer
54
+ end
55
+ end
56
+
57
+ get '/'
58
+ assert ok?
59
+ assert_like '<outer><p>hi</p></outer>', body
60
+ end
31
61
  end
32
62
 
33
63
  rescue LoadError
@@ -686,10 +686,10 @@ class RoutingTest < Test::Unit::TestCase
686
686
  it "filters by accept header" do
687
687
  mock_app {
688
688
  get '/', :provides => :xml do
689
- request.env['HTTP_ACCEPT']
689
+ env['HTTP_ACCEPT']
690
690
  end
691
691
  get '/foo', :provides => :html do
692
- request.env['HTTP_ACCEPT']
692
+ env['HTTP_ACCEPT']
693
693
  end
694
694
  }
695
695
 
@@ -714,7 +714,7 @@ class RoutingTest < Test::Unit::TestCase
714
714
 
715
715
  mock_app {
716
716
  get '/', :provides => types do
717
- request.env['HTTP_ACCEPT']
717
+ env['HTTP_ACCEPT']
718
718
  end
719
719
  }
720
720
 
@@ -729,7 +729,7 @@ class RoutingTest < Test::Unit::TestCase
729
729
  it 'degrades gracefully when optional accept header is not provided' do
730
730
  mock_app {
731
731
  get '/', :provides => :xml do
732
- request.env['HTTP_ACCEPT']
732
+ env['HTTP_ACCEPT']
733
733
  end
734
734
  get '/' do
735
735
  'default'
@@ -1042,4 +1042,35 @@ class RoutingTest < Test::Unit::TestCase
1042
1042
  get '/foo'
1043
1043
  assert not_found?
1044
1044
  end
1045
+
1046
+ it 'allows using call to fire another request internally' do
1047
+ mock_app do
1048
+ get '/foo' do
1049
+ status, headers, body = call env.merge("PATH_INFO" => '/bar')
1050
+ [status, headers, body.map(&:upcase)]
1051
+ end
1052
+
1053
+ get '/bar' do
1054
+ "bar"
1055
+ end
1056
+ end
1057
+
1058
+ get '/foo'
1059
+ assert ok?
1060
+ assert_body "BAR"
1061
+ end
1062
+
1063
+ it 'plays well with other routing middleware' do
1064
+ middleware = Sinatra.new
1065
+ inner_app = Sinatra.new { get('/foo') { 'hello' } }
1066
+ builder = Rack::Builder.new do
1067
+ use middleware
1068
+ map('/test') { run inner_app }
1069
+ end
1070
+
1071
+ @app = builder.to_app
1072
+ get '/test/foo'
1073
+ assert ok?
1074
+ assert_body 'hello'
1075
+ end
1045
1076
  end
@@ -34,6 +34,24 @@ class SettingsTest < Test::Unit::TestCase
34
34
  assert !@base.respond_to?(:fiz)
35
35
  end
36
36
 
37
+ it 'raises an error without value and block' do
38
+ assert_raise(ArgumentError) { @base.set(:fiz) }
39
+ assert !@base.respond_to?(:fiz)
40
+ end
41
+
42
+ it 'allows setting a value to the app class' do
43
+ @base.set :base, @base
44
+ assert @base.respond_to?(:base)
45
+ assert_equal @base, @base.base
46
+ end
47
+
48
+ it 'raises an error with the app class as value and a block' do
49
+ assert_raise ArgumentError do
50
+ @base.set(:fiz, @base) { 'baz' }
51
+ end
52
+ assert !@base.respond_to?(:fiz)
53
+ end
54
+
37
55
  it "sets multiple settings with a Hash" do
38
56
  @base.set :foo => 1234,
39
57
  :bar => 'Hello World',
@@ -28,6 +28,36 @@ class TextileTest < Test::Unit::TestCase
28
28
  mock_app { get('/') { textile :no_such_template } }
29
29
  assert_raise(Errno::ENOENT) { get('/') }
30
30
  end
31
+
32
+ it "renders with inline layouts" do
33
+ mock_app do
34
+ layout { 'THIS. IS. #{yield.upcase}!' }
35
+ get('/') { textile 'Sparta', :layout_engine => :str }
36
+ end
37
+ get '/'
38
+ assert ok?
39
+ assert_like 'THIS. IS. <P>SPARTA</P>!', body
40
+ end
41
+
42
+ it "renders with file layouts" do
43
+ textile_app { textile 'Hello World', :layout => :layout2, :layout_engine => :erb }
44
+ assert ok?
45
+ assert_body "ERB Layout!\n<p>Hello World</p>"
46
+ end
47
+
48
+ it "can be used in a nested fashion for partials and whatnot" do
49
+ mock_app do
50
+ template(:inner) { "hi" }
51
+ template(:outer) { "<outer><%= textile :inner %></outer>" }
52
+ get '/' do
53
+ erb :outer
54
+ end
55
+ end
56
+
57
+ get '/'
58
+ assert ok?
59
+ assert_like '<outer><p>hi</p></outer>', body
60
+ end
31
61
  end
32
62
 
33
63
  rescue LoadError
@@ -0,0 +1 @@
1
+ = Hello From Creole
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sinatra
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 1.3.0.c
5
+ version: 1.3.0.d
6
6
  platform: ruby
7
7
  authors:
8
8
  - Blake Mizerany
@@ -13,8 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2011-04-13 00:00:00 +02:00
17
- default_executable:
16
+ date: 2011-04-30 00:00:00 Z
18
17
  dependencies:
19
18
  - !ruby/object:Gem::Dependency
20
19
  name: rack
@@ -34,10 +33,7 @@ dependencies:
34
33
  requirements:
35
34
  - - ~>
36
35
  - !ruby/object:Gem::Version
37
- version: "1.2"
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 1.2.2
36
+ version: "1.3"
41
37
  type: :runtime
42
38
  prerelease: false
43
39
  version_requirements: *id002
@@ -95,10 +91,10 @@ files:
95
91
  - test/builder_test.rb
96
92
  - test/coffee_test.rb
97
93
  - test/contest.rb
94
+ - test/creole_test.rb
98
95
  - test/delegator_test.rb
99
96
  - test/encoding_test.rb
100
97
  - test/erb_test.rb
101
- - test/erubis_test.rb
102
98
  - test/extensions_test.rb
103
99
  - test/filter_test.rb
104
100
  - test/haml_test.rb
@@ -134,15 +130,14 @@ files:
134
130
  - test/views/calc.html.erb
135
131
  - test/views/error.builder
136
132
  - test/views/error.erb
137
- - test/views/error.erubis
138
133
  - test/views/error.haml
139
134
  - test/views/error.sass
140
135
  - test/views/explicitly_nested.str
141
136
  - test/views/foo/hello.test
142
137
  - test/views/hello.builder
143
138
  - test/views/hello.coffee
139
+ - test/views/hello.creole
144
140
  - test/views/hello.erb
145
- - test/views/hello.erubis
146
141
  - test/views/hello.haml
147
142
  - test/views/hello.less
148
143
  - test/views/hello.liquid
@@ -159,7 +154,6 @@ files:
159
154
  - test/views/hello.textile
160
155
  - test/views/layout2.builder
161
156
  - test/views/layout2.erb
162
- - test/views/layout2.erubis
163
157
  - test/views/layout2.haml
164
158
  - test/views/layout2.liquid
165
159
  - test/views/layout2.mab
@@ -170,7 +164,6 @@ files:
170
164
  - test/views/layout2.test
171
165
  - test/views/nested.str
172
166
  - test/views/utf8.erb
173
- has_rdoc: true
174
167
  homepage: http://sinatra.rubyforge.org
175
168
  licenses: []
176
169
 
@@ -189,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
182
  requirements:
190
183
  - - ">="
191
184
  - !ruby/object:Gem::Version
192
- hash: -1589888549486616538
185
+ hash: -3511635882760576003
193
186
  segments:
194
187
  - 0
195
188
  version: "0"
@@ -202,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
195
  requirements: []
203
196
 
204
197
  rubyforge_project: sinatra
205
- rubygems_version: 1.6.2
198
+ rubygems_version: 1.7.2
206
199
  signing_key:
207
200
  specification_version: 2
208
201
  summary: Classy web-development dressed in a DSL
@@ -210,10 +203,10 @@ test_files:
210
203
  - test/base_test.rb
211
204
  - test/builder_test.rb
212
205
  - test/coffee_test.rb
206
+ - test/creole_test.rb
213
207
  - test/delegator_test.rb
214
208
  - test/encoding_test.rb
215
209
  - test/erb_test.rb
216
- - test/erubis_test.rb
217
210
  - test/extensions_test.rb
218
211
  - test/filter_test.rb
219
212
  - test/haml_test.rb
@@ -1,88 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- begin
4
- require 'erubis'
5
-
6
- class ERubisTest < Test::Unit::TestCase
7
- def erubis_app(&block)
8
- mock_app {
9
- set :views, File.dirname(__FILE__) + '/views'
10
- get '/', &block
11
- }
12
- get '/'
13
- end
14
-
15
- it 'renders inline ERubis strings' do
16
- erubis_app { erubis '<%= 1 + 1 %>' }
17
- assert ok?
18
- assert_equal '2', body
19
- end
20
-
21
- it 'renders .erubis files in views path' do
22
- erubis_app { erubis :hello }
23
- assert ok?
24
- assert_equal "Hello World\n", body
25
- end
26
-
27
- it 'takes a :locals option' do
28
- erubis_app {
29
- locals = {:foo => 'Bar'}
30
- erubis '<%= foo %>', :locals => locals
31
- }
32
- assert ok?
33
- assert_equal 'Bar', body
34
- end
35
-
36
- it "renders with inline layouts" do
37
- mock_app {
38
- layout { 'THIS. IS. <%= yield.upcase %>!' }
39
- get('/') { erubis 'Sparta' }
40
- }
41
- get '/'
42
- assert ok?
43
- assert_equal 'THIS. IS. SPARTA!', body
44
- end
45
-
46
- it "renders with file layouts" do
47
- erubis_app {
48
- erubis 'Hello World', :layout => :layout2
49
- }
50
- assert ok?
51
- assert_equal "ERubis Layout!\nHello World\n", body
52
- end
53
-
54
- it "renders erubis with blocks" do
55
- mock_app {
56
- def container
57
- @_out_buf << "THIS."
58
- yield
59
- @_out_buf << "SPARTA!"
60
- end
61
- def is; "IS." end
62
- get '/' do
63
- erubis '<% container do %> <%= is %> <% end %>'
64
- end
65
- }
66
- get '/'
67
- assert ok?
68
- assert_equal 'THIS. IS. SPARTA!', body
69
- end
70
-
71
- it "can be used in a nested fashion for partials and whatnot" do
72
- mock_app {
73
- template(:inner) { "<inner><%= 'hi' %></inner>" }
74
- template(:outer) { "<outer><%= erubis :inner %></outer>" }
75
- get '/' do
76
- erubis :outer
77
- end
78
- }
79
-
80
- get '/'
81
- assert ok?
82
- assert_equal '<outer><inner>hi</inner></outer>', body
83
- end
84
- end
85
-
86
- rescue LoadError
87
- warn "#{$!.to_s}: skipping erubis tests"
88
- end