Update requires to fix compatibility with Nokogiri 1.1.0

This commit is contained in:
Bryan Helmkamp 2008-12-27 19:45:31 -05:00
parent 859a15b8d8
commit 95e3260142

View File

@ -8,20 +8,27 @@ module Webrat
def self.root #:nodoc: def self.root #:nodoc:
defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
end end
def self.require_xml
gem "nokogiri", ">= 1.1.0"
if on_java?
# We need Nokogiri's CSS to XPath support, even if using REXML and Hpricot for parsing and searching
require "nokogiri/css"
require "hpricot"
require "rexml/document"
else
require "nokogiri"
require "webrat/core/nokogiri"
end
end
def self.on_java?
RUBY_PLATFORM =~ /java/
end
end end
# We need Nokogiri's CSS to XPath support, even if using REXML Webrat.require_xml
require "nokogiri/css"
# Require nokogiri and fall back on rexml
begin
require "nokogiri"
require "webrat/core/nokogiri"
rescue LoadError => e
require "rexml/document"
warn("Standard REXML library is slow. Please consider installing nokogiri.\nUse \"sudo gem install nokogiri\"")
end
require "webrat/core" require "webrat/core"
# TODO: This is probably not a good idea. # TODO: This is probably not a good idea.