2008-10-25 16:22:55 +00:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2008-10-23 04:28:36 +00:00
|
|
|
|
|
|
|
module Webrat
|
2008-12-12 20:43:27 +00:00
|
|
|
describe Field do
|
2009-05-11 04:11:01 +00:00
|
|
|
unless Webrat.on_java?
|
|
|
|
it "should have nice inspect output" do
|
|
|
|
html = <<-HTML
|
|
|
|
<html>
|
|
|
|
<input type='checkbox' checked='checked' />
|
|
|
|
</html>
|
|
|
|
HTML
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2009-05-11 04:11:01 +00:00
|
|
|
element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
|
|
|
|
checkbox = CheckboxField.new(nil, element)
|
|
|
|
checkbox.inspect.should =~ /#<Webrat::CheckboxField @element=<input type=['"]checkbox['"] checked(=['"]checked['"])?\/?>>/
|
|
|
|
end
|
2008-12-12 20:43:27 +00:00
|
|
|
end
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-10-23 04:28:36 +00:00
|
|
|
describe CheckboxField do
|
|
|
|
it "should say it is checked if it is" do
|
2008-11-28 05:55:45 +00:00
|
|
|
html = <<-HTML
|
|
|
|
<html>
|
|
|
|
<input type='checkbox' checked='checked' />
|
|
|
|
</html>
|
|
|
|
HTML
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-28 05:55:45 +00:00
|
|
|
element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
|
|
|
|
checkbox = CheckboxField.new(nil, element)
|
2008-10-23 04:28:36 +00:00
|
|
|
checkbox.should be_checked
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should say it is not checked if it is not" do
|
2008-11-28 05:55:45 +00:00
|
|
|
html = <<-HTML
|
|
|
|
<html>
|
|
|
|
<input type='checkbox' />
|
|
|
|
</html>
|
|
|
|
HTML
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-28 05:55:45 +00:00
|
|
|
element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
|
|
|
|
checkbox = CheckboxField.new(nil, element)
|
2008-10-23 04:28:36 +00:00
|
|
|
checkbox.should_not be_checked
|
|
|
|
end
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-14 06:09:18 +00:00
|
|
|
describe RadioField do
|
|
|
|
it "should say it is checked if it is" do
|
2008-11-28 05:55:45 +00:00
|
|
|
html = <<-HTML
|
|
|
|
<html>
|
|
|
|
<input type='radio' checked='checked' />
|
|
|
|
</html>
|
|
|
|
HTML
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-28 05:55:45 +00:00
|
|
|
element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
|
|
|
|
radio_button = RadioField.new(nil, element)
|
2008-11-14 06:09:18 +00:00
|
|
|
radio_button.should be_checked
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should say it is not checked if it is not" do
|
2008-11-28 05:55:45 +00:00
|
|
|
html = <<-HTML
|
|
|
|
<html><input type='radio' /></html>
|
|
|
|
HTML
|
2009-04-08 00:30:12 +00:00
|
|
|
|
|
|
|
element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
|
2008-11-28 05:55:45 +00:00
|
|
|
radio_button = RadioField.new(nil, element)
|
2008-11-14 06:09:18 +00:00
|
|
|
radio_button.should_not be_checked
|
|
|
|
end
|
|
|
|
end
|
2008-10-23 04:28:36 +00:00
|
|
|
end
|