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:
parent
bfa250e7af
commit
926bcc6c66
@ -2,17 +2,6 @@ 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.
|
||||||
def self.configure(configuration = Webrat.configuration)
|
def self.configure(configuration = Webrat.configuration)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
require "webrat"
|
require "webrat"
|
||||||
gem "selenium-client", ">=1.2.14"
|
gem "selenium-client", ">=1.2.14"
|
||||||
require "selenium/client"
|
require "selenium/client"
|
||||||
|
require "webrat/selenium/silence_stream"
|
||||||
require "webrat/selenium/selenium_session"
|
require "webrat/selenium/selenium_session"
|
||||||
require "webrat/selenium/matchers"
|
require "webrat/selenium/matchers"
|
||||||
require "webrat/core_extensions/tcp_socket"
|
require "webrat/core_extensions/tcp_socket"
|
||||||
|
@ -3,7 +3,7 @@ module Webrat
|
|||||||
|
|
||||||
class ApplicationServer
|
class ApplicationServer
|
||||||
|
|
||||||
include Webrat::SilentStream
|
include Webrat::Selenium::SilenceStream
|
||||||
|
|
||||||
def self.boot
|
def self.boot
|
||||||
case Webrat.configuration.application_framework
|
case Webrat.configuration.application_framework
|
||||||
|
@ -3,7 +3,7 @@ module Webrat
|
|||||||
|
|
||||||
class SeleniumRCServer
|
class SeleniumRCServer
|
||||||
|
|
||||||
include Webrat::SilentStream
|
include Webrat::Selenium::SilenceStream
|
||||||
|
|
||||||
def self.boot
|
def self.boot
|
||||||
new.boot
|
new.boot
|
||||||
|
@ -22,7 +22,7 @@ module Webrat
|
|||||||
|
|
||||||
class SeleniumSession
|
class SeleniumSession
|
||||||
include Webrat::SaveAndOpenPage
|
include Webrat::SaveAndOpenPage
|
||||||
include Webrat::SilentStream
|
include Webrat::Selenium::SilenceStream
|
||||||
|
|
||||||
def initialize(*args) # :nodoc:
|
def initialize(*args) # :nodoc:
|
||||||
end
|
end
|
||||||
|
14
lib/webrat/selenium/silence_stream.rb
Normal file
14
lib/webrat/selenium/silence_stream.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user