From e5b0e773328f2993ea07e4c0f72c2231a72388cd Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Fri, 7 Nov 2008 02:49:48 -0500 Subject: [PATCH] Moving require of nokogiri to webrat.rb --- lib/webrat.rb | 12 ++++++++++++ lib/webrat/core/matchers/have_content.rb | 11 ----------- lib/webrat/core/matchers/have_xpath.rb | 12 ------------ 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/lib/webrat.rb b/lib/webrat.rb index 748c869..20b0119 100644 --- a/lib/webrat.rb +++ b/lib/webrat.rb @@ -10,6 +10,18 @@ module Webrat end end +# We need Nokogiri's CSS to XPath support, even if using REXML +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" # TODO: This is probably not a good idea. diff --git a/lib/webrat/core/matchers/have_content.rb b/lib/webrat/core/matchers/have_content.rb index 895d33b..faa81df 100644 --- a/lib/webrat/core/matchers/have_content.rb +++ b/lib/webrat/core/matchers/have_content.rb @@ -3,17 +3,6 @@ module Webrat class HasContent def initialize(content) - # We need Nokogiri's CSS to XPath support, even if using REXML - require "nokogiri/css" - - 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 - @content = content end diff --git a/lib/webrat/core/matchers/have_xpath.rb b/lib/webrat/core/matchers/have_xpath.rb index 8fd23d8..b949e54 100644 --- a/lib/webrat/core/matchers/have_xpath.rb +++ b/lib/webrat/core/matchers/have_xpath.rb @@ -3,18 +3,6 @@ module Webrat class HaveXpath def initialize(expected, &block) - # We need Nokogiri's CSS to XPath support, even if using REXML - 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 - @expected = expected @block = block end