added checked? to CheckboxField
This commit is contained in:
parent
070f36ce51
commit
1ba0f58dfa
@ -207,6 +207,10 @@ module Webrat
|
||||
raise_error_if_disabled
|
||||
set(@element["value"] || "on")
|
||||
end
|
||||
|
||||
def checked?
|
||||
@element["checked"] == "checked"
|
||||
end
|
||||
|
||||
def uncheck
|
||||
raise_error_if_disabled
|
||||
|
15
spec/core/field_spec.rb
Normal file
15
spec/core/field_spec.rb
Normal file
@ -0,0 +1,15 @@
|
||||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
||||
|
||||
module Webrat
|
||||
describe CheckboxField do
|
||||
it "should say it is checked if it is" do
|
||||
checkbox = CheckboxField.new(nil, (Hpricot("<input type='checkbox' checked='checked'>")/'input').first)
|
||||
checkbox.should be_checked
|
||||
end
|
||||
|
||||
it "should say it is not checked if it is not" do
|
||||
checkbox = CheckboxField.new(nil, (Hpricot("<input type='checkbox'>")/'input').first)
|
||||
checkbox.should_not be_checked
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user