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
|
== 0.6.0 / 2009-11-28
|
||||||
|
|
||||||
REMOVED: Support for Hpricot + REXML as an alternative to Nokogiri.
|
REMOVED: Support for Hpricot + REXML as an alternative to Nokogiri.
|
||||||
|
@ -7,29 +7,33 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def matches?(response)
|
def matches?(response)
|
||||||
if @content.is_a?(Regexp)
|
|
||||||
text_finder = "regexp:#{@content.source}"
|
|
||||||
else
|
|
||||||
text_finder = @content
|
|
||||||
end
|
|
||||||
|
|
||||||
response.session.wait_for do
|
response.session.wait_for do
|
||||||
response.selenium.is_text_present(text_finder)
|
response.selenium.is_text_present(text_finder)
|
||||||
end
|
end
|
||||||
rescue Webrat::TimeoutError
|
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
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# String:: The failure message.
|
# String:: The failure message.
|
||||||
def 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
|
end
|
||||||
|
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# String:: The failure message to be displayed in negative matches.
|
# String:: The failure message to be displayed in negative matches.
|
||||||
def negative_failure_message
|
def negative_failure_message
|
||||||
"expected the following element's content to not #{content_message}:\n#{@element}"
|
"expected the response to not #{content_message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def content_message
|
def content_message
|
||||||
@ -40,6 +44,14 @@ module Webrat
|
|||||||
"match #{@content.inspect}"
|
"match #{@content.inspect}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def text_finder
|
||||||
|
if @content.is_a?(Regexp)
|
||||||
|
"regexp:#{@content.source}"
|
||||||
|
else
|
||||||
|
@content
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Matches the contents of an HTML document with
|
# Matches the contents of an HTML document with
|
||||||
|
@ -14,6 +14,14 @@ module Webrat
|
|||||||
false
|
false
|
||||||
end
|
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
|
# ==== Returns
|
||||||
# String:: The failure message.
|
# String:: The failure message.
|
||||||
def failure_message
|
def failure_message
|
||||||
|
@ -14,6 +14,14 @@ module Webrat
|
|||||||
false
|
false
|
||||||
end
|
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
|
# ==== Returns
|
||||||
# String:: The failure message.
|
# String:: The failure message.
|
||||||
def failure_message
|
def failure_message
|
||||||
|
@ -61,7 +61,7 @@ module Webrat
|
|||||||
TCPSocket.wait_for_service_with_timeout \
|
TCPSocket.wait_for_service_with_timeout \
|
||||||
:host => (Webrat.configuration.selenium_server_address || "0.0.0.0"),
|
:host => (Webrat.configuration.selenium_server_address || "0.0.0.0"),
|
||||||
:port => Webrat.configuration.selenium_server_port,
|
:port => Webrat.configuration.selenium_server_port,
|
||||||
:timeout => 15 # seconds
|
:timeout => 45 # seconds
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user