Provide an implementation for silence_stream inside webrat.

I added the implementation to webrat/core/configuration.rb because
it seems to me that this always gets read first. I decided to put
it inside a util module Webrat::SilentStream and include this where
appropriate, instead of altering Kernel.
This commit is contained in:
snusnu 2009-05-12 18:32:30 +02:00
parent 77fa1bcdb6
commit bfa250e7af
4 changed files with 16 additions and 9 deletions

View File

@ -1,6 +1,17 @@
require "webrat/core_extensions/deprecate" require "webrat/core_extensions/deprecate"
module Webrat module Webrat
module SilentStream
def silence_stream(stream)
old_stream = stream.dup
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
stream.sync = true
yield
ensure
stream.reopen(old_stream)
end
end
# Configures Webrat. If this is not done, Webrat will be created # Configures Webrat. If this is not done, Webrat will be created
# with all of the default settings. # with all of the default settings.

View File

@ -2,6 +2,8 @@ module Webrat
module Selenium module Selenium
class ApplicationServer class ApplicationServer
include Webrat::SilentStream
def self.boot def self.boot
case Webrat.configuration.application_framework case Webrat.configuration.application_framework

View File

@ -2,6 +2,8 @@ module Webrat
module Selenium module Selenium
class SeleniumRCServer class SeleniumRCServer
include Webrat::SilentStream
def self.boot def self.boot
new.boot new.boot

View File

@ -22,6 +22,7 @@ module Webrat
class SeleniumSession class SeleniumSession
include Webrat::SaveAndOpenPage include Webrat::SaveAndOpenPage
include Webrat::SilentStream
def initialize(*args) # :nodoc: def initialize(*args) # :nodoc:
end end
@ -182,15 +183,6 @@ module Webrat
protected protected
def silence_stream(stream)
old_stream = stream.dup
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
stream.sync = true
yield
ensure
stream.reopen(old_stream)
end
def setup #:nodoc: def setup #:nodoc:
Webrat::Selenium::SeleniumRCServer.boot Webrat::Selenium::SeleniumRCServer.boot
Webrat::Selenium::ApplicationServer.boot Webrat::Selenium::ApplicationServer.boot