5 class HaveText #:nodoc:
7 def initialize(expected)
11 def matches?(response)
12 @actual = response.body
13 return actual =~ expected if Regexp === expected
14 return actual == expected unless Regexp === expected
18 "expected #{expected.inspect}, got #{actual.inspect}"
21 def negative_failure_message
22 "expected not to have text #{expected.inspect}"
26 "have text #{expected.inspect}"
36 # response.should have_text(expected)
37 # response.should_not have_text(expected)
39 # Accepts a String or a Regexp, matching a String using ==
40 # and a Regexp using =~.
42 # Use this instead of <tt>response.should have_tag()</tt>
43 # when you either don't know or don't care where on the page
48 # response.should have_text("This is the expected text")