Sha256: edab23e3fcf71629df4b330333d23e782ce8b8aded9b949e8838fdc2ecc9416f

Contents?: true

Size: 679 Bytes

Versions: 16

Compression:

Stored size: 679 Bytes

Contents

class String
  def to_xhtml css = nil    
    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

require 'nokogiri'
::Nokogiri::XML::Node.class_eval do
  def should_be_fuzzy_equal_to attributes
    node_attributes = {}
    
    attributes.each do |k, v|
      nv = if k.to_s == 'content'
        self.content
      else
        self[k.to_s]
      end
      node_attributes[k] = nv
    end
    
    node_attributes.should == attributes
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rad_core-0.0.29 lib/rad/spec/xhtml.rb
rad_core-0.0.28 lib/rad/spec/xhtml.rb
rad_core-0.0.27 lib/rad/spec/xhtml.rb
rad_core-0.0.26 lib/rad/spec/xhtml.rb
rad_core-0.0.25 lib/rad/spec/xhtml.rb
rad_core-0.0.24 lib/rad/spec/xhtml.rb
rad_core-0.0.23 lib/rad/spec/xhtml.rb
rad_core-0.0.22 lib/rad/spec/xhtml.rb
rad_core-0.0.21 lib/rad/spec/xhtml.rb
rad_core-0.0.20 lib/rad/spec/xhtml.rb
rad_core-0.0.19 lib/rad/spec/xhtml.rb
rad_core-0.0.18 lib/rad/spec/xhtml.rb
rad_core-0.0.17 lib/rad/spec/xhtml.rb
rad_core-0.0.16 lib/rad/spec/xhtml.rb
rad_core-0.0.15 lib/rad/spec/xhtml.rb
rad_core-0.0.14 lib/rad/spec/xhtml.rb