Created
February 4, 2010 16:09
-
-
Save biot023/294802 to your computer and use it in GitHub Desktop.
my_env.rb
This file contains 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
# Again, the text() method wouldn't give me what I wanted, so I came up with this to get at it (and to remove any | |
# whitespace either side of it). | |
# Used like: | |
# find( "//a[@id = 'messages']" ).should contain_text( "Review Your Messages" ) | |
class ContainText | |
def initialize( text ) | |
@text = text | |
end | |
def matches?( node ) | |
@node_text = node.text.strip | |
return true if @node_text.blank? && @text.blank? | |
@node_text == @text | |
end | |
def failure_message | |
"The node should have contained the text #{ @text.inspect }, but instead got #{ @node_text.inspect }." | |
end | |
def negative_failure_message | |
"The node should not have contained the text #{ text.inspect }, but did in #{ @node_text.inspect }." | |
end | |
end | |
def contain_text( text ) | |
ContainText.new( text ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment