lib/rspec_ext/xhtml.rb in ruby_ext-0.4.25 vs lib/rspec_ext/xhtml.rb in ruby_ext-0.5.1
- old
+ new
@@ -1,11 +1,11 @@
-#
+#
# FuzzyHash, to_fuzzy_hash, to_html
-#
+#
begin
require 'nokogiri'
-
+
class RSpec::FuzzyHash < Hash
def == o
return true if super
if o.respond_to? :each
@@ -16,21 +16,21 @@
end
false
end
end
-
+
::Nokogiri::XML::Node.class_eval do
def to_fuzzy_hash
h = RSpec::FuzzyHash.new
attributes.each{|n, v| h[n] = v.value}
h[:content] = content
h
end
end
-
+
class String
- def to_xhtml css = nil
+ def to_xhtml css = nil
require 'nokogiri'
node = Nokogiri::HTML(self)
unless css
node
\ No newline at end of file