fa881a88c8
* Basically Field#to_param was replaced for Field#to_query_string and some methods related to build params were moved to Form class. Before this commit the params hash was made by parsing each element querystring to param and then merge, now we build the whole querystring first and then parse it to get params with Rack or Rails depending of the configure mode.
84 lines
2.2 KiB
Ruby
84 lines
2.2 KiB
Ruby
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
|
|
module Webrat
|
|
describe Field do
|
|
it "should have nice inspect output" do
|
|
html = <<-HTML
|
|
<html>
|
|
<input type='checkbox' checked='checked' />
|
|
</html>
|
|
HTML
|
|
|
|
element = Webrat::XML.document(html).css("input").first
|
|
checkbox = CheckboxField.new(nil, element)
|
|
checkbox.inspect.should =~ /^#<Webrat::CheckboxField @element=/
|
|
end
|
|
end
|
|
|
|
describe CheckboxField do
|
|
it "should say it is checked if it is" do
|
|
html = <<-HTML
|
|
<html>
|
|
<input type='checkbox' checked='checked' />
|
|
</html>
|
|
HTML
|
|
|
|
element = Webrat::XML.document(html).css("input").first
|
|
checkbox = CheckboxField.new(nil, element)
|
|
checkbox.should be_checked
|
|
end
|
|
|
|
it "should say it is not checked if it is not" do
|
|
html = <<-HTML
|
|
<html>
|
|
<input type='checkbox' />
|
|
</html>
|
|
HTML
|
|
|
|
element = Webrat::XML.document(html).css("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
|
|
html = <<-HTML
|
|
<html>
|
|
<input type='radio' checked='checked' />
|
|
</html>
|
|
HTML
|
|
|
|
element = Webrat::XML.document(html).css("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
|
|
html = <<-HTML
|
|
<html><input type='radio' /></html>
|
|
HTML
|
|
|
|
element = Webrat::XML.document(html).css("input").first
|
|
radio_button = RadioField.new(nil, element)
|
|
radio_button.should_not be_checked
|
|
end
|
|
end
|
|
|
|
describe TextField do
|
|
it 'should not escape values in mechanize mode' do
|
|
Webrat.configuration.mode = :mechanize
|
|
|
|
html = <<-HTML
|
|
<html>
|
|
<input type="text" name="email" value="user@example.com" />
|
|
</html>
|
|
HTML
|
|
|
|
element = Webrat::XML.document(html).css('input').first
|
|
text_field = TextField.new(nil, element)
|
|
text_field.to_query_string.should == 'email=user@example.com'
|
|
end
|
|
end
|
|
end
|