Permalink
Browse files

Simplify select option matching code. Minor behavior change:

  Valid: select "Peanut Butter & Jelly"
  Invalid: select "Peanut Butter & Jelly"
  • Loading branch information...
1 parent b7ea268 commit 00c49a052155594f4e9cc0f585e94a8d9a587603 @brynary brynary committed Sep 7, 2009
Showing with 6 additions and 6 deletions.
  1. +4 −0 lib/webrat/core/elements/select_option.rb
  2. +2 −6 lib/webrat/core/locators/select_option_locator.rb
@@ -17,6 +17,10 @@ def unchoose
select.unset(value)
end
+ def inner_text
+ @element.inner_text
+ end
+
protected
def select
@@ -21,26 +21,22 @@ def locate
if @option_text.is_a?(Regexp)
o.element.inner_html =~ @option_text
else
- escaped_or_non_escaped_values.include?(o.element.inner_html)
+ o.inner_text == @option_text.to_s
end
end
else
option_element = option_elements.detect do |o|
if @option_text.is_a?(Regexp)
o.inner_html =~ @option_text
else
- escaped_or_non_escaped_values.include?(o.inner_html)
+ o.inner_text == @option_text.to_s
end
end
SelectOption.load(@session, option_element)
end
end
- def escaped_or_non_escaped_values
- [@option_text.to_s, CGI.escapeHTML(@option_text.to_s)]
- end
-
def option_elements
@dom.xpath(*SelectOption.xpath_search)
end

0 comments on commit 00c49a0

Please sign in to comment.