backed out will add in again as a different feature

This commit is contained in:
Amos King 2009-01-02 14:36:16 -06:00
parent 45bd577955
commit fe5d183e69
2 changed files with 55 additions and 1 deletions

View File

@ -88,7 +88,6 @@ module ActionController #:nodoc:
IntegrationTest.class_eval do
include Webrat::Methods
include Webrat::Selenium::Methods
include Webrat::Matchers
include Webrat::Selenium::Matchers
end
end

View File

@ -12,6 +12,18 @@ module Webrat
response.selenium.is_element_present("xpath=#{@expected}")
end
end
# ==== Returns
# String:: The failure message.
def failure_message
"expected following text to match xpath #{@expected}:\n#{@document}"
end
# ==== Returns
# String:: The failure message to be displayed in negative matches.
def negative_failure_message
"expected following text to not match xpath #{@expected}:\n#{@document}"
end
end
def have_xpath(xpath)
@ -28,6 +40,18 @@ module Webrat
response.selenium.is_element_present("css=#{@expected}")
end
end
# ==== Returns
# String:: The failure message.
def failure_message
"expected following text to match selector #{@expected}:\n#{@document}"
end
# ==== Returns
# String:: The failure message to be displayed in negative matches.
def negative_failure_message
"expected following text to not match selector #{@expected}:\n#{@document}"
end
end
def have_selector(content)
@ -35,6 +59,10 @@ module Webrat
end
class HasContent #:nodoc:
def initialize(content)
@content = content
end
def matches?(response)
if @content.is_a?(Regexp)
text_finder = "regexp:#{@content.source}"
@ -46,6 +74,33 @@ module Webrat
response.selenium.is_text_present(text_finder)
end
end
# ==== Returns
# String:: The failure message.
def failure_message
"expected the following element's content to #{content_message}:\n#{@element}"
end
# ==== Returns
# String:: The failure message to be displayed in negative matches.
def negative_failure_message
"expected the following element's content to not #{content_message}:\n#{@element}"
end
def content_message
case @content
when String
"include \"#{@content}\""
when Regexp
"match #{@content.inspect}"
end
end
end
# Matches the contents of an HTML document with
# whatever string is supplied
def contain(content)
HasContent.new(content)
end
end