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 ::Nokogiri::XML::Node.class_eval do def should_be_equal_to attributes attributes.stringify_keys! node_attributes = {} attributes.each do |k, v| nv = if k == 'content' self.content else self[k] end node_attributes[k] = nv end node_attributes.should == attributes end end