Created
September 1, 2010 00:18
-
-
Save hassox/560013 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rspec::Matchers.define :match_nokogiri_selector do |selector| | |
| match do |doc| | |
| doc.at(selector) != nil | |
| end | |
| failure_message_for_should do |doc| | |
| "expected #{selector} to be found in \n#{doc.to_xml}" | |
| end | |
| failure_message_for_should_not do |doc| | |
| "expected that #{selector} would not be found in #{doc.to_xml}" | |
| end | |
| description do | |
| "match a selector of a nokogiri document" | |
| end | |
| end | |
| ## Example | |
| xml = Nokogiri.XML(File.read(xml_path)) | |
| xml.should match_nokogiri_selector "section article[class='stuff'] h1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment