2008-04-07 04:52:49 +00:00
|
|
|
module Webrat
|
2008-11-07 17:13:41 +00:00
|
|
|
class SelectOption #:nodoc:
|
2008-04-07 04:52:49 +00:00
|
|
|
|
|
|
|
def initialize(select, element)
|
|
|
|
@select = select
|
|
|
|
@element = element
|
|
|
|
end
|
|
|
|
|
2008-04-12 21:22:20 +00:00
|
|
|
def matches_text?(text)
|
|
|
|
if text.is_a?(Regexp)
|
2008-11-06 22:53:41 +00:00
|
|
|
@element.inner_html =~ text
|
2008-04-12 21:22:20 +00:00
|
|
|
else
|
2008-11-06 22:53:41 +00:00
|
|
|
@element.inner_html == text.to_s
|
2008-04-12 21:22:20 +00:00
|
|
|
end
|
2008-04-07 04:52:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def choose
|
2008-10-02 00:22:23 +00:00
|
|
|
@select.raise_error_if_disabled
|
2008-04-07 04:52:49 +00:00
|
|
|
@select.set(value)
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def value
|
2008-11-27 05:52:17 +00:00
|
|
|
Webrat::XML.attribute(@element, "value") || @element.inner_html
|
2008-04-07 04:52:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|