Skip to content

Commit

Permalink
Simplify select option matching code. Minor behavior change:
Browse files Browse the repository at this point in the history
  Valid: select "Peanut Butter & Jelly"
  Invalid: select "Peanut Butter & Jelly"
  • Loading branch information
brynary committed Sep 7, 2009
1 parent b7ea268 commit 00c49a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lib/webrat/core/elements/select_option.rb
Expand Up @@ -17,6 +17,10 @@ def unchoose
select.unset(value)
end

def inner_text
@element.inner_text
end

protected

def select
Expand Down
8 changes: 2 additions & 6 deletions lib/webrat/core/locators/select_option_locator.rb
Expand Up @@ -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
Expand Down

0 comments on commit 00c49a0

Please sign in to comment.