Class: Webrat::CheckboxField

Inherits:
Field show all
Defined in:
lib/webrat/core/elements/field.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Field

#value

Attributes inherited from Element

#element

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Field

#disabled?, field_class, field_classes, #id, inherited, #initialize, #label_text, load, #raise_error_if_disabled, #set, #unset, xpath_search_excluding_hidden

Methods inherited from Element

#initialize, #inspect, load, load_all, #path

Constructor Details

This class inherits a constructor from Webrat::Field

Class Method Details

.xpath_searchObject



260
261
262
# File 'lib/webrat/core/elements/field.rb', line 260

def self.xpath_search
  ".//input[@type = 'checkbox']"
end

Instance Method Details

#checkObject



269
270
271
272
# File 'lib/webrat/core/elements/field.rb', line 269

def check
  raise_error_if_disabled
  set(@element["value"] || "on")
end

#checked?Boolean

Returns:

  • (Boolean)


274
275
276
# File 'lib/webrat/core/elements/field.rb', line 274

def checked?
  @element["checked"] == "checked"
end

#to_paramObject



264
265
266
267
# File 'lib/webrat/core/elements/field.rb', line 264

def to_param
  return nil if @value.nil?
  super
end

#uncheckObject



278
279
280
281
# File 'lib/webrat/core/elements/field.rb', line 278

def uncheck
  raise_error_if_disabled
  set(nil)
end