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

Methods

Public Instance methods

[Source]

     # File lib/form_test_helper.rb, line 320
320:     def check
321:       self.value = checked_value
322:     end

[Source]

     # File lib/form_test_helper.rb, line 299
299:     def checked_value
300:       @checkbox_tag = tags.detect {|field_tag| field_tag['type'] == 'checkbox' }
301:       @checkbox_tag['value']
302:     end

[Source]

     # File lib/form_test_helper.rb, line 295
295:     def initial_value
296:       tag['checked'] ? checked_value : unchecked_value
297:     end

[Source]

     # File lib/form_test_helper.rb, line 324
324:     def uncheck
325:       self.value = unchecked_value
326:     end

[Source]

     # File lib/form_test_helper.rb, line 304
304:     def unchecked_value
305:       @hidden_tag = tags.detect {|field_tag| field_tag['type'] == 'hidden' }
306:       @hidden_tag ? @hidden_tag['value'] : nil
307:     end

[Source]

     # File lib/form_test_helper.rb, line 309
309:     def value=(value)
310:       case value
311:       when TrueClass, FalseClass
312:         @value = value ? checked_value : unchecked_value
313:       when checked_value, unchecked_value
314:         super
315:       else
316:         raise "Checkbox value must be one of #{[checked_value, unchecked_value].inspect}."
317:       end
318:     end

[Validate]