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

Methods

Public Instance methods

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]