webrat/lib/webrat/core/select_option.rb

29 lines
525 B
Ruby
Raw Normal View History

2008-04-07 04:52:49 +00:00
module Webrat
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
@select.raise_error_if_disabled
2008-04-07 04:52:49 +00:00
@select.set(value)
end
protected
def value
Webrat::XML.attribute(@element, "value") || @element.inner_html
2008-04-07 04:52:49 +00:00
end
end
end