Skip to content

Commit

Permalink
radio button and check box now wrap a node
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Feb 7, 2010
1 parent 3587836 commit f717afc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
Expand Up @@ -35,7 +35,7 @@ Also, check out the EXAMPLES file.

Copyright (c) 2005 by Michael Neumann (mneumann@ntecs.de)

Copyright (c) 2006-2009:
Copyright (c) 2006-2010:

* {Aaron Patterson}[http://tenderlovemaking.com] (aaronp@rubyforge.org)
* {Mike Dalessio}[http://mike.daless.io] (mike@csa.net)
Expand Down
4 changes: 2 additions & 2 deletions lib/mechanize/form.rb
Expand Up @@ -277,9 +277,9 @@ def parse
next if name.nil? && !(type == 'submit' || type =='button')
case type
when 'radio'
@radiobuttons << RadioButton.new(node['name'], node['value'], !!node['checked'], self, node)
@radiobuttons << RadioButton.new(node, self)
when 'checkbox'
@checkboxes << CheckBox.new(node['name'], node['value'], !!node['checked'], self, node)
@checkboxes << CheckBox.new(node, self)
when 'file'
@file_uploads << FileUpload.new(node['name'], nil)
when 'submit'
Expand Down
6 changes: 3 additions & 3 deletions lib/mechanize/form/radio_button.rb
Expand Up @@ -5,11 +5,11 @@ class Form
class RadioButton < Field
attr_accessor :checked

def initialize(name, value, checked, form, node)
@checked = checked
def initialize node, form
@checked = !!node['checked']
@form = form
@node = node
super(name, value)
super(node['name'], node['value'])
end

def check
Expand Down
6 changes: 5 additions & 1 deletion test/test_html_unscape_forms.rb
Expand Up @@ -32,7 +32,11 @@ def test_image_button
end

def test_radio_button
f = Mechanize::Form::RadioButton.new('a&amp;b', 'a&amp;b', nil, nil, nil)
fake_node = {
'name' => 'a&amp;b',
'value' => 'a&amp;b'
}
f = Mechanize::Form::RadioButton.new(fake_node, nil)
assert_equal('a&b', f.name)
assert_equal('a&b', f.value)
end
Expand Down

0 comments on commit f717afc

Please sign in to comment.