From 00c49a052155594f4e9cc0f585e94a8d9a587603 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Mon, 7 Sep 2009 12:44:54 -0400 Subject: [PATCH] Simplify select option matching code. Minor behavior change: Valid: select "Peanut Butter & Jelly" Invalid: select "Peanut Butter & Jelly" --- lib/webrat/core/elements/select_option.rb | 4 ++++ lib/webrat/core/locators/select_option_locator.rb | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/webrat/core/elements/select_option.rb b/lib/webrat/core/elements/select_option.rb index 8e19e4f..a586a77 100644 --- a/lib/webrat/core/elements/select_option.rb +++ b/lib/webrat/core/elements/select_option.rb @@ -17,6 +17,10 @@ module Webrat select.unset(value) end + def inner_text + @element.inner_text + end + protected def select diff --git a/lib/webrat/core/locators/select_option_locator.rb b/lib/webrat/core/locators/select_option_locator.rb index 10f509b..49df2b0 100644 --- a/lib/webrat/core/locators/select_option_locator.rb +++ b/lib/webrat/core/locators/select_option_locator.rb @@ -21,7 +21,7 @@ module Webrat 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 @@ -29,7 +29,7 @@ module Webrat 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 @@ -37,10 +37,6 @@ module Webrat 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