From bfa250e7af9b00475af34b4389ae140a467f502f Mon Sep 17 00:00:00 2001 From: snusnu Date: Tue, 12 May 2009 18:32:30 +0200 Subject: [PATCH] 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. --- lib/webrat/core/configuration.rb | 11 +++++++++++ lib/webrat/selenium/application_server.rb | 2 ++ lib/webrat/selenium/selenium_rc_server.rb | 2 ++ lib/webrat/selenium/selenium_session.rb | 10 +--------- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/webrat/core/configuration.rb b/lib/webrat/core/configuration.rb index 33d274f..376cd36 100755 --- a/lib/webrat/core/configuration.rb +++ b/lib/webrat/core/configuration.rb @@ -1,6 +1,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. diff --git a/lib/webrat/selenium/application_server.rb b/lib/webrat/selenium/application_server.rb index f4edc98..65b2993 100644 --- a/lib/webrat/selenium/application_server.rb +++ b/lib/webrat/selenium/application_server.rb @@ -2,6 +2,8 @@ module Webrat module Selenium class ApplicationServer + + include Webrat::SilentStream def self.boot case Webrat.configuration.application_framework diff --git a/lib/webrat/selenium/selenium_rc_server.rb b/lib/webrat/selenium/selenium_rc_server.rb index 0d0b651..2685af4 100644 --- a/lib/webrat/selenium/selenium_rc_server.rb +++ b/lib/webrat/selenium/selenium_rc_server.rb @@ -2,6 +2,8 @@ module Webrat module Selenium class SeleniumRCServer + + include Webrat::SilentStream def self.boot new.boot diff --git a/lib/webrat/selenium/selenium_session.rb b/lib/webrat/selenium/selenium_session.rb index 5149299..5512f4e 100644 --- a/lib/webrat/selenium/selenium_session.rb +++ b/lib/webrat/selenium/selenium_session.rb @@ -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