Make selenium matchers handle negative match more consistently with positive match
This commit is contained in:
parent
b64d68a2a8
commit
f9985cd488
@ -1,3 +1,7 @@
|
||||
* Bug fixes
|
||||
|
||||
* Make selenium matchers handle negative match more consistently with positive match (Luke Melia)
|
||||
|
||||
== 0.6.0 / 2009-11-28
|
||||
|
||||
REMOVED: Support for Hpricot + REXML as an alternative to Nokogiri.
|
||||
|
@ -7,29 +7,33 @@ module Webrat
|
||||
end
|
||||
|
||||
def matches?(response)
|
||||
if @content.is_a?(Regexp)
|
||||
text_finder = "regexp:#{@content.source}"
|
||||
else
|
||||
text_finder = @content
|
||||
end
|
||||
|
||||
response.session.wait_for do
|
||||
response.selenium.is_text_present(text_finder)
|
||||
end
|
||||
rescue Webrat::TimeoutError
|
||||
false
|
||||
rescue Webrat::TimeoutError => e
|
||||
@error_message = e.message
|
||||
false
|
||||
end
|
||||
|
||||
def does_not_match?(response)
|
||||
response.session.wait_for do
|
||||
!response.selenium.is_text_present(text_finder)
|
||||
end
|
||||
rescue Webrat::TimeoutError => e
|
||||
@error_message = e.message
|
||||
false
|
||||
end
|
||||
|
||||
# ==== Returns
|
||||
# String:: The failure message.
|
||||
def failure_message
|
||||
"expected the following element's content to #{content_message}:\n#{@element}"
|
||||
"expected the response to #{content_message}:\n#{@error_message}"
|
||||
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}"
|
||||
"expected the response to not #{content_message}"
|
||||
end
|
||||
|
||||
def content_message
|
||||
@ -40,6 +44,14 @@ module Webrat
|
||||
"match #{@content.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
def text_finder
|
||||
if @content.is_a?(Regexp)
|
||||
"regexp:#{@content.source}"
|
||||
else
|
||||
@content
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Matches the contents of an HTML document with
|
||||
@ -52,7 +64,7 @@ module Webrat
|
||||
# the supplied string or regexp
|
||||
def assert_contain(content)
|
||||
hc = HasContent.new(content)
|
||||
assert hc.matches?(response), hc.failure_message
|
||||
assert hc.matches?(response), hc.failure_message
|
||||
end
|
||||
|
||||
# Asserts that the body of the response
|
||||
|
@ -14,6 +14,14 @@ module Webrat
|
||||
false
|
||||
end
|
||||
|
||||
def does_not_match?(response)
|
||||
response.session.wait_for do
|
||||
!response.selenium.is_element_present("css=#{@expected}")
|
||||
end
|
||||
rescue Webrat::TimeoutError
|
||||
false
|
||||
end
|
||||
|
||||
# ==== Returns
|
||||
# String:: The failure message.
|
||||
def failure_message
|
||||
|
@ -14,6 +14,14 @@ module Webrat
|
||||
false
|
||||
end
|
||||
|
||||
def does_not_match?(response)
|
||||
response.session.wait_for do
|
||||
!response.selenium.is_element_present("xpath=#{@expected}")
|
||||
end
|
||||
rescue Webrat::TimeoutError
|
||||
false
|
||||
end
|
||||
|
||||
# ==== Returns
|
||||
# String:: The failure message.
|
||||
def failure_message
|
||||
|
@ -61,7 +61,7 @@ module Webrat
|
||||
TCPSocket.wait_for_service_with_timeout \
|
||||
:host => (Webrat.configuration.selenium_server_address || "0.0.0.0"),
|
||||
:port => Webrat.configuration.selenium_server_port,
|
||||
:timeout => 15 # seconds
|
||||
:timeout => 45 # seconds
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user