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 with_html <<-HTML
<html> <html>
<form method="get" action="/login"> <form method="get" action="/login">
<input disabled id="user_email" name="user[email]" value="test@example.com" type="text" /> <input disabled="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_gender_male" name="user[gender]" type="radio" value="M" />
<label for="user_gender_male">Male</label> <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> <label for="user_gender_female">Female</label>
<input type="submit" /> <input type="submit" />
</form> </form>

View File

@ -12,6 +12,8 @@ describe "field_by_xpath" do
</html> </html>
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
end end

View File

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

View File

@ -3,24 +3,50 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
module Webrat module Webrat
describe CheckboxField do describe CheckboxField do
it "should say it is checked if it is" 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 checkbox.should be_checked
end end
it "should say it is not checked if it is not" do 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 checkbox.should_not be_checked
end end
end end
describe RadioField do describe RadioField do
it "should say it is checked if it is" 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 radio_button.should be_checked
end end
it "should say it is not checked if it is not" do 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 radio_button.should_not be_checked
end end
end end

View File

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