diff --git a/lib/webrat/selenium.rb b/lib/webrat/selenium.rb index b7574fe..2564645 100644 --- a/lib/webrat/selenium.rb +++ b/lib/webrat/selenium.rb @@ -1,6 +1,13 @@ require "webrat" gem "selenium-client", ">=1.2.14" require "selenium/client" + +# active_support already defines silence_stream, no need to do that again if it's already present. +# http://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/kernel/reporting.rb +unless Kernel.respond_to?(:silence_stream) + require "webrat/selenium/silence_stream" +end + require "webrat/selenium/selenium_session" require "webrat/selenium/matchers" require "webrat/core_extensions/tcp_socket" diff --git a/lib/webrat/selenium/application_server.rb b/lib/webrat/selenium/application_server.rb index f4edc98..4f47332 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::Selenium::SilenceStream 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..735adf6 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::Selenium::SilenceStream def self.boot new.boot diff --git a/lib/webrat/selenium/selenium_session.rb b/lib/webrat/selenium/selenium_session.rb index bd860a5..0130b5e 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::Selenium::SilenceStream def initialize(*args) # :nodoc: end @@ -186,15 +187,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 diff --git a/lib/webrat/selenium/silence_stream.rb b/lib/webrat/selenium/silence_stream.rb new file mode 100644 index 0000000..a458306 --- /dev/null +++ b/lib/webrat/selenium/silence_stream.rb @@ -0,0 +1,14 @@ +module Webrat + module Selenium + module SilenceStream + 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 + end +end \ No newline at end of file