Fix ruby warnings

Cleans up all warnings generated from Sinatra. There's still
a bunch of warnings coming from HAML, though. It would be nice
if we could use Kernel#warn for deprecation notices but that's
going to be annoying if there's a bunch of unrelated warnings
from other libs.
This commit is contained in:
Ryan Tomayko 2009-01-09 01:49:49 -08:00
parent a4a1ecf233
commit 49c60151bf
4 changed files with 7 additions and 5 deletions

View File

@ -70,7 +70,7 @@ module Sinatra
def redirect(uri, *args) def redirect(uri, *args)
status 302 status 302
response['Location'] = uri response['Location'] = uri
halt *args halt(*args)
end end
# Halt processing and return the error status provided. # Halt processing and return the error status provided.
@ -476,7 +476,7 @@ module Sinatra
s !~ /\(.*\)/ } s !~ /\(.*\)/ }
file = line.sub(/:\d+.*$/, '') file = line.sub(/:\d+.*$/, '')
if data = ::IO.read(file).split('__END__')[1] if data = ::IO.read(file).split('__END__')[1]
data.gsub! /\r\n/, "\n" data.gsub!(/\r\n/, "\n")
template = nil template = nil
data.each_line do |line| data.each_line do |line|
if line =~ /^@@\s*(.*)/ if line =~ /^@@\s*(.*)/

View File

@ -10,6 +10,8 @@ module Sinatra::Test
@app = Sinatra.new(base, &block) @app = Sinatra.new(base, &block)
end end
undef request if method_defined?(:request)
def request(verb, path, *args) def request(verb, path, *args)
fail "@app not set - cannot make request" if @app.nil? fail "@app not set - cannot make request" if @app.nil?
@request = Rack::MockRequest.new(@app) @request = Rack::MockRequest.new(@app)

View File

@ -49,7 +49,7 @@ describe 'Sinatra::Base' do
it 'can take multiple definitions of a route' do it 'can take multiple definitions of a route' do
app = mock_app { app = mock_app {
user_agent /Foo/ user_agent(/Foo/)
get '/foo' do get '/foo' do
'foo' 'foo'
end end

View File

@ -278,7 +278,7 @@ describe "Routing" do
it "passes to the next route when user_agent does not match" do it "passes to the next route when user_agent does not match" do
mock_app { mock_app {
user_agent /Foo/ user_agent(/Foo/)
get '/foo' do get '/foo' do
'Hello World' 'Hello World'
end end
@ -293,7 +293,7 @@ describe "Routing" do
it "makes captures in user agent pattern available in params[:agent]" do it "makes captures in user agent pattern available in params[:agent]" do
mock_app { mock_app {
user_agent /Foo (.*)/ user_agent(/Foo (.*)/)
get '/foo' do get '/foo' do
'Hello ' + params[:agent].first 'Hello ' + params[:agent].first
end end