padrino-core 0.16.0.pre4 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +8 -8
- data/Rakefile +1 -1
- data/bin/padrino +1 -1
- data/lib/padrino-core/application/application_setup.rb +28 -26
- data/lib/padrino-core/application/authenticity_token.rb +3 -2
- data/lib/padrino-core/application/flash.rb +4 -5
- data/lib/padrino-core/application/params_protection.rb +34 -37
- data/lib/padrino-core/application/routing.rb +165 -164
- data/lib/padrino-core/application/show_exceptions.rb +5 -7
- data/lib/padrino-core/application.rb +4 -4
- data/lib/padrino-core/caller.rb +6 -7
- data/lib/padrino-core/cli/adapter.rb +4 -4
- data/lib/padrino-core/cli/base.rb +31 -32
- data/lib/padrino-core/cli/binstub.rb +9 -8
- data/lib/padrino-core/cli/console.rb +1 -1
- data/lib/padrino-core/cli/launcher.rb +45 -42
- data/lib/padrino-core/cli/rake.rb +16 -14
- data/lib/padrino-core/cli/rake_tasks.rb +18 -20
- data/lib/padrino-core/command.rb +1 -1
- data/lib/padrino-core/ext/sinatra.rb +3 -2
- data/lib/padrino-core/filter.rb +3 -3
- data/lib/padrino-core/loader.rb +10 -12
- data/lib/padrino-core/logger.rb +85 -77
- data/lib/padrino-core/mounter/application_extension.rb +2 -2
- data/lib/padrino-core/mounter.rb +33 -34
- data/lib/padrino-core/path_router/compiler.rb +8 -8
- data/lib/padrino-core/path_router/matcher.rb +11 -11
- data/lib/padrino-core/path_router/route.rb +15 -15
- data/lib/padrino-core/path_router.rb +4 -3
- data/lib/padrino-core/reloader/rack.rb +1 -1
- data/lib/padrino-core/reloader/storage.rb +12 -11
- data/lib/padrino-core/reloader.rb +18 -19
- data/lib/padrino-core/router.rb +14 -14
- data/lib/padrino-core/server.rb +20 -24
- data/lib/padrino-core/tasks.rb +0 -1
- data/lib/padrino-core/version.rb +1 -1
- data/lib/padrino-core.rb +9 -10
- data/padrino-core.gemspec +18 -18
- data/test/fixtures/app_gem/app_gem.gemspec +8 -7
- data/test/fixtures/app_gem/lib/app_gem/version.rb +1 -1
- data/test/fixtures/apps/complex.rb +6 -6
- data/test/fixtures/apps/concerned/app.rb +1 -1
- data/test/fixtures/apps/custom_dependencies/custom_dependencies.rb +3 -3
- data/test/fixtures/apps/demo_app.rb +1 -1
- data/test/fixtures/apps/demo_demo.rb +1 -1
- data/test/fixtures/apps/demo_project/api/app.rb +1 -1
- data/test/fixtures/apps/demo_project/app.rb +1 -1
- data/test/fixtures/apps/helpers/class_methods_helpers.rb +1 -0
- data/test/fixtures/apps/helpers/instance_methods_helpers.rb +1 -0
- data/test/fixtures/apps/helpers/system_helpers.rb +0 -1
- data/test/fixtures/apps/lib/myklass/mysubklass.rb +2 -2
- data/test/fixtures/apps/mountable_apps/rack_apps.rb +7 -7
- data/test/fixtures/apps/precompiled_app.rb +6 -5
- data/test/fixtures/apps/simple.rb +5 -5
- data/test/fixtures/apps/static.rb +2 -2
- data/test/fixtures/apps/stealthy/app.rb +1 -1
- data/test/fixtures/apps/stealthy/helpers/stealthy_class_helpers.rb +1 -1
- data/test/fixtures/apps/system.rb +1 -1
- data/test/fixtures/apps/system_class_methods_demo.rb +1 -1
- data/test/fixtures/apps/system_instance_methods_demo.rb +1 -1
- data/test/fixtures/dependencies/a.rb +1 -1
- data/test/fixtures/dependencies/b.rb +1 -1
- data/test/fixtures/dependencies/c.rb +1 -1
- data/test/fixtures/dependencies/circular/e.rb +2 -1
- data/test/fixtures/dependencies/d.rb +1 -1
- data/test/fixtures/dependencies/linear/i.rb +1 -1
- data/test/fixtures/dependencies/nested/l.rb +2 -2
- data/test/fixtures/dependencies/nested/m.rb +1 -1
- data/test/fixtures/dependencies/nested/qqq.rb +2 -2
- data/test/fixtures/dependencies/nested/rrr.rb +1 -1
- data/test/fixtures/dependencies/nested/sss.rb +1 -1
- data/test/fixtures/reloadable_apps/external/app/app.rb +0 -1
- data/test/fixtures/reloadable_apps/external/app/controllers/base.rb +1 -2
- data/test/fixtures/reloadable_apps/main/app.rb +2 -2
- data/test/helper.rb +2 -2
- data/test/test_application.rb +59 -60
- data/test/test_configuration.rb +2 -2
- data/test/test_core.rb +13 -13
- data/test/test_csrf_protection.rb +67 -63
- data/test/test_dependencies.rb +33 -34
- data/test/test_filters.rb +46 -47
- data/test/test_flash.rb +14 -14
- data/test/test_locale.rb +2 -2
- data/test/test_logger.rb +64 -64
- data/test/test_mounter.rb +133 -123
- data/test/test_params_protection.rb +40 -40
- data/test/test_reloader_complex.rb +23 -23
- data/test/test_reloader_external.rb +10 -10
- data/test/test_reloader_simple.rb +26 -23
- data/test/test_reloader_storage.rb +9 -12
- data/test/test_reloader_system.rb +29 -29
- data/test/test_restful_routing.rb +19 -19
- data/test/test_router.rb +126 -145
- data/test/test_routing.rb +882 -894
- metadata +6 -6
data/test/test_core.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe 'Core' do
|
|
4
4
|
def setup
|
|
5
5
|
Padrino.clear!
|
|
6
6
|
end
|
|
@@ -19,7 +19,7 @@ describe "Core" do
|
|
|
19
19
|
|
|
20
20
|
it 'should validate global helpers' do
|
|
21
21
|
assert_equal :test, Padrino.env
|
|
22
|
-
assert_match(
|
|
22
|
+
assert_match(%r{/test}, Padrino.root)
|
|
23
23
|
assert Padrino.version
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -38,25 +38,25 @@ describe "Core" do
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it 'should add middlewares in front if specified' do
|
|
41
|
-
test = Class.new
|
|
41
|
+
test = Class.new do
|
|
42
42
|
def initialize(app)
|
|
43
43
|
@app = app
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def call(env)
|
|
47
47
|
status, headers, body = @app.call(env)
|
|
48
|
-
headers[
|
|
48
|
+
headers['Middleware-Called'] = 'yes'
|
|
49
49
|
[status, headers, body]
|
|
50
50
|
end
|
|
51
|
-
|
|
51
|
+
end
|
|
52
52
|
|
|
53
53
|
class Foo < Padrino::Application; end
|
|
54
54
|
|
|
55
55
|
Padrino.use(test)
|
|
56
|
-
Padrino.mount(Foo).to(
|
|
56
|
+
Padrino.mount(Foo).to('/')
|
|
57
57
|
|
|
58
|
-
res = Rack::MockRequest.new(Padrino.application).get(
|
|
59
|
-
assert_equal
|
|
58
|
+
res = Rack::MockRequest.new(Padrino.application).get('/')
|
|
59
|
+
assert_equal 'yes', res['Middleware-Called']
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
it 'should properly set default options' do
|
|
@@ -75,13 +75,13 @@ describe "Core" do
|
|
|
75
75
|
it 'should return a friendly 500' do
|
|
76
76
|
mock_app do
|
|
77
77
|
enable :show_exceptions
|
|
78
|
-
get(:index){ raise StandardError }
|
|
78
|
+
get(:index) { raise StandardError }
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
get
|
|
81
|
+
get '/'
|
|
82
82
|
assert_equal 500, status
|
|
83
|
-
assert_includes body,
|
|
84
|
-
assert_includes body,
|
|
83
|
+
assert_includes body, 'StandardError'
|
|
84
|
+
assert_includes body, '<code>show_exceptions</code> setting'
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
end
|
|
@@ -1,206 +1,210 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe 'Application' do
|
|
4
4
|
before { Padrino.clear! }
|
|
5
5
|
|
|
6
6
|
describe 'CSRF protection' do
|
|
7
|
-
describe
|
|
7
|
+
describe 'with CSRF protection on' do
|
|
8
8
|
before do
|
|
9
|
-
@token =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
@token =
|
|
10
|
+
begin
|
|
11
|
+
Rack::Protection::AuthenticityToken.random_token
|
|
12
|
+
rescue StandardError
|
|
13
|
+
'a_token'
|
|
14
|
+
end
|
|
15
|
+
|
|
14
16
|
mock_app do
|
|
15
17
|
enable :sessions
|
|
16
18
|
enable :protect_from_csrf
|
|
17
|
-
post('/'){ 'HI' }
|
|
19
|
+
post('/') { 'HI' }
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
it 'should not allow requests without tokens' do
|
|
22
|
-
post
|
|
24
|
+
post '/'
|
|
23
25
|
assert_equal 403, status
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
it 'should allow requests with correct tokens' do
|
|
27
|
-
post
|
|
29
|
+
post '/', { 'authenticity_token' => @token }, 'rack.session' => { csrf: @token }
|
|
28
30
|
assert_equal 200, status
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
it 'should not allow requests with incorrect tokens' do
|
|
32
|
-
post
|
|
34
|
+
post '/', { 'authenticity_token' => 'b' }, 'rack.session' => { csrf: @token }
|
|
33
35
|
assert_equal 403, status
|
|
34
36
|
end
|
|
35
37
|
|
|
36
38
|
it 'should allow requests with correct X-CSRF-TOKEN' do
|
|
37
|
-
post
|
|
39
|
+
post '/', {}, 'rack.session' => { csrf: @token }, 'HTTP_X_CSRF_TOKEN' => @token
|
|
38
40
|
assert_equal 200, status
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
it 'should not allow requests with incorrect X-CSRF-TOKEN' do
|
|
42
|
-
post
|
|
44
|
+
post '/', {}, 'rack.session' => { csrf: @token }, 'HTTP_X_CSRF_TOKEN' => 'b'
|
|
43
45
|
assert_equal 403, status
|
|
44
46
|
end
|
|
45
47
|
end
|
|
46
48
|
|
|
47
|
-
describe
|
|
49
|
+
describe 'without CSRF protection on' do
|
|
48
50
|
before do
|
|
49
51
|
mock_app do
|
|
50
52
|
enable :sessions
|
|
51
53
|
disable :protect_from_csrf
|
|
52
|
-
post('/'){ 'HI' }
|
|
54
|
+
post('/') { 'HI' }
|
|
53
55
|
end
|
|
54
56
|
end
|
|
55
57
|
|
|
56
58
|
it 'should allows requests without tokens' do
|
|
57
|
-
post
|
|
59
|
+
post '/'
|
|
58
60
|
assert_equal 200, status
|
|
59
61
|
end
|
|
60
62
|
|
|
61
63
|
it 'should allow requests with correct tokens' do
|
|
62
|
-
post
|
|
64
|
+
post '/', { 'authenticity_token' => 'a' }, 'rack.session' => { csrf: 'a' }
|
|
63
65
|
assert_equal 200, status
|
|
64
66
|
end
|
|
65
67
|
|
|
66
68
|
it 'should allow requests with incorrect tokens' do
|
|
67
|
-
post
|
|
69
|
+
post '/', { 'authenticity_token' => 'a' }, 'rack.session' => { csrf: 'b' }
|
|
68
70
|
assert_equal 200, status
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
it 'should allow requests with correct X-CSRF-TOKEN' do
|
|
72
|
-
post
|
|
74
|
+
post '/', {}, 'rack.session' => { csrf: 'a' }, 'HTTP_X_CSRF_TOKEN' => 'a'
|
|
73
75
|
assert_equal 200, status
|
|
74
76
|
end
|
|
75
77
|
|
|
76
78
|
it 'should allow requests with incorrect X-CSRF-TOKEN' do
|
|
77
|
-
post
|
|
79
|
+
post '/', {}, 'rack.session' => { csrf: 'a' }, 'HTTP_X_CSRF_TOKEN' => 'b'
|
|
78
80
|
assert_equal 200, status
|
|
79
81
|
end
|
|
80
82
|
end
|
|
81
83
|
|
|
82
|
-
describe
|
|
84
|
+
describe 'with optional CSRF protection' do
|
|
83
85
|
before do
|
|
84
86
|
mock_app do
|
|
85
87
|
enable :sessions
|
|
86
88
|
enable :protect_from_csrf
|
|
87
89
|
enable :allow_disabled_csrf
|
|
88
90
|
post('/on') { 'HI' }
|
|
89
|
-
post('/off', :
|
|
91
|
+
post('/off', csrf_protection: false) { 'HI' }
|
|
90
92
|
end
|
|
91
93
|
end
|
|
92
94
|
|
|
93
95
|
it 'should allow access to routes with csrf_protection off' do
|
|
94
|
-
post
|
|
96
|
+
post '/off'
|
|
95
97
|
assert_equal 200, status
|
|
96
98
|
end
|
|
97
99
|
|
|
98
100
|
it 'should not allow access to routes with csrf_protection on' do
|
|
99
|
-
post
|
|
101
|
+
post '/on'
|
|
100
102
|
assert_equal 403, status
|
|
101
103
|
assert_equal 'Forbidden', body
|
|
102
104
|
end
|
|
103
105
|
end
|
|
104
106
|
|
|
105
|
-
describe
|
|
107
|
+
describe 'with :except option that is using Proc' do
|
|
106
108
|
before do
|
|
107
109
|
mock_app do
|
|
108
110
|
enable :sessions
|
|
109
|
-
set :protect_from_csrf, :
|
|
110
|
-
post(
|
|
111
|
-
post(
|
|
112
|
-
post(
|
|
111
|
+
set :protect_from_csrf, except: proc { |env| ['/', '/foo'].any? { |path| path == env['PATH_INFO'] } }
|
|
112
|
+
post('/') { 'Hello' }
|
|
113
|
+
post('/foo') { 'Hello, foo' }
|
|
114
|
+
post('/bar') { 'Hello, bar' }
|
|
113
115
|
end
|
|
114
116
|
end
|
|
115
117
|
|
|
116
118
|
it 'should allow ignoring CSRF protection on specific routes' do
|
|
117
|
-
post
|
|
119
|
+
post '/'
|
|
118
120
|
assert_equal 200, status
|
|
119
|
-
post
|
|
121
|
+
post '/foo'
|
|
120
122
|
assert_equal 200, status
|
|
121
|
-
post
|
|
123
|
+
post '/bar'
|
|
122
124
|
assert_equal 403, status
|
|
123
125
|
end
|
|
124
126
|
end
|
|
125
127
|
|
|
126
|
-
describe
|
|
128
|
+
describe 'with :except option that is using String and Regexp' do
|
|
127
129
|
before do
|
|
128
130
|
mock_app do
|
|
129
131
|
enable :sessions
|
|
130
|
-
set :protect_from_csrf, :
|
|
131
|
-
post(
|
|
132
|
-
post(
|
|
133
|
-
post(
|
|
132
|
+
set :protect_from_csrf, except: ['/a', %r{^/a.c$}]
|
|
133
|
+
post('/a') { 'a' }
|
|
134
|
+
post('/abc') { 'abc' }
|
|
135
|
+
post('/foo') { 'foo' }
|
|
134
136
|
end
|
|
135
137
|
end
|
|
136
138
|
|
|
137
139
|
it 'should allow ignoring CSRF protection on specific routes' do
|
|
138
|
-
post
|
|
140
|
+
post '/a'
|
|
139
141
|
assert_equal 200, status
|
|
140
|
-
post
|
|
142
|
+
post '/abc'
|
|
141
143
|
assert_equal 200, status
|
|
142
|
-
post
|
|
144
|
+
post '/foo'
|
|
143
145
|
assert_equal 403, status
|
|
144
146
|
end
|
|
145
147
|
end
|
|
146
148
|
|
|
147
|
-
describe
|
|
149
|
+
describe 'with custom protection options' do
|
|
148
150
|
before do
|
|
149
|
-
@token =
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
@token =
|
|
152
|
+
begin
|
|
153
|
+
Rack::Protection::AuthenticityToken.random_token
|
|
154
|
+
rescue StandardError
|
|
155
|
+
'a_token'
|
|
156
|
+
end
|
|
157
|
+
|
|
154
158
|
mock_app do
|
|
155
159
|
enable :sessions
|
|
156
|
-
set :protect_from_csrf, :
|
|
157
|
-
post(
|
|
160
|
+
set :protect_from_csrf, authenticity_param: 'foobar', message: 'sucker!'
|
|
161
|
+
post('/a') { 'a' }
|
|
158
162
|
end
|
|
159
163
|
end
|
|
160
164
|
|
|
161
165
|
it 'should allow configuring protection options' do
|
|
162
|
-
post
|
|
166
|
+
post '/a', { 'foobar' => @token }, 'rack.session' => { csrf: @token }
|
|
163
167
|
assert_equal 200, status
|
|
164
168
|
end
|
|
165
169
|
|
|
166
170
|
it 'should allow configuring message' do
|
|
167
|
-
post
|
|
171
|
+
post '/a'
|
|
168
172
|
assert_equal 403, status
|
|
169
173
|
assert_equal 'sucker!', body
|
|
170
174
|
end
|
|
171
175
|
end
|
|
172
176
|
|
|
173
|
-
describe
|
|
177
|
+
describe 'with middleware' do
|
|
174
178
|
before do
|
|
175
179
|
class Middleware < Sinatra::Base
|
|
176
|
-
post(
|
|
177
|
-
post(
|
|
180
|
+
post('/middleware') { 'Hello, middleware' }
|
|
181
|
+
post('/dummy') { 'Hello, dummy' }
|
|
178
182
|
end
|
|
179
183
|
mock_app do
|
|
180
184
|
enable :sessions
|
|
181
|
-
set :protect_from_csrf, :
|
|
185
|
+
set :protect_from_csrf, except: proc { |env| ['/', '/middleware'].any? { |path| path == env['PATH_INFO'] } }
|
|
182
186
|
use Middleware
|
|
183
|
-
post(
|
|
187
|
+
post('/') { 'Hello' }
|
|
184
188
|
end
|
|
185
189
|
end
|
|
186
190
|
|
|
187
191
|
it 'should allow ignoring CSRF protection on specific routes of middleware' do
|
|
188
|
-
post
|
|
192
|
+
post '/'
|
|
189
193
|
assert_equal 200, status
|
|
190
|
-
post
|
|
194
|
+
post '/middleware'
|
|
191
195
|
assert_equal 200, status
|
|
192
|
-
post
|
|
196
|
+
post '/dummy'
|
|
193
197
|
assert_equal 403, status
|
|
194
198
|
end
|
|
195
199
|
end
|
|
196
200
|
|
|
197
|
-
describe
|
|
201
|
+
describe 'with standard report layout' do
|
|
198
202
|
before do
|
|
199
203
|
mock_app do
|
|
200
204
|
enable :sessions
|
|
201
|
-
set :protect_from_csrf, :
|
|
205
|
+
set :protect_from_csrf, message: 'sucker!'
|
|
202
206
|
enable :report_csrf_failure
|
|
203
|
-
post(
|
|
207
|
+
post('/a') { 'a' }
|
|
204
208
|
error 403 do
|
|
205
209
|
halt 406, 'please, do not hack'
|
|
206
210
|
end
|
|
@@ -208,7 +212,7 @@ describe "Application" do
|
|
|
208
212
|
end
|
|
209
213
|
|
|
210
214
|
it 'should allow configuring protection options' do
|
|
211
|
-
post
|
|
215
|
+
post '/a'
|
|
212
216
|
assert_equal 406, status
|
|
213
217
|
assert_equal 'please, do not hack', body
|
|
214
218
|
end
|
data/test/test_dependencies.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe 'Dependencies' do
|
|
4
4
|
describe 'when we require a dependency that have another dependency' do
|
|
5
5
|
before do
|
|
6
6
|
@log_level = Padrino::Logger::Config[:test]
|
|
7
7
|
@io = StringIO.new
|
|
8
|
-
Padrino::Logger::Config[:test] = { :
|
|
8
|
+
Padrino::Logger::Config[:test] = { log_level: :error, stream: @io }
|
|
9
9
|
Padrino::Logger.setup!
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -18,10 +18,10 @@ describe "Dependencies" do
|
|
|
18
18
|
capture_io do
|
|
19
19
|
assert_raises(RuntimeError) do
|
|
20
20
|
Padrino.require_dependencies(
|
|
21
|
-
Padrino.root(
|
|
22
|
-
Padrino.root(
|
|
23
|
-
Padrino.root(
|
|
24
|
-
Padrino.root(
|
|
21
|
+
Padrino.root('fixtures/dependencies/a.rb'),
|
|
22
|
+
Padrino.root('fixtures/dependencies/b.rb'),
|
|
23
|
+
Padrino.root('fixtures/dependencies/c.rb'),
|
|
24
|
+
Padrino.root('fixtures/dependencies/d.rb')
|
|
25
25
|
)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -32,35 +32,35 @@ describe "Dependencies" do
|
|
|
32
32
|
it 'should resolve dependency problems' do
|
|
33
33
|
capture_io do
|
|
34
34
|
Padrino.require_dependencies(
|
|
35
|
-
Padrino.root(
|
|
36
|
-
Padrino.root(
|
|
37
|
-
Padrino.root(
|
|
35
|
+
Padrino.root('fixtures/dependencies/a.rb'),
|
|
36
|
+
Padrino.root('fixtures/dependencies/b.rb'),
|
|
37
|
+
Padrino.root('fixtures/dependencies/c.rb')
|
|
38
38
|
)
|
|
39
39
|
end
|
|
40
|
-
assert_equal [
|
|
41
|
-
assert_equal
|
|
42
|
-
assert_equal
|
|
40
|
+
assert_equal %w[B C], A_result
|
|
41
|
+
assert_equal 'C', B_result
|
|
42
|
+
assert_equal '', @io.string
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it 'should remove partially loaded constants' do
|
|
46
46
|
capture_io do
|
|
47
47
|
Padrino.require_dependencies(
|
|
48
|
-
Padrino.root(
|
|
49
|
-
Padrino.root(
|
|
50
|
-
Padrino.root(
|
|
48
|
+
Padrino.root('fixtures/dependencies/circular/e.rb'),
|
|
49
|
+
Padrino.root('fixtures/dependencies/circular/f.rb'),
|
|
50
|
+
Padrino.root('fixtures/dependencies/circular/g.rb')
|
|
51
51
|
)
|
|
52
52
|
end
|
|
53
|
-
assert_equal [
|
|
54
|
-
assert_equal
|
|
53
|
+
assert_equal ['name'], F.fields
|
|
54
|
+
assert_equal '', @io.string
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it 'should not silence LoadError raised in dependencies excluded from reloading' do
|
|
58
58
|
capture_io do
|
|
59
59
|
assert_raises(LoadError) do
|
|
60
|
-
Padrino::Reloader.exclude << Padrino.root(
|
|
60
|
+
Padrino::Reloader.exclude << Padrino.root('fixtures/dependencies/linear/h.rb')
|
|
61
61
|
Padrino.require_dependencies(
|
|
62
|
-
Padrino.root(
|
|
63
|
-
Padrino.root(
|
|
62
|
+
Padrino.root('fixtures/dependencies/linear/h.rb'),
|
|
63
|
+
Padrino.root('fixtures/dependencies/linear/i.rb')
|
|
64
64
|
)
|
|
65
65
|
end
|
|
66
66
|
end
|
|
@@ -69,20 +69,19 @@ describe "Dependencies" do
|
|
|
69
69
|
it 'should not remove constants that are newly commited in nested require_dependencies' do
|
|
70
70
|
capture_io do
|
|
71
71
|
Padrino.require_dependencies(
|
|
72
|
-
Padrino.root(
|
|
73
|
-
Padrino.root(
|
|
74
|
-
Padrino.root(
|
|
72
|
+
Padrino.root('fixtures/dependencies/nested/j.rb'),
|
|
73
|
+
Padrino.root('fixtures/dependencies/nested/k.rb'),
|
|
74
|
+
Padrino.root('fixtures/dependencies/nested/l.rb')
|
|
75
75
|
)
|
|
76
76
|
end
|
|
77
|
-
assert_equal
|
|
77
|
+
assert_equal 'hello', M.hello
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
describe "change log level for :devel" do
|
|
80
|
+
describe 'change log level for :devel' do
|
|
82
81
|
before do
|
|
83
82
|
@log_level_devel = Padrino::Logger::Config[:test]
|
|
84
83
|
@io = StringIO.new
|
|
85
|
-
Padrino::Logger::Config[:test] = { :
|
|
84
|
+
Padrino::Logger::Config[:test] = { log_level: :devel, stream: @io }
|
|
86
85
|
Padrino::Logger.setup!
|
|
87
86
|
end
|
|
88
87
|
|
|
@@ -94,14 +93,14 @@ describe "Dependencies" do
|
|
|
94
93
|
it 'should resolve interdependence by out/in side nested require_dependencies' do
|
|
95
94
|
capture_io do
|
|
96
95
|
Padrino.require_dependencies(
|
|
97
|
-
Padrino.root(
|
|
98
|
-
Padrino.root(
|
|
99
|
-
Padrino.root(
|
|
96
|
+
Padrino.root('fixtures/dependencies/nested/ooo.rb'),
|
|
97
|
+
Padrino.root('fixtures/dependencies/nested/ppp.rb'),
|
|
98
|
+
Padrino.root('fixtures/dependencies/nested/qqq.rb')
|
|
100
99
|
)
|
|
101
100
|
end
|
|
102
|
-
assert_equal
|
|
103
|
-
assert_equal
|
|
104
|
-
assert_equal
|
|
101
|
+
assert_equal 'hello', RRR.hello
|
|
102
|
+
assert_equal 'hello', OOO.hello
|
|
103
|
+
assert_equal 'hello', RollbackTarget.hello
|
|
105
104
|
assert_match(/Removed constant RollbackTarget from Object/, @io.string)
|
|
106
105
|
end
|
|
107
106
|
end
|