Permalink
Browse files

silence logs in server_test.rb again

  • Loading branch information...
rkh committed Jun 16, 2011
1 parent 66fac5b commit 7c8826a46cac728a9111d36d545753e2b83080cc
Showing with 6 additions and 5 deletions.
  1. +3 −3 lib/sinatra/base.rb
  2. +3 −2 test/server_test.rb
View
@@ -1232,7 +1232,7 @@ def use(middleware, *args, &block)
def quit!(server, handler_name)
# Use Thin's hard #stop! if available, otherwise just #stop.
server.respond_to?(:stop!) ? server.stop! : server.stop
- STDERR.puts "\n== Sinatra has ended his set (crowd applauds)" unless handler_name =~/cgi/i
+ $stderr.puts "\n== Sinatra has ended his set (crowd applauds)" unless handler_name =~/cgi/i
end
# Run the Sinatra app as a self-hosted server using
@@ -1241,14 +1241,14 @@ def run!(options={})
set options
handler = detect_rack_handler
handler_name = handler.name.gsub(/.*::/, '')
- STDERR.puts "== Sinatra/#{Sinatra::VERSION} has taken the stage " +
+ $stderr.puts "== Sinatra/#{Sinatra::VERSION} has taken the stage " +
"on #{port} for #{environment} with backup from #{handler_name}" unless handler_name =~/cgi/i
handler.run self, :Host => bind, :Port => port do |server|
[:INT, :TERM].each { |sig| trap(sig) { quit!(server, handler_name) } }
set :running, true
end
rescue Errno::EADDRINUSE => e
- STDERR.puts "== Someone is already performing on port #{port}!"
+ $stderr.puts "== Someone is already performing on port #{port}!"
end
# The prototype instance used to process requests.
View
@@ -1,4 +1,5 @@
require File.dirname(__FILE__) + '/helper'
+require 'stringio'
module Rack::Handler
class Mock
@@ -25,11 +26,11 @@ class ServerTest < Test::Unit::TestCase
set :bind, 'foo.local'
set :port, 9001
}
- $stdout = File.open('/dev/null', 'wb')
+ $stderr = StringIO.new
end
def teardown
- $stdout = STDOUT
+ $stderr = STDERR
end
it "locates the appropriate Rack handler and calls ::run" do

0 comments on commit 7c8826a

Please sign in to comment.