fix selenium matchers to only overide needed methods from the oriinal matchers so that I don't have to write the same methods again for selenium mode.
This commit is contained in:
parent
b77c33b865
commit
45bd577955
@ -88,6 +88,7 @@ module ActionController #:nodoc:
|
|||||||
IntegrationTest.class_eval do
|
IntegrationTest.class_eval do
|
||||||
include Webrat::Methods
|
include Webrat::Methods
|
||||||
include Webrat::Selenium::Methods
|
include Webrat::Selenium::Methods
|
||||||
|
include Webrat::Matchers
|
||||||
include Webrat::Selenium::Matchers
|
include Webrat::Selenium::Matchers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,18 +12,6 @@ module Webrat
|
|||||||
response.selenium.is_element_present("xpath=#{@expected}")
|
response.selenium.is_element_present("xpath=#{@expected}")
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
def have_xpath(xpath)
|
def have_xpath(xpath)
|
||||||
@ -40,18 +28,6 @@ module Webrat
|
|||||||
response.selenium.is_element_present("css=#{@expected}")
|
response.selenium.is_element_present("css=#{@expected}")
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
def have_selector(content)
|
def have_selector(content)
|
||||||
@ -59,10 +35,6 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
class HasContent #:nodoc:
|
class HasContent #:nodoc:
|
||||||
def initialize(content)
|
|
||||||
@content = content
|
|
||||||
end
|
|
||||||
|
|
||||||
def matches?(response)
|
def matches?(response)
|
||||||
if @content.is_a?(Regexp)
|
if @content.is_a?(Regexp)
|
||||||
text_finder = "regexp:#{@content.source}"
|
text_finder = "regexp:#{@content.source}"
|
||||||
@ -74,33 +46,6 @@ module Webrat
|
|||||||
response.selenium.is_text_present(text_finder)
|
response.selenium.is_text_present(text_finder)
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user