Cleaning up some more specs

This commit is contained in:
Bryan Helmkamp 2008-11-28 00:55:45 -05:00
parent 31aa659a67
commit 18e65bfa44
5 changed files with 37 additions and 11 deletions

View File

@ -209,10 +209,10 @@ describe "click_button" do
with_html <<-HTML
<html>
<form method="get" action="/login">
<input disabled id="user_email" name="user[email]" value="test@example.com" type="text" />
<input disabled id="user_gender_male" name="user[gender]" type="radio" value="M" />
<input disabled="disabled" id="user_email" name="user[email]" value="test@example.com" type="text" />
<input disabled="disabled" id="user_gender_male" name="user[gender]" type="radio" value="M" />
<label for="user_gender_male">Male</label>
<input disabled id="user_gender_female" name="user[gender]" type="radio" value="F" checked="checked" />
<input disabled="disabled" id="user_gender_female" name="user[gender]" type="radio" value="F" checked="checked" />
<label for="user_gender_female">Female</label>
<input type="submit" />
</form>

View File

@ -12,6 +12,8 @@ describe "field_by_xpath" do
</html>
HTML
field_by_xpath(".//input").id.should == "element_42"
field = field_by_xpath(".//input")
field.should_not be_nil
field.id.should == "element_42"
end
end

View File

@ -6,7 +6,6 @@ describe Webrat::Matchers do
before(:each) do
@body = <<-HTML
<html>
<div id='main'>
<div class='inner'>hello, world!</div>
<ul>
@ -14,7 +13,6 @@ describe Webrat::Matchers do
<li>Second</li>
</ul>
</div>
</html>
HTML
end

View File

@ -3,24 +3,50 @@ 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, (Webrat::XML.document("<input type='checkbox' checked='checked' />").search('input')).first)
html = <<-HTML
<html>
<input type='checkbox' checked='checked' />
</html>
HTML
element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
checkbox = CheckboxField.new(nil, element)
checkbox.should be_checked
end
it "should say it is not checked if it is not" do
checkbox = CheckboxField.new(nil, (Webrat::XML.document("<input type='checkbox' />").search('input')).first)
html = <<-HTML
<html>
<input type='checkbox' />
</html>
HTML
element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
checkbox = CheckboxField.new(nil, element)
checkbox.should_not be_checked
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)
html = <<-HTML
<html>
<input type='radio' checked='checked' />
</html>
HTML
element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
radio_button = RadioField.new(nil, element)
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)
html = <<-HTML
<html><input type='radio' /></html>
HTML
element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
radio_button = RadioField.new(nil, element)
radio_button.should_not be_checked
end
end

View File

@ -18,7 +18,7 @@ describe Webrat::Session do
"<html></html>"
end
session.current_dom.should respond_to(:search)
session.should respond_to(:current_dom)
end
it "should open the page in the browser in MacOSX" do