extracted silence_stream into its own file under webrat/selenium

I don't think silence_stream.rb should be stored under
core_extensions, because the way it's implemented, it simply is
no core extension. Also, a grep through webrat source shows that
silence_stream is only used inside the selenium support. This is
why I added webrat/selenium/silence_stream.rb and require it
*before* all other selenium related files in webrat/selenium.rb.
It's necessary to include it this early, because if mode is set
to :selenium, webrat/selenium.rb is required, which in turn
requires webrat/selenium/selenium_session.rb and silence_stream
must be available before selenium_session gets required because
selenium_session already wants to silence the stream.
This commit is contained in:
snusnu 2009-05-13 03:35:32 +02:00
parent bfa250e7af
commit 926bcc6c66
6 changed files with 18 additions and 14 deletions

View File

@ -2,17 +2,6 @@ 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)

View File

@ -1,6 +1,7 @@
require "webrat"
gem "selenium-client", ">=1.2.14"
require "selenium/client"
require "webrat/selenium/silence_stream"
require "webrat/selenium/selenium_session"
require "webrat/selenium/matchers"
require "webrat/core_extensions/tcp_socket"

View File

@ -3,7 +3,7 @@ module Webrat
class ApplicationServer
include Webrat::SilentStream
include Webrat::Selenium::SilenceStream
def self.boot
case Webrat.configuration.application_framework

View File

@ -3,7 +3,7 @@ module Webrat
class SeleniumRCServer
include Webrat::SilentStream
include Webrat::Selenium::SilenceStream
def self.boot
new.boot

View File

@ -22,7 +22,7 @@ module Webrat
class SeleniumSession
include Webrat::SaveAndOpenPage
include Webrat::SilentStream
include Webrat::Selenium::SilenceStream
def initialize(*args) # :nodoc:
end

View File

@ -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