Class FormTestHelper::CheckBox
In: lib/form_test_helper.rb
Parent: Field

Methods

Public Instance methods

[Source]

     # File lib/form_test_helper.rb, line 281
281:     def check
282:       self.value = checked_value
283:     end

[Source]

     # File lib/form_test_helper.rb, line 260
260:     def checked_value
261:       @checkbox_tag = tags.detect {|field_tag| field_tag['type'] == 'checkbox' }
262:       @checkbox_tag['value']
263:     end

[Source]

     # File lib/form_test_helper.rb, line 256
256:     def initial_value
257:       tag['checked'] ? checked_value : unchecked_value
258:     end

[Source]

     # File lib/form_test_helper.rb, line 285
285:     def uncheck
286:       self.value = unchecked_value
287:     end

[Source]

     # File lib/form_test_helper.rb, line 265
265:     def unchecked_value
266:       @hidden_tag = tags.detect {|field_tag| field_tag['type'] == 'hidden' }
267:       @hidden_tag ? @hidden_tag['value'] : nil
268:     end

[Source]

     # File lib/form_test_helper.rb, line 270
270:     def value=(value)
271:       case value
272:       when TrueClass, FalseClass
273:         @value = value ? checked_value : unchecked_value
274:       when checked_value, unchecked_value
275:         super
276:       else
277:         raise "Checkbox value must be one of #{[checked_value, unchecked_value].inspect}."
278:       end
279:     end

[Validate]