Class: Chop::Form::Select

Inherits:
Field
  • Object
show all
Defined in:
lib/chop/form.rb

Instance Attribute Summary

Attributes inherited from Field

#field, #label, #path, #session, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Field

candidates, combined_css_selector, for, from, #label_text, #should_include_in_diff?, #to_diff_row

Class Method Details

.css_selectorObject



175
176
177
# File 'lib/chop/form.rb', line 175

def self.css_selector
  "select"
end

Instance Method Details

#diff_valueObject



193
194
195
# File 'lib/chop/form.rb', line 193

def diff_value
  get_value.to_s
end

#fill_in!Object



183
184
185
# File 'lib/chop/form.rb', line 183

def fill_in!
  session.select value, from: label
end

#get_valueObject



187
188
189
190
191
# File 'lib/chop/form.rb', line 187

def get_value
  if selected_value = field.value
    field.find("option[value='#{selected_value}']").text
  end
end

#matches?Boolean

Returns:

  • (Boolean)


179
180
181
# File 'lib/chop/form.rb', line 179

def matches?
  field.tag_name == "select" && field[:multiple].to_s == "false"
end