Sha256: 222f588a8efef441043c12489c83170a873ca0e147a40a618a3482cb7640ae25
Contents?: true
Size: 1.01 KB
Versions: 9
Compression:
Stored size: 1.01 KB
Contents
# # FuzzyHash, to_fuzzy_hash, to_html # begin require 'nokogiri' class RSpec::FuzzyHash < Hash def == o return true if super if o.respond_to? :each o.each do |k, v| return false if (self[k.to_sym] || self[k.to_s]) != v end return true 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 require 'nokogiri' node = Nokogiri::HTML(self) unless css node else nodes = node.css(css) raise "Elements for '#{css}' CSS query not found!" if nodes.size < 1 raise "Found more than one elment for '#{css}' CSS query!" if nodes.size > 1 nodes.first end end end rescue LoadError warn "WARN: some specs require the 'nokogiri' gem, but there's no such gem on this system, these specs will be scipped!" end
Version data entries
9 entries across 9 versions & 1 rubygems