Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Test the html in your functional tests using the wicked Hpricot CSS / XPath selectors.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 init.rb
Octocat-spinner-32 should_pricot.gemspec
README.rdoc

ShouldPricot

Test the html in your functional tests using the wicked Hpricot CSS / XPath selectors. Requires Hpricot. Designed for use with ActiveSupport::TestCase (Test/Unit)

Install

gem install should_pricot

(or use bundler)

Example

  • I want to test something appears on the page:

    element('h1').should_be_present
  • I want to test something does not appear:

    element('#power_user a[@href="/create/havok"]').should_be_missing
  • I want to check an elements contents:

    element('.intro p').should_be 'Welcome'
  • I want to count the number of times something appears:

    count('ol#girlfriends li').should_be 6
  • You can also pass a regex

    element("div.wicked").should_be /containg this/
  • Even better

    element('.date').should_contain "today"
  • You can also pass in html

    element("div.wicked", some_html).should_be_present

Please refer to the Hpricot library for more examples of the kind of selectors available.

Funktional

Designed to be used with the funktional testing library which provides contexts and class level assertions on top of Test:Unit.

Mad props to Kid80 for the regex matching patch.

Copyright © 2009 [Brent Greeff], released under the MIT license

Something went wrong with that request. Please try again.