Added RadioField#checked? to indicated whether or not a radio button is checked.

This commit is contained in:
Luke Melia 2008-11-14 01:09:18 -05:00
parent f29cb53239
commit 82b1553719
2 changed files with 16 additions and 0 deletions

View File

@ -241,6 +241,10 @@ module Webrat
set(@element["value"] || "on") set(@element["value"] || "on")
end end
def checked?
@element["checked"] == "checked"
end
protected protected
def other_options def other_options

View File

@ -12,4 +12,16 @@ module Webrat
checkbox.should_not be_checked checkbox.should_not be_checked
end end
end end
describe RadioField do
it "should say it is checked if it is" do
radio_button = RadioField.new(nil, (Webrat::XML.document("<input type='radio' checked='checked'>").search('input')).first)
radio_button.should be_checked
end
it "should say it is not checked if it is not" do
radio_button = RadioField.new(nil, (Webrat::XML.document("<input type='radio'>").search('input')).first)
radio_button.should_not be_checked
end
end
end end