Simplify select option matching code. Minor behavior change:

Valid: select "Peanut Butter & Jelly"
  Invalid: select "Peanut Butter & Jelly"
This commit is contained in:
Bryan Helmkamp 2009-09-07 12:44:54 -04:00
parent b7ea26841e
commit 00c49a0521
2 changed files with 6 additions and 6 deletions

View File

@ -17,6 +17,10 @@ module Webrat
select.unset(value) select.unset(value)
end end
def inner_text
@element.inner_text
end
protected protected
def select def select

View File

@ -21,7 +21,7 @@ module Webrat
if @option_text.is_a?(Regexp) if @option_text.is_a?(Regexp)
o.element.inner_html =~ @option_text o.element.inner_html =~ @option_text
else else
escaped_or_non_escaped_values.include?(o.element.inner_html) o.inner_text == @option_text.to_s
end end
end end
else else
@ -29,7 +29,7 @@ module Webrat
if @option_text.is_a?(Regexp) if @option_text.is_a?(Regexp)
o.inner_html =~ @option_text o.inner_html =~ @option_text
else else
escaped_or_non_escaped_values.include?(o.inner_html) o.inner_text == @option_text.to_s
end end
end end
@ -37,10 +37,6 @@ module Webrat
end end
end end
def escaped_or_non_escaped_values
[@option_text.to_s, CGI.escapeHTML(@option_text.to_s)]
end
def option_elements def option_elements
@dom.xpath(*SelectOption.xpath_search) @dom.xpath(*SelectOption.xpath_search)
end end