Skip to content

Commit

Permalink
Incorporated kid80's regex matching.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent Greeff committed Sep 14, 2009
1 parent c3035b1 commit 970b411
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.rdoc
Expand Up @@ -23,6 +23,10 @@ Designed for use with ActiveSupport::TestCase (Test/Unit)

count('ol#girlfriends li').should_be 6

* You can also pass a regex

element("div.wicked").should_be /fuzzy match this/

* You can also pass in html

element("div.wicked", some_html).should_be_present
Expand All @@ -31,4 +35,7 @@ Designed for use with ActiveSupport::TestCase (Test/Unit)
Please refer to the Hpricot library for more examples
of the kind of selectors available.

Mad props to Kid80 for the regex matching patch.


Copyright (c) 2009 [Brent Greeff], released under the MIT license
7 changes: 6 additions & 1 deletion lib/should_pricot/element_assertion.rb
Expand Up @@ -8,7 +8,12 @@ def initialize(selector, html, test_instance)

def should_be(expected)
should_be_present
assert_equal expected, @element.inner_html.strip

if expected.is_a? Regexp
assert_match expected, @element.inner_html.strip
else
assert_equal expected, @element.inner_html.strip
end
end

def should_be_present
Expand Down

0 comments on commit 970b411

Please sign in to comment.