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:
parent
77fa1bcdb6
commit
bfa250e7af
@ -2,6 +2,17 @@ require "webrat/core_extensions/deprecate"
|
||||
|
||||
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
|
||||
# with all of the default settings.
|
||||
def self.configure(configuration = Webrat.configuration)
|
||||
|
@ -3,6 +3,8 @@ module Webrat
|
||||
|
||||
class ApplicationServer
|
||||
|
||||
include Webrat::SilentStream
|
||||
|
||||
def self.boot
|
||||
case Webrat.configuration.application_framework
|
||||
when :sinatra
|
||||
|
@ -3,6 +3,8 @@ module Webrat
|
||||
|
||||
class SeleniumRCServer
|
||||
|
||||
include Webrat::SilentStream
|
||||
|
||||
def self.boot
|
||||
new.boot
|
||||
end
|
||||
|
@ -22,6 +22,7 @@ module Webrat
|
||||
|
||||
class SeleniumSession
|
||||
include Webrat::SaveAndOpenPage
|
||||
include Webrat::SilentStream
|
||||
|
||||
def initialize(*args) # :nodoc:
|
||||
end
|
||||
@ -182,15 +183,6 @@ module Webrat
|
||||
|
||||
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:
|
||||
Webrat::Selenium::SeleniumRCServer.boot
|
||||
Webrat::Selenium::ApplicationServer.boot
|
||||
|
Loading…
Reference in New Issue
Block a user