class Wrapybara::Option

Attributes

element[RW]
parent[RW]

Public Class Methods

new(select, option) click to toggle source
# File lib/wrapybara/elements/option.rb, line 7
def initialize(select, option)
        @option = option
        @parent = select
        xpath = option.blank? ? ".//option[normalize-space()='']" : XPath::HTML.option(option)
        @element = select.element.find(xpath) rescue nil
end

Public Instance Methods

deselect() click to toggle source
# File lib/wrapybara/elements/option.rb, line 28
def deselect
        self.should_exist
        # Capybara method
        @element.unselect_option
end
select() click to toggle source
# File lib/wrapybara/elements/option.rb, line 22
def select
        self.should_exist
        # Capybara method
        @element.select_option
end
selected?() click to toggle source
# File lib/wrapybara/elements/option.rb, line 34
def selected?
        self.should_exist
        # Capybara method
        @element.selected? || @parent.element.value == @element.value
end
should_be_selected() click to toggle source
# File lib/wrapybara/elements/option.rb, line 40
def should_be_selected
        raise UnmetExpectation, "Expected select #{self.parent_identifier} to have option '#{@option}' selected" unless self.selected?
end
should_exist() click to toggle source
Calls superclass method Wrapybara::Element#should_exist
# File lib/wrapybara/elements/option.rb, line 14
def should_exist
        super "Expected select #{self.parent_identifier} to have option '#{@option}'"
end
should_not_be_selected() click to toggle source
# File lib/wrapybara/elements/option.rb, line 44
def should_not_be_selected
        raise UnmetExpectation, "Did not expect select #{self.parent_identifier} to have option '#{@option}' selected" if self.selected?
end
should_not_exist() click to toggle source
Calls superclass method Wrapybara::Element#should_not_exist
# File lib/wrapybara/elements/option.rb, line 18
def should_not_exist
        super "Did not expect select #{self.parent_identifier} to have option '#{@option}'"
end