lib/kelp/dropdown.rb
# Verify that a given dropdown does not include any of the given strings.
# This looks for the visible values in the dropdown, *not* the 'value'
# attribute of each option.
#
# @param [String] dropdown
#   Capybara locator for the dropdown (the `select` element)
# @param [Array] values
#   Visible contents you do not want to see in the dropdown
# @param [Hash] scope
#   Scoping keywords as understood by {#in_scope}
#
# @raise [Kelp::Unexpected]
#   If the given dropdown includes any value in `values`
#
# @since 0.1.2
#
Verify that a given dropdown does not include any of the given strings.
This looks for the visible values in the dropdown, *not* the 'value'
attribute of each option.
Verify that a given dropdown does not include any of the given strings . This looks for the visible values in the dropdown * not * the ' value ' attribute of each option .
def dropdown_should_not_include(dropdown, values, scope={})
      in_scope(scope) do
        values = [values] if values.class == String
        field = nice_find_field(dropdown)
        unexpected = values.select do |value|
          page.has_xpath?(".//option[text()=#{xpath_sanitize(value)}]")
        end
        if !unexpected.empty?
          raise Kelp::Unexpected,
            "Expected '#{dropdown}' dropdown to not include: #{values.inspect}" + \
            "\nDid include: #{unexpected.inspect}"
        end
      end
    end
def dropdown_should_not_include ( dropdown , values , scope = { } ) in_scope ( scope ) do values = [ values ] if values . class == String field = nice_find_field ( dropdown ) unexpected = values . select do | value | page . has_xpath? ( ".//option[text()=#{xpath_sanitize(value)}]" ) end if ! unexpected . empty? raise Kelp :: Unexpected , "Expected '#{dropdown}' dropdown to not include: #{values.inspect}" + "\nDid include: #{unexpected.inspect}" end end end
Verify that a given dropdown does not include any of the given strings.
Verify that a given dropdown does not include any of the given strings .
# If values is a String, convert it to an Array # Select all not-expected values that do appear in the dropdown
[Kelp::Unexpected] If the given dropdown includes any value in `values`
[ Kelp :: Unexpected ] If the given dropdown includes any value in ` values `
dropdown
<not_specific>
values
<not_specific>
scope
<not_specific>
<not_specific>
scope Scoping keywords as understood by {#in_scope}
scope Scoping keywords as understood by { #in_scope }
since
None