Fix constant resolution in specs under 1.9
The way constants are set/resolved in class_eval blocks seems to have changed significantly. Move constants to top-level to remedy the situation for now.
This commit is contained in:
parent
18dff713cd
commit
d074e0c6f0
|
@ -380,10 +380,10 @@ describe 'Helpers#etag' do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'Adding new helpers' do
|
||||
module HelperOne; def one; '1'; end; end
|
||||
module HelperTwo; def two; '2'; end; end
|
||||
module HelperOne; def one; '1'; end; end
|
||||
module HelperTwo; def two; '2'; end; end
|
||||
|
||||
describe 'Adding new helpers' do
|
||||
it 'should allow passing a list of modules' do
|
||||
mock_app {
|
||||
helpers HelperOne, HelperTwo
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
require File.dirname(__FILE__) + '/helper'
|
||||
|
||||
describe 'Exception Mappings' do
|
||||
class FooError < RuntimeError
|
||||
end
|
||||
class FooError < RuntimeError
|
||||
end
|
||||
|
||||
class FooNotFound < Sinatra::NotFound
|
||||
end
|
||||
|
||||
describe 'Exception Mappings' do
|
||||
it 'invokes handlers registered with ::error when raised' do
|
||||
mock_app {
|
||||
set :raise_errors, false
|
||||
|
@ -80,9 +83,6 @@ describe 'Exception Mappings' do
|
|||
assert_equal 404, status
|
||||
end
|
||||
|
||||
class FooNotFound < Sinatra::NotFound
|
||||
end
|
||||
|
||||
it "cascades for subclasses of Sinatra::NotFound" do
|
||||
mock_app {
|
||||
set :raise_errors, true
|
||||
|
|
|
@ -4,7 +4,9 @@ describe "Middleware" do
|
|||
before do
|
||||
@app = mock_app(Sinatra::Default) {
|
||||
get '/*' do
|
||||
response.headers['X-Tests'] = env['test.ran'].join(', ')
|
||||
response.headers['X-Tests'] = env['test.ran'].
|
||||
map { |n| n.split('::').last }.
|
||||
join(', ')
|
||||
env['PATH_INFO']
|
||||
end
|
||||
}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
require File.dirname(__FILE__) + '/helper'
|
||||
|
||||
describe 'Static' do
|
||||
F = ::File
|
||||
|
||||
before do
|
||||
mock_app {
|
||||
set :static, true
|
||||
set :public, F.dirname(__FILE__)
|
||||
set :public, File.dirname(__FILE__)
|
||||
}
|
||||
end
|
||||
|
||||
it 'serves GET requests for files in the public directory' do
|
||||
get "/#{F.basename(__FILE__)}"
|
||||
get "/#{File.basename(__FILE__)}"
|
||||
assert ok?
|
||||
assert_equal File.read(__FILE__), body
|
||||
assert_equal File.size(__FILE__).to_s, response['Content-Length']
|
||||
|
@ -19,7 +17,7 @@ describe 'Static' do
|
|||
end
|
||||
|
||||
it 'produces a body that can be iterated over multiple times' do
|
||||
env = Rack::MockRequest.env_for("/#{F.basename(__FILE__)}")
|
||||
env = Rack::MockRequest.env_for("/#{File.basename(__FILE__)}")
|
||||
status, headers, body = @app.call(env)
|
||||
buf1, buf2 = [], []
|
||||
body.each { |part| buf1 << part }
|
||||
|
@ -29,7 +27,7 @@ describe 'Static' do
|
|||
end
|
||||
|
||||
it 'serves HEAD requests for files in the public directory' do
|
||||
head "/#{F.basename(__FILE__)}"
|
||||
head "/#{File.basename(__FILE__)}"
|
||||
assert ok?
|
||||
assert_equal '', body
|
||||
assert_equal File.size(__FILE__).to_s, response['Content-Length']
|
||||
|
@ -37,8 +35,8 @@ describe 'Static' do
|
|||
end
|
||||
|
||||
it 'serves files in preference to custom routes' do
|
||||
@app.get("/#{F.basename(__FILE__)}") { 'Hello World' }
|
||||
get "/#{F.basename(__FILE__)}"
|
||||
@app.get("/#{File.basename(__FILE__)}") { 'Hello World' }
|
||||
get "/#{File.basename(__FILE__)}"
|
||||
assert ok?
|
||||
assert body != 'Hello World'
|
||||
end
|
||||
|
@ -50,13 +48,13 @@ describe 'Static' do
|
|||
|
||||
it 'passes to the next handler when the static option is disabled' do
|
||||
@app.set :static, false
|
||||
get "/#{F.basename(__FILE__)}"
|
||||
get "/#{File.basename(__FILE__)}"
|
||||
assert not_found?
|
||||
end
|
||||
|
||||
it 'passes to the next handler when the public option is nil' do
|
||||
@app.set :public, nil
|
||||
get "/#{F.basename(__FILE__)}"
|
||||
get "/#{File.basename(__FILE__)}"
|
||||
assert not_found?
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue