padrino-core 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/padrino-core.rb +4 -4
- data/lib/padrino-core/application.rb +6 -195
- data/lib/padrino-core/application/application_setup.rb +199 -0
- data/lib/padrino-core/application/routing.rb +66 -25
- data/lib/padrino-core/cli/base.rb +8 -5
- data/lib/padrino-core/cli/rake.rb +12 -9
- data/lib/padrino-core/loader.rb +1 -1
- data/lib/padrino-core/logger.rb +25 -0
- data/lib/padrino-core/mounter.rb +8 -3
- data/lib/padrino-core/reloader.rb +2 -2
- data/lib/padrino-core/server.rb +50 -17
- data/lib/padrino-core/version.rb +1 -1
- data/padrino-core.gemspec +2 -10
- data/test/fixtures/apps/demo_app.rb +7 -0
- data/test/fixtures/apps/demo_demo.rb +7 -0
- data/test/helper.rb +6 -37
- data/test/test_application.rb +12 -13
- data/test/test_core.rb +12 -13
- data/test/test_csrf_protection.rb +49 -23
- data/test/test_dependencies.rb +7 -7
- data/test/test_filters.rb +41 -17
- data/test/test_flash.rb +24 -24
- data/test/test_locale.rb +1 -1
- data/test/test_logger.rb +39 -27
- data/test/test_mounter.rb +34 -20
- data/test/test_reloader_complex.rb +5 -6
- data/test/test_reloader_simple.rb +23 -20
- data/test/test_reloader_system.rb +10 -7
- data/test/test_restful_routing.rb +1 -1
- data/test/test_router.rb +7 -7
- data/test/test_routing.rb +177 -141
- metadata +14 -53
- data/lib/padrino-core/application/rendering.rb +0 -325
- data/lib/padrino-core/application/rendering/extensions/erubis.rb +0 -68
- data/lib/padrino-core/application/rendering/extensions/haml.rb +0 -29
- data/lib/padrino-core/application/rendering/extensions/slim.rb +0 -21
- data/lib/padrino-core/locale/cs.yml +0 -33
- data/lib/padrino-core/locale/da.yml +0 -33
- data/lib/padrino-core/locale/de.yml +0 -33
- data/lib/padrino-core/locale/en.yml +0 -33
- data/lib/padrino-core/locale/es.yml +0 -33
- data/lib/padrino-core/locale/fr.yml +0 -33
- data/lib/padrino-core/locale/hu.yml +0 -33
- data/lib/padrino-core/locale/it.yml +0 -39
- data/lib/padrino-core/locale/ja.yml +0 -33
- data/lib/padrino-core/locale/lv.yml +0 -33
- data/lib/padrino-core/locale/nl.yml +0 -33
- data/lib/padrino-core/locale/no.yml +0 -33
- data/lib/padrino-core/locale/pl.yml +0 -33
- data/lib/padrino-core/locale/pt_br.yml +0 -39
- data/lib/padrino-core/locale/ro.yml +0 -33
- data/lib/padrino-core/locale/ru.yml +0 -34
- data/lib/padrino-core/locale/sv.yml +0 -33
- data/lib/padrino-core/locale/tr.yml +0 -33
- data/lib/padrino-core/locale/uk.yml +0 -33
- data/lib/padrino-core/locale/zh_cn.yml +0 -33
- data/lib/padrino-core/locale/zh_tw.yml +0 -33
- data/lib/padrino-core/support_lite.rb +0 -259
- data/test/fixtures/apps/.components +0 -6
- data/test/fixtures/apps/.gitignore +0 -7
- data/test/fixtures/apps/render.rb +0 -13
- data/test/fixtures/apps/views/blog/post.erb +0 -1
- data/test/fixtures/layouts/layout.erb +0 -1
- data/test/mini_shoulda.rb +0 -45
- data/test/test_rendering.rb +0 -606
- data/test/test_rendering_extensions.rb +0 -14
- data/test/test_support_lite.rb +0 -56
data/test/test_filters.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
2
|
|
3
3
|
describe "Filters" do
|
4
|
-
should
|
4
|
+
it 'should filters by accept header' do
|
5
5
|
mock_app do
|
6
6
|
get '/foo', :provides => [:xml, :js] do
|
7
7
|
request.env['HTTP_ACCEPT']
|
@@ -30,7 +30,7 @@ describe "Filters" do
|
|
30
30
|
assert_equal 406, status
|
31
31
|
end
|
32
32
|
|
33
|
-
should
|
33
|
+
it 'should allow passing & halting in before filters' do
|
34
34
|
mock_app do
|
35
35
|
controller do
|
36
36
|
before { env['QUERY_STRING'] == 'secret' or pass }
|
@@ -58,7 +58,7 @@ describe "Filters" do
|
|
58
58
|
assert_equal "index", body
|
59
59
|
end
|
60
60
|
|
61
|
-
should
|
61
|
+
it 'should scope filters in the given controller' do
|
62
62
|
mock_app do
|
63
63
|
before { @global = 'global' }
|
64
64
|
after { @global = nil }
|
@@ -88,7 +88,7 @@ describe "Filters" do
|
|
88
88
|
assert_equal "global", body
|
89
89
|
end
|
90
90
|
|
91
|
-
should
|
91
|
+
it 'should be able to access params in a before filter' do
|
92
92
|
username_from_before_filter = nil
|
93
93
|
|
94
94
|
mock_app do
|
@@ -103,7 +103,7 @@ describe "Filters" do
|
|
103
103
|
assert_equal 'josh', username_from_before_filter
|
104
104
|
end
|
105
105
|
|
106
|
-
should
|
106
|
+
it 'should be able to access params normally when a before filter is specified' do
|
107
107
|
mock_app do
|
108
108
|
before { }
|
109
109
|
get :index do
|
@@ -114,7 +114,7 @@ describe "Filters" do
|
|
114
114
|
assert_equal '{"test"=>"what"}', body
|
115
115
|
end
|
116
116
|
|
117
|
-
should
|
117
|
+
it 'should be able to filter based on a path' do
|
118
118
|
mock_app do
|
119
119
|
before('/') { @test = "#{@test}before"}
|
120
120
|
get :index do
|
@@ -130,7 +130,7 @@ describe "Filters" do
|
|
130
130
|
assert_equal '', body
|
131
131
|
end
|
132
132
|
|
133
|
-
should
|
133
|
+
it 'should be able to filter based on a symbol' do
|
134
134
|
mock_app do
|
135
135
|
before(:index) { @test = 'before'}
|
136
136
|
get :index do
|
@@ -146,7 +146,7 @@ describe "Filters" do
|
|
146
146
|
assert_equal '', body
|
147
147
|
end
|
148
148
|
|
149
|
-
should
|
149
|
+
it 'should be able to filter based on a symbol for a controller' do
|
150
150
|
mock_app do
|
151
151
|
controller :foo do
|
152
152
|
before(:test) { @test = 'foo'}
|
@@ -167,7 +167,7 @@ describe "Filters" do
|
|
167
167
|
assert_equal 'bar response', body
|
168
168
|
end
|
169
169
|
|
170
|
-
should
|
170
|
+
it 'should be able to filter based on a symbol or path' do
|
171
171
|
mock_app do
|
172
172
|
before(:index, '/main') { @test = 'before'}
|
173
173
|
get :index do
|
@@ -183,7 +183,7 @@ describe "Filters" do
|
|
183
183
|
assert_equal 'before', body
|
184
184
|
end
|
185
185
|
|
186
|
-
should
|
186
|
+
it 'should be able to filter based on a symbol or regexp' do
|
187
187
|
mock_app do
|
188
188
|
before(:index, /main/) { @test = 'before'}
|
189
189
|
get :index do
|
@@ -204,7 +204,7 @@ describe "Filters" do
|
|
204
204
|
assert_equal '', body
|
205
205
|
end
|
206
206
|
|
207
|
-
should
|
207
|
+
it 'should be able to filter excluding based on a symbol' do
|
208
208
|
mock_app do
|
209
209
|
before(:except => :index) { @test = 'before'}
|
210
210
|
get :index do
|
@@ -220,7 +220,31 @@ describe "Filters" do
|
|
220
220
|
assert_equal 'before', body
|
221
221
|
end
|
222
222
|
|
223
|
-
should
|
223
|
+
it 'should be able to filter excluding based on a symbol when specify the multiple routes and use nested controller' do
|
224
|
+
mock_app do
|
225
|
+
controller :test, :nested do
|
226
|
+
before(:except => [:test1, :test2]) { @long = 'long'}
|
227
|
+
before(:except => [:test1]) { @short = 'short'}
|
228
|
+
get :test1 do
|
229
|
+
"#{@long} #{@short} normal"
|
230
|
+
end
|
231
|
+
get :test2 do
|
232
|
+
"#{@long} #{@short} normal"
|
233
|
+
end
|
234
|
+
get :test3 do
|
235
|
+
"#{@long} #{@short} normal"
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
get '/test/nested/test1'
|
240
|
+
assert_equal ' normal', body
|
241
|
+
get '/test/nested/test2'
|
242
|
+
assert_equal ' short normal', body
|
243
|
+
get '/test/nested/test3'
|
244
|
+
assert_equal 'long short normal', body
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'should be able to filter based on a request param' do
|
224
248
|
mock_app do
|
225
249
|
before(:agent => /IE/) { @test = 'before'}
|
226
250
|
get :index do
|
@@ -233,7 +257,7 @@ describe "Filters" do
|
|
233
257
|
assert_equal 'before', body
|
234
258
|
end
|
235
259
|
|
236
|
-
should
|
260
|
+
it 'should be able to filter based on a symbol or path in multiple controller' do
|
237
261
|
mock_app do
|
238
262
|
controllers :foo do
|
239
263
|
before(:index, '/foo/main') { @test = 'before' }
|
@@ -264,7 +288,7 @@ describe "Filters" do
|
|
264
288
|
assert_equal 'also before', body
|
265
289
|
end
|
266
290
|
|
267
|
-
should
|
291
|
+
it 'should call before filters even if there was no match' do
|
268
292
|
test = nil
|
269
293
|
mock_app do
|
270
294
|
before(:index, '/foo') { test = 'before' }
|
@@ -276,7 +300,7 @@ describe "Filters" do
|
|
276
300
|
assert_equal 'before', test
|
277
301
|
end
|
278
302
|
|
279
|
-
should
|
303
|
+
it 'should call before filters only once' do
|
280
304
|
once = ''
|
281
305
|
mock_app do
|
282
306
|
error 500 do
|
@@ -294,7 +318,7 @@ describe "Filters" do
|
|
294
318
|
assert_equal 'before', once
|
295
319
|
end
|
296
320
|
|
297
|
-
should
|
321
|
+
it 'should catch exceptions in before filters' do
|
298
322
|
doodle = nil
|
299
323
|
mock_app do
|
300
324
|
after do
|
@@ -316,7 +340,7 @@ describe "Filters" do
|
|
316
340
|
assert_equal nil, doodle
|
317
341
|
end
|
318
342
|
|
319
|
-
should
|
343
|
+
it 'should catch exceptions in after filters if no exceptions caught before' do
|
320
344
|
doodle = ''
|
321
345
|
mock_app do
|
322
346
|
after do
|
data/test/test_flash.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
2
|
|
3
3
|
describe Padrino::Flash do
|
4
|
-
|
4
|
+
describe 'storage' do
|
5
5
|
before do
|
6
6
|
@storage = Padrino::Flash::Storage.new(
|
7
7
|
:success => 'Success msg',
|
@@ -13,53 +13,53 @@ describe Padrino::Flash do
|
|
13
13
|
@storage[:two] = 'Two msg'
|
14
14
|
end
|
15
15
|
|
16
|
-
should
|
16
|
+
it 'should acts like hash' do
|
17
17
|
assert_respond_to @storage, :[]
|
18
18
|
end
|
19
19
|
|
20
|
-
should
|
20
|
+
it 'should know its size' do
|
21
21
|
assert_equal 4, @storage.length
|
22
22
|
assert_equal @storage.length, @storage.size
|
23
23
|
end
|
24
24
|
|
25
|
-
should
|
25
|
+
it 'should sweep its content' do
|
26
26
|
assert_equal 2, @storage.sweep.size
|
27
27
|
assert_empty @storage.sweep
|
28
28
|
end
|
29
29
|
|
30
|
-
should
|
30
|
+
it 'should discard everything' do
|
31
31
|
assert_empty @storage.discard.sweep
|
32
32
|
end
|
33
33
|
|
34
|
-
should
|
34
|
+
it 'should discard specified key' do
|
35
35
|
assert_equal 1, @storage.discard(:one).sweep.size
|
36
36
|
end
|
37
37
|
|
38
|
-
should
|
38
|
+
it 'should keep everything' do
|
39
39
|
assert_equal 2, @storage.sweep.keep.sweep.size
|
40
40
|
end
|
41
41
|
|
42
|
-
should
|
42
|
+
it 'should keep only specified key' do
|
43
43
|
assert_equal 1, @storage.sweep.keep(:one).sweep.size
|
44
44
|
end
|
45
45
|
|
46
|
-
should
|
46
|
+
it 'should not know the values you set right away' do
|
47
47
|
@storage[:foo] = 'bar'
|
48
48
|
assert_nil @storage[:foo]
|
49
49
|
end
|
50
50
|
|
51
|
-
should
|
51
|
+
it 'should knows the values you set next time' do
|
52
52
|
@storage[:foo] = 'bar'
|
53
53
|
@storage.sweep
|
54
54
|
assert_equal 'bar', @storage[:foo]
|
55
55
|
end
|
56
56
|
|
57
|
-
should
|
57
|
+
it 'should set values for now' do
|
58
58
|
@storage.now[:foo] = 'bar'
|
59
59
|
assert_equal 'bar', @storage[:foo]
|
60
60
|
end
|
61
61
|
|
62
|
-
should
|
62
|
+
it 'should forgets values you set only for now next time' do
|
63
63
|
@storage.now[:foo] = 'bar'
|
64
64
|
@storage.sweep
|
65
65
|
assert_nil @storage[:foo]
|
@@ -97,42 +97,42 @@ describe Padrino::Flash do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
|
100
|
+
describe 'padrino application without sessions' do
|
101
101
|
before { mock_app(&routes) }
|
102
102
|
|
103
|
-
should
|
103
|
+
it 'should show nothing' do
|
104
104
|
get '/'
|
105
105
|
assert_equal '{}', body
|
106
106
|
end
|
107
107
|
|
108
|
-
should
|
108
|
+
it 'should set a flash' do
|
109
109
|
post '/', :foo => :bar
|
110
110
|
assert_equal '{:foo=>"bar"}', body
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
|
114
|
+
describe 'padrino application with sessions' do
|
115
115
|
before do
|
116
116
|
mock_app { enable :sessions; class_eval(&routes) }
|
117
117
|
end
|
118
118
|
|
119
|
-
should
|
119
|
+
it 'should be sure have sessions enabled' do
|
120
120
|
assert @app.sessions
|
121
121
|
get '/session'
|
122
122
|
assert_equal 'true', body
|
123
123
|
end
|
124
124
|
|
125
|
-
should
|
125
|
+
it 'should show nothing' do
|
126
126
|
get '/'
|
127
127
|
assert_equal '{}', body
|
128
128
|
end
|
129
129
|
|
130
|
-
should
|
130
|
+
it 'should set a flash' do
|
131
131
|
post '/', :foo => :bar
|
132
132
|
assert_equal '{:foo=>"bar"}', body
|
133
133
|
end
|
134
134
|
|
135
|
-
should
|
135
|
+
it 'should get a flash' do
|
136
136
|
post '/', :foo => :bar
|
137
137
|
get '/', :key => :foo
|
138
138
|
assert_equal 'bar', body
|
@@ -140,26 +140,26 @@ describe Padrino::Flash do
|
|
140
140
|
assert_equal '{}', body
|
141
141
|
end
|
142
142
|
|
143
|
-
should
|
143
|
+
it 'should follow redirects with flash' do
|
144
144
|
get '/redirect'
|
145
145
|
follow_redirect!
|
146
146
|
assert_equal 'redirected!', body
|
147
147
|
assert 301, status
|
148
148
|
end
|
149
149
|
|
150
|
-
should
|
150
|
+
it 'should set success' do
|
151
151
|
get '/success'
|
152
152
|
get '/', :key => :success
|
153
153
|
assert_equal 'Yup', body
|
154
154
|
end
|
155
155
|
|
156
|
-
should
|
156
|
+
it 'should set error' do
|
157
157
|
get '/error'
|
158
158
|
get '/', :key => :error
|
159
159
|
assert_equal 'Arg', body
|
160
160
|
end
|
161
161
|
|
162
|
-
should
|
162
|
+
it 'should set notice' do
|
163
163
|
get '/notice'
|
164
164
|
get '/', :key => :notice
|
165
165
|
assert_equal 'Mmm', body
|
data/test/test_locale.rb
CHANGED
@@ -4,7 +4,7 @@ describe "Locales" do
|
|
4
4
|
Dir[File.expand_path("../../lib/padrino-core/locale/*.yml", __FILE__)].each do |file|
|
5
5
|
base_original = YAML.load_file(file)
|
6
6
|
name = File.basename(file, '.yml')
|
7
|
-
|
7
|
+
it "should should have correct locale for #{name}" do
|
8
8
|
base = base_original[name]['date']['formats']
|
9
9
|
assert base['default'].present?
|
10
10
|
assert base['short'].present?
|
data/test/test_logger.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
|
-
require 'lumberjack'
|
3
2
|
require 'logger'
|
4
3
|
|
5
4
|
describe "PadrinoLogger" do
|
@@ -14,21 +13,21 @@ describe "PadrinoLogger" do
|
|
14
13
|
@logger = Padrino::Logger.new(options.merge(:stream => @log))
|
15
14
|
end
|
16
15
|
|
17
|
-
|
16
|
+
describe 'for logger functionality' do
|
18
17
|
|
19
|
-
|
18
|
+
describe 'check stream config' do
|
20
19
|
|
21
|
-
should
|
20
|
+
it 'should use stdout if stream is nil' do
|
22
21
|
Padrino::Logger::Config[:test][:stream] = nil
|
23
22
|
Padrino::Logger.setup!
|
24
23
|
assert_equal $stdout, Padrino.logger.log
|
25
24
|
end
|
26
25
|
|
27
|
-
should
|
26
|
+
it 'should use StringIO as default for test' do
|
28
27
|
assert_instance_of StringIO, Padrino.logger.log
|
29
28
|
end
|
30
29
|
|
31
|
-
should
|
30
|
+
it 'should use a custom stream' do
|
32
31
|
my_stream = StringIO.new
|
33
32
|
Padrino::Logger::Config[:test][:stream] = my_stream
|
34
33
|
Padrino::Logger.setup!
|
@@ -36,17 +35,17 @@ describe "PadrinoLogger" do
|
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
|
-
should
|
38
|
+
it 'should log something' do
|
40
39
|
setup_logger(:log_level => :error)
|
41
40
|
@logger.error "You log this error?"
|
42
41
|
assert_match(/You log this error?/, @log.string)
|
43
42
|
@logger.debug "You don't log this error!"
|
44
|
-
|
43
|
+
refute_match(/You don't log this error!/, @log.string)
|
45
44
|
@logger << "Yep this can be logged"
|
46
45
|
assert_match(/Yep this can be logged/, @log.string)
|
47
46
|
end
|
48
47
|
|
49
|
-
should
|
48
|
+
it 'should respond to #write for Rack::CommonLogger' do
|
50
49
|
setup_logger(:log_level => :error)
|
51
50
|
@logger.error "Error message"
|
52
51
|
assert_match /Error message/, @log.string
|
@@ -56,7 +55,7 @@ describe "PadrinoLogger" do
|
|
56
55
|
assert_match /log via alias/, @log.string
|
57
56
|
end
|
58
57
|
|
59
|
-
should
|
58
|
+
it 'should log an application' do
|
60
59
|
mock_app do
|
61
60
|
enable :logging
|
62
61
|
get("/"){ "Foo" }
|
@@ -66,7 +65,7 @@ describe "PadrinoLogger" do
|
|
66
65
|
assert_match /GET/, Padrino.logger.log.string
|
67
66
|
end
|
68
67
|
|
69
|
-
should
|
68
|
+
it 'should log an application\'s status code' do
|
70
69
|
mock_app do
|
71
70
|
enable :logging
|
72
71
|
get("/"){ "Foo" }
|
@@ -75,8 +74,8 @@ describe "PadrinoLogger" do
|
|
75
74
|
assert_match /\e\[1m200\e\[0m OK/, Padrino.logger.log.string
|
76
75
|
end
|
77
76
|
|
78
|
-
|
79
|
-
should
|
77
|
+
describe "static asset logging" do
|
78
|
+
it 'should not log static assets by default' do
|
80
79
|
mock_app do
|
81
80
|
enable :logging
|
82
81
|
get("/images/something.png"){ env["sinatra.static_file"] = '/public/images/something.png'; "Foo" }
|
@@ -86,7 +85,7 @@ describe "PadrinoLogger" do
|
|
86
85
|
assert_match "", Padrino.logger.log.string
|
87
86
|
end
|
88
87
|
|
89
|
-
should
|
88
|
+
it 'should allow turning on static assets logging' do
|
90
89
|
Padrino.logger.instance_eval{ @log_static = true }
|
91
90
|
mock_app do
|
92
91
|
enable :logging
|
@@ -99,7 +98,7 @@ describe "PadrinoLogger" do
|
|
99
98
|
end
|
100
99
|
end
|
101
100
|
|
102
|
-
|
101
|
+
describe "health-check requests logging" do
|
103
102
|
def access_to_mock_app
|
104
103
|
mock_app do
|
105
104
|
enable :logging
|
@@ -108,7 +107,7 @@ describe "PadrinoLogger" do
|
|
108
107
|
get "/"
|
109
108
|
end
|
110
109
|
|
111
|
-
should
|
110
|
+
it 'should output under debug level' do
|
112
111
|
Padrino.logger.instance_eval{ @level = Padrino::Logger::Levels[:debug] }
|
113
112
|
access_to_mock_app
|
114
113
|
assert_match /\e\[36m DEBUG\e\[0m/, Padrino.logger.log.string
|
@@ -117,7 +116,7 @@ describe "PadrinoLogger" do
|
|
117
116
|
access_to_mock_app
|
118
117
|
assert_match /\e\[36m DEBUG\e\[0m/, Padrino.logger.log.string
|
119
118
|
end
|
120
|
-
should
|
119
|
+
it 'should not output over debug level' do
|
121
120
|
Padrino.logger.instance_eval{ @level = Padrino::Logger::Levels[:info] }
|
122
121
|
access_to_mock_app
|
123
122
|
assert_equal '', Padrino.logger.log.string
|
@@ -130,19 +129,32 @@ describe "PadrinoLogger" do
|
|
130
129
|
end
|
131
130
|
end
|
132
131
|
|
133
|
-
describe "alternate logger
|
132
|
+
describe "alternate logger" do
|
133
|
+
class FancyLogger
|
134
|
+
attr_accessor :level, :log
|
135
|
+
def initialize(buf)
|
136
|
+
self.log = buf
|
137
|
+
self.level = 0
|
138
|
+
end
|
139
|
+
def add(level, text)
|
140
|
+
self.log << text
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
134
144
|
def setup_logger
|
135
145
|
@log = StringIO.new
|
136
|
-
Padrino.logger =
|
146
|
+
Padrino.logger = FancyLogger.new(@log)
|
137
147
|
end
|
138
148
|
|
139
|
-
should
|
149
|
+
it 'should annotate the logger to support additional Padrino fancyness' do
|
140
150
|
setup_logger
|
141
151
|
Padrino.logger.debug("Debug message")
|
142
152
|
assert_match(/Debug message/, @log.string)
|
153
|
+
Padrino.logger.exception(Exception.new 'scary message')
|
154
|
+
assert_match(/Exception - scary message/, @log.string)
|
143
155
|
end
|
144
156
|
|
145
|
-
should
|
157
|
+
it 'should colorize log output after colorize! is called' do
|
146
158
|
setup_logger
|
147
159
|
Padrino.logger.colorize!
|
148
160
|
|
@@ -162,13 +174,13 @@ describe "alternate logger: stdlib logger" do
|
|
162
174
|
Padrino.logger = Logger.new(@log)
|
163
175
|
end
|
164
176
|
|
165
|
-
should
|
177
|
+
it 'should annotate the logger to support additional Padrino fancyness' do
|
166
178
|
setup_logger
|
167
179
|
Padrino.logger.debug("Debug message")
|
168
180
|
assert_match(/Debug message/, @log.string)
|
169
181
|
end
|
170
182
|
|
171
|
-
should
|
183
|
+
it 'should colorize log output after colorize! is called' do
|
172
184
|
setup_logger
|
173
185
|
Padrino.logger.colorize!
|
174
186
|
|
@@ -190,16 +202,16 @@ describe "options :colorize_logging" do
|
|
190
202
|
end
|
191
203
|
get "/"
|
192
204
|
end
|
193
|
-
|
194
|
-
should
|
205
|
+
describe 'default' do
|
206
|
+
it 'should use colorize logging' do
|
195
207
|
Padrino::Logger.setup!
|
196
208
|
|
197
209
|
access_to_mock_app
|
198
210
|
assert_match /\e\[1m200\e\[0m OK/, Padrino.logger.log.string
|
199
211
|
end
|
200
212
|
end
|
201
|
-
|
202
|
-
should
|
213
|
+
describe 'set value is false' do
|
214
|
+
it 'should not use colorize logging' do
|
203
215
|
Padrino::Logger::Config[:test][:colorize_logging] = false
|
204
216
|
Padrino::Logger.setup!
|
205
217
|
|