Refactoring SelectOption creation

This commit is contained in:
Bryan Helmkamp 2008-11-30 01:29:58 -05:00
parent 1e7e977ec4
commit f3ff8d4ad2
2 changed files with 5 additions and 5 deletions

View File

@ -365,11 +365,7 @@ module Webrat
end
def options
option_elements.map { |oe| SelectOption.new(@session, oe) }
end
def option_elements
Webrat::XML.css_search(@element, "option")
@options ||= SelectOption.load_all(@session, @element)
end
end

View File

@ -3,6 +3,10 @@ require "webrat/core/elements/element"
module Webrat
class SelectOption < Element #:nodoc:
def self.xpath_search
".//option"
end
def matches_text?(text)
if text.is_a?(Regexp)
Webrat::XML.inner_html(@element) =~ text