diff --git a/lib/webrat/core/field.rb b/lib/webrat/core/field.rb
index 42710cc..11799d3 100644
--- a/lib/webrat/core/field.rb
+++ b/lib/webrat/core/field.rb
@@ -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
diff --git a/spec/core/field_spec.rb b/spec/core/field_spec.rb
new file mode 100644
index 0000000..4383179
--- /dev/null
+++ b/spec/core/field_spec.rb
@@ -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').first)
+ checkbox.should be_checked
+ end
+
+ it "should say it is not checked if it is not" do
+ checkbox = CheckboxField.new(nil, (Hpricot("")/'input').first)
+ checkbox.should_not be_checked
+ end
+ end
+end