From 49c60151bfcd2440d21f53424089c58027c819d5 Mon Sep 17 00:00:00 2001 From: Ryan Tomayko Date: Fri, 9 Jan 2009 01:49:49 -0800 Subject: [PATCH] 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. --- lib/sinatra/base.rb | 4 ++-- lib/sinatra/test.rb | 2 ++ test/base_test.rb | 2 +- test/routing_test.rb | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 6532a24e..1c75729e 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -70,7 +70,7 @@ module Sinatra def redirect(uri, *args) status 302 response['Location'] = uri - halt *args + halt(*args) end # Halt processing and return the error status provided. @@ -476,7 +476,7 @@ module Sinatra s !~ /\(.*\)/ } file = line.sub(/:\d+.*$/, '') if data = ::IO.read(file).split('__END__')[1] - data.gsub! /\r\n/, "\n" + data.gsub!(/\r\n/, "\n") template = nil data.each_line do |line| if line =~ /^@@\s*(.*)/ diff --git a/lib/sinatra/test.rb b/lib/sinatra/test.rb index a37b5c46..2afde1be 100644 --- a/lib/sinatra/test.rb +++ b/lib/sinatra/test.rb @@ -10,6 +10,8 @@ module Sinatra::Test @app = Sinatra.new(base, &block) end + undef request if method_defined?(:request) + def request(verb, path, *args) fail "@app not set - cannot make request" if @app.nil? @request = Rack::MockRequest.new(@app) diff --git a/test/base_test.rb b/test/base_test.rb index 18bd410a..b783fef5 100644 --- a/test/base_test.rb +++ b/test/base_test.rb @@ -49,7 +49,7 @@ describe 'Sinatra::Base' do it 'can take multiple definitions of a route' do app = mock_app { - user_agent /Foo/ + user_agent(/Foo/) get '/foo' do 'foo' end diff --git a/test/routing_test.rb b/test/routing_test.rb index 374af410..ed302a17 100644 --- a/test/routing_test.rb +++ b/test/routing_test.rb @@ -278,7 +278,7 @@ describe "Routing" do it "passes to the next route when user_agent does not match" do mock_app { - user_agent /Foo/ + user_agent(/Foo/) get '/foo' do 'Hello World' end @@ -293,7 +293,7 @@ describe "Routing" do it "makes captures in user agent pattern available in params[:agent]" do mock_app { - user_agent /Foo (.*)/ + user_agent(/Foo (.*)/) get '/foo' do 'Hello ' + params[:agent].first end