2008-05-12 03:58:20 +00:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2008-03-02 20:14:52 +00:00
|
|
|
|
2008-11-23 19:02:51 +00:00
|
|
|
describe "select" do
|
2008-11-15 21:56:24 +00:00
|
|
|
it "should fail with a helpful message when option not found" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-02 20:14:52 +00:00
|
|
|
<form method="get" action="/login">
|
|
|
|
<select name="month"><option value="1">January</option></select>
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-23 19:02:51 +00:00
|
|
|
lambda { select "February", :from => "month" }.should raise_error(Webrat::NotFoundError,
|
2009-04-08 00:30:12 +00:00
|
|
|
"The 'February' option was not found in the \"month\" select box")
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should fail if option not found in list specified by element name" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-02 20:14:52 +00:00
|
|
|
<form method="get" action="/login">
|
|
|
|
<select name="month"><option value="1">January</option></select>
|
|
|
|
<select name="year"><option value="2008">2008</option></select>
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2008-04-23 14:54:07 +00:00
|
|
|
|
2008-11-23 19:02:51 +00:00
|
|
|
lambda { select "February", :from => "year" }.should raise_error(Webrat::NotFoundError)
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should fail if specified list not found" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-02 20:14:52 +00:00
|
|
|
<form method="get" action="/login">
|
|
|
|
<select name="month"><option value="1">January</option></select>
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2008-04-23 14:54:07 +00:00
|
|
|
|
2008-11-23 19:08:34 +00:00
|
|
|
lambda { select "February", :from => "year" }.should raise_error(Webrat::NotFoundError)
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
2008-10-02 00:22:23 +00:00
|
|
|
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-10-02 00:22:23 +00:00
|
|
|
it "should fail if the select is disabled" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-10-02 00:22:23 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month" disabled="disabled"><option value="1">January</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2008-10-02 00:22:23 +00:00
|
|
|
|
2008-11-23 19:08:34 +00:00
|
|
|
lambda { select "January", :from => "month" }.should raise_error(Webrat::DisabledFieldError)
|
2008-10-02 00:22:23 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send value from option" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-02 20:14:52 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month"><option value="1">January</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2009-05-11 20:48:28 +00:00
|
|
|
webrat_session.should_receive(:post).with("/login", "month" => "1")
|
2008-11-23 19:02:51 +00:00
|
|
|
select "January", :from => "month"
|
2008-11-23 05:22:49 +00:00
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
2008-04-13 23:02:35 +00:00
|
|
|
|
2008-05-17 00:22:41 +00:00
|
|
|
it "should send values with HTML encoded ampersands" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-05-17 00:22:41 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="encoded"><option value="A & B">Encoded</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2009-05-11 20:48:28 +00:00
|
|
|
webrat_session.should_receive(:post).with("/login", "encoded" => "A & B")
|
2008-11-23 19:02:51 +00:00
|
|
|
select "Encoded", :from => "encoded"
|
2008-11-23 05:22:49 +00:00
|
|
|
click_button
|
2008-05-17 00:22:41 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should work with empty select lists" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-04-13 23:02:35 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month"></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2009-05-11 20:48:28 +00:00
|
|
|
webrat_session.should_receive(:post).with("/login", 'month' => '')
|
2008-11-23 05:22:49 +00:00
|
|
|
click_button
|
2008-04-13 23:02:35 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should work without specifying the field name or label" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-04-08 02:26:24 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month"><option value="1">January</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2009-05-11 20:48:28 +00:00
|
|
|
webrat_session.should_receive(:post).with("/login", "month" => "1")
|
2008-11-23 19:02:51 +00:00
|
|
|
select "January"
|
2008-11-23 05:22:49 +00:00
|
|
|
click_button
|
2008-04-08 02:26:24 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send value from option in list specified by name" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-02 20:14:52 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="start_month"><option value="s1">January</option></select>
|
|
|
|
<select name="end_month"><option value="e1">January</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2009-05-11 20:48:28 +00:00
|
|
|
webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
2008-11-23 19:02:51 +00:00
|
|
|
select "January", :from => "end_month"
|
2008-11-23 05:22:49 +00:00
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send value from option in list specified by label" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-02 20:14:52 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<label for="start_month">Start Month</label>
|
|
|
|
<select id="start_month" name="start_month"><option value="s1">January</option></select>
|
|
|
|
<label for="end_month">End Month</label>
|
|
|
|
<select id="end_month" name="end_month"><option value="e1">January</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2009-05-11 20:48:28 +00:00
|
|
|
webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
2008-11-23 19:02:51 +00:00
|
|
|
select "January", :from => "End Month"
|
2008-11-23 05:22:49 +00:00
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should use option text if no value" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-02 20:14:52 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month"><option>January</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2009-05-11 20:48:28 +00:00
|
|
|
webrat_session.should_receive(:post).with("/login", "month" => "January")
|
2008-11-23 19:02:51 +00:00
|
|
|
select "January", :from => "month"
|
2008-11-23 05:22:49 +00:00
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
2008-04-12 21:22:20 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should find option by regexp" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-04-12 21:22:20 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month"><option>January</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2009-05-11 20:48:28 +00:00
|
|
|
webrat_session.should_receive(:post).with("/login", "month" => "January")
|
2008-11-23 19:02:51 +00:00
|
|
|
select /jan/i
|
2008-11-23 05:22:49 +00:00
|
|
|
click_button
|
2008-04-12 21:22:20 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2009-09-07 16:53:06 +00:00
|
|
|
it "should find options by regexp with HTML entities" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month"><option>Peanut butter & jelly</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly")
|
|
|
|
select /Peanut butter & jelly/
|
|
|
|
click_button
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not find options by regexp with HTML entities in the regexp" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month"><option>Peanut butter & jelly</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
lambda {
|
|
|
|
select /Peanut butter & jelly/
|
|
|
|
}.should raise_error(Webrat::NotFoundError)
|
|
|
|
end
|
|
|
|
|
2008-08-11 04:29:21 +00:00
|
|
|
it "should fail if no option matching the regexp exists" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-08-11 04:29:21 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month"><option>January</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-08-11 04:29:21 +00:00
|
|
|
lambda {
|
2008-11-23 19:02:51 +00:00
|
|
|
select /feb/i
|
|
|
|
}.should raise_error(Webrat::NotFoundError)
|
2008-08-11 04:29:21 +00:00
|
|
|
end
|
2008-04-12 21:22:20 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should find option by regexp in list specified by label" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-04-12 21:22:20 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<label for="start_month">Start Month</label>
|
|
|
|
<select id="start_month" name="start_month"><option value="s1">January</option></select>
|
|
|
|
<label for="end_month">End Month</label>
|
|
|
|
<select id="end_month" name="end_month"><option value="e1">January</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2009-05-11 20:48:28 +00:00
|
|
|
webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
2008-11-23 19:02:51 +00:00
|
|
|
select /jan/i, :from => "End Month"
|
2008-11-23 05:22:49 +00:00
|
|
|
click_button
|
2008-04-12 21:22:20 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-30 05:19:16 +00:00
|
|
|
it "should properly handle submitting HTML entities in select values" do
|
2009-09-07 16:53:06 +00:00
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month"><option>Peanut butter & jelly</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly")
|
|
|
|
click_button
|
2008-11-30 05:19:16 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-30 05:19:16 +00:00
|
|
|
it "should properly handle locating with HTML entities in select values" do
|
2009-09-07 16:53:06 +00:00
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month"><option>Peanut butter & jelly</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly")
|
|
|
|
select "Peanut butter & jelly"
|
|
|
|
click_button
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not locate based on HTML entities" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="month"><option>Peanut butter & jelly</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
lambda {
|
|
|
|
select "Peanut butter & jelly"
|
|
|
|
}.should raise_error(Webrat::NotFoundError)
|
2008-11-30 05:19:16 +00:00
|
|
|
end
|
2009-05-11 05:27:04 +00:00
|
|
|
|
2009-04-11 17:18:09 +00:00
|
|
|
it "should submit duplicates selected options as a single value" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="clothes"><option value="pants" selected="selected">pants</option><option value="pants" selected="selected">pants</option></select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
2009-05-11 05:27:04 +00:00
|
|
|
|
2009-05-11 20:51:42 +00:00
|
|
|
webrat_session.should_receive(:post).with("/login", "clothes" => "pants")
|
2009-04-11 17:18:09 +00:00
|
|
|
click_button
|
|
|
|
end
|
2009-05-11 05:27:04 +00:00
|
|
|
|
2009-08-31 06:34:04 +00:00
|
|
|
it "should allow fields to be unselected" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="clothes">
|
|
|
|
<option value="tshirt" selected="selected">tshirt</option>
|
|
|
|
<option value="pants">pants</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
webrat_session.should_receive(:post).with("/login", {"clothes"=>""})
|
|
|
|
unselect "tshirt"
|
|
|
|
click_button
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Mutliple Selection Fields
|
|
|
|
#
|
|
|
|
|
|
|
|
it "should not submit any values for multiples without any selected" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="clothes[]" multiple="multiple">
|
|
|
|
<option value="tshirt">tshirt</option>
|
|
|
|
<option value="pants">pants</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
webrat_session.should_receive(:post).with("/login", {})
|
|
|
|
click_button
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should submit with preselected values" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="clothes[]" multiple="multiple">
|
|
|
|
<option value="tshirt" selected="selected">tshirt</option>
|
|
|
|
<option value="pants" selected="selected">pants</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
webrat_session.should_receive(:post).with("/login", "clothes" => ['tshirt', 'pants'])
|
|
|
|
click_button
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should allow selection of multiple fields" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="clothes[]" multiple="multiple">
|
|
|
|
<option value="tshirt">tshirt</option>
|
|
|
|
<option value="pants">pants</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
webrat_session.should_receive(:post).with("/login", "clothes" => ['pants'])
|
|
|
|
select 'pants'
|
|
|
|
click_button
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not overwrite preselected multiples" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="clothes[]" multiple="multiple">
|
|
|
|
<option value="tshirt" selected="selected">tshirt</option>
|
|
|
|
<option value="pants">pants</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
webrat_session.should_receive(:post).with("/login", "clothes" => ['tshirt', 'pants'])
|
|
|
|
select 'pants'
|
|
|
|
click_button
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should allow fields that exist to be selected or throw errors" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="clothes[]" multiple="multiple">
|
|
|
|
<option value="top" selected="selected">shirt</option>
|
|
|
|
<option value="pants">trousers</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
lambda { select "shirt" }.should_not raise_error(Webrat::NotFoundError)
|
|
|
|
lambda { select "trousers" }.should_not raise_error(Webrat::NotFoundError)
|
|
|
|
lambda { select "shoes" }.should raise_error(Webrat::NotFoundError)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should allow selected fields to be unselected" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="clothes[]" multiple="multiple">
|
|
|
|
<option value="tshirt" selected="selected">tshirt</option>
|
|
|
|
<option value="pants" selected="selected">pants</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
webrat_session.should_receive(:post).with("/login", "clothes" => ['pants'])
|
|
|
|
unselect 'tshirt'
|
|
|
|
click_button
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should be able to select options with special characters" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="clothes[]" multiple="multiple">
|
|
|
|
<option>tshirt & sweater</option>
|
|
|
|
<option>pants & socks</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
webrat_session.should_receive(:post).with("/login", "clothes" => ['pants & socks'])
|
|
|
|
select 'pants & socks'
|
|
|
|
click_button
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should be able to unselect options with special characters" do
|
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/login">
|
|
|
|
<select name="clothes[]" multiple="multiple">
|
|
|
|
<option selected="selected">tshirt & sweater</option>
|
|
|
|
<option selected="selected">pants & socks</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
|
|
|
|
webrat_session.should_receive(:post).with("/login", "clothes" => ['tshirt & sweater'])
|
|
|
|
unselect 'pants & socks'
|
|
|
|
click_button
|
|
|
|
end
|
|
|
|
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|