public
Description: Webrat - Ruby Acceptance Testing for Web applications
Homepage: http://gitrdoc.com/brynary/webrat/tree/master/
Clone URL: git://github.com/brynary/webrat.git
Moving requiring of Nokogiri/Hpricot/REXML to a method
brynary (author)
Wed Nov 19 12:52:56 -0800 2008
commit  f1b4486594311d1daaef4c9038657d7d28c18386
tree    1fc4d3b0a5ea8358ff6b0a8e895084251dd52ba3
parent  ec8bc82c243541a1fef06de19ed1ecd338881984
...
12
13
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
16
17
18
19
20
21
22
23
24
25
 
26
27
28
29
30
31
32
33
 
...
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
 
 
 
 
 
 
 
 
33
34
35
36
37
38
 
 
 
39
0
@@ -12,22 +12,28 @@ module Webrat
0
     defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
0
   end
0
 
0
+  def self.require_xml
0
+    if on_java?
0
+      # We need Nokogiri's CSS to XPath support, even if using REXML and Hpricot for parsing and searching
0
+      require "nokogiri/css"
0
+      require "hpricot"
0
+      require "rexml/document"
0
+    else
0
+      require "nokogiri"
0
+      require "webrat/core/nokogiri"
0
+    end
0
+  end
0
+  
0
+  def self.on_java?
0
+    RUBY_PLATFORM =~ /java/
0
+  end
0
+  
0
 end
0
 
0
-if RUBY_PLATFORM =~ /java/
0
-  # We need Nokogiri's CSS to XPath support, even if using REXML and Hpricot for parsing and searching
0
-  require "nokogiri/css"
0
-  require "hpricot"
0
-  require "rexml/document"
0
-else
0
-  require "nokogiri"
0
-  require "webrat/core/nokogiri"
0
-end
0
+Webrat.require_xml
0
 
0
 require "webrat/core"
0
 
0
 # TODO: This is probably not a good idea.
0
 # Probably better for webrat users to require "webrat/rails" etc. directly
0
-if defined?(RAILS_ENV)
0
-  require "webrat/rails"
0
-end
0
+require "webrat/rails" if defined?(RAILS_ENV)

Comments