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-05 23:32:36 +00:00
|
|
|
describe "click_button" do
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should fail if no buttons" 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"></form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
2008-04-07 04:52:49 +00:00
|
|
|
|
2008-11-23 05:22:49 +00:00
|
|
|
lambda { click_button }.should raise_error(Webrat::NotFoundError)
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should fail if input is not a submit button" 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">
|
|
|
|
<input type="reset" />
|
|
|
|
</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 05:22:49 +00:00
|
|
|
lambda { click_button }.should raise_error(Webrat::NotFoundError)
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
2008-10-02 00:22:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
it "should fail if button 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="get" action="/login">
|
|
|
|
<input type="submit" disabled="disabled" />
|
|
|
|
</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 05:22:49 +00:00
|
|
|
lambda { click_button }.should raise_error(Webrat::DisabledFieldError)
|
2008-10-02 00:22:23 +00:00
|
|
|
end
|
2008-03-02 20:14:52 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should default to get method" 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 action="/login">
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get)
|
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should assert valid response" 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 action="/login">
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.response_code = 501
|
|
|
|
lambda { click_button }.should raise_error(Webrat::PageLoadError)
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-10-25 16:30:30 +00:00
|
|
|
[200, 300, 400, 499].each do |status|
|
2008-10-25 21:17:00 +00:00
|
|
|
it "should consider the #{status} status code as success" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-11-23 05:22:49 +00:00
|
|
|
<form action="/login">
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.response_code = status
|
|
|
|
lambda { click_button }.should_not raise_error
|
2008-10-25 16:30:30 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should submit the first form by default" 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="/form1">
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
<form method="get" action="/form2">
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/form1", {})
|
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should not explode on file fields" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-04-13 22:03:56 +00:00
|
|
|
<form method="get" action="/form1">
|
|
|
|
<input type="file" />
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
click_button
|
2008-04-13 22:03:56 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should submit the form with the specified button" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-22 21:46:03 +00:00
|
|
|
<html>
|
|
|
|
<form method="get" action="/form1">
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
<form method="get" action="/form2">
|
|
|
|
<input type="submit" value="Form2" />
|
|
|
|
</form>
|
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/form2", {})
|
|
|
|
click_button "Form2"
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should use action from form" 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">
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", {})
|
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should use method from form" 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">
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:post)
|
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send button as param if it has a 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">
|
|
|
|
<input type="submit" name="cancel" value="Cancel" />
|
|
|
|
<input type="submit" name="login" value="Login" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:post).with("/login", "login" => "Login")
|
|
|
|
click_button("Login")
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should not send button as param if it has no 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">
|
|
|
|
<input type="submit" name="cancel" value="Cancel" />
|
|
|
|
<input type="submit" value="Login" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:post).with("/login", {})
|
|
|
|
click_button("Login")
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
2008-04-04 15:16:54 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send default password field values" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-04-04 15:16:54 +00:00
|
|
|
<form method="get" action="/login">
|
|
|
|
<input id="user_password" name="user[password]" value="mypass" type="password" />
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "user" => {"password" => "mypass"})
|
|
|
|
click_button
|
2008-04-04 15:16:54 +00:00
|
|
|
end
|
2008-03-02 20:14:52 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send default hidden field values" 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">
|
|
|
|
<input id="user_email" name="user[email]" value="test@example.com" type="hidden" />
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
|
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send default text field values" 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">
|
|
|
|
<input id="user_email" name="user[email]" value="test@example.com" type="text" />
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
|
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-09-23 02:19:20 +00:00
|
|
|
it "should not send disabled field values" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-09-23 02:19:20 +00:00
|
|
|
<form method="get" action="/login">
|
2008-11-28 05:55:45 +00:00
|
|
|
<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" />
|
2008-09-23 02:19:20 +00:00
|
|
|
<label for="user_gender_male">Male</label>
|
2008-11-28 05:55:45 +00:00
|
|
|
<input disabled="disabled" id="user_gender_female" name="user[gender]" type="radio" value="F" checked="checked" />
|
2008-09-23 02:19:20 +00:00
|
|
|
<label for="user_gender_female">Female</label>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", {})
|
|
|
|
click_button
|
2008-09-23 02:19:20 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send default checked fields" 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">
|
|
|
|
<input id="user_tos" name="user[tos]" value="1" type="checkbox" checked="checked" />
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
|
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send default radio options" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-03 01:06:43 +00:00
|
|
|
<form method="get" action="/login">
|
|
|
|
<input id="user_gender_male" name="user[gender]" type="radio" value="M" />
|
|
|
|
<label for="user_gender_male">Male</label>
|
|
|
|
<input id="user_gender_female" name="user[gender]" type="radio" value="F" checked="checked" />
|
|
|
|
<label for="user_gender_female">Female</label>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "user" => {"gender" => "F"})
|
|
|
|
click_button
|
2008-03-03 01:06:43 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send correct data for rails style unchecked fields" 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">
|
|
|
|
<input id="user_tos" name="user[tos]" type="checkbox" value="1" />
|
|
|
|
<input name="user[tos]" type="hidden" value="0" /> TOS
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
|
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send correct data for rails style checked fields" 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">
|
|
|
|
<input id="user_tos" name="user[tos]" type="checkbox" value="1" checked="checked" />
|
|
|
|
<input name="user[tos]" type="hidden" value="0" /> TOS
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
|
|
|
|
click_button
|
2008-03-19 08:25:29 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send default collection fields" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-19 08:25:29 +00:00
|
|
|
<form method="post" action="/login">
|
|
|
|
<input type="checkbox" name="options[]" value="burger" checked="checked" />
|
|
|
|
<input type="radio" name="options[]" value="fries" checked="checked" />
|
|
|
|
<input type="text" name="options[]" value="soda" />
|
2008-03-19 13:36:21 +00:00
|
|
|
<!-- Same value appearing twice -->
|
|
|
|
<input type="text" name="options[]" value="soda" />
|
2008-03-19 08:25:29 +00:00
|
|
|
<input type="hidden" name="options[]" value="dessert" />
|
2008-03-19 13:36:21 +00:00
|
|
|
<input type="hidden" name="response[choices][][selected]" value="one" />
|
|
|
|
<input type="hidden" name="response[choices][][selected]" value="two" />
|
|
|
|
<!-- Same value appearing twice -->
|
|
|
|
<input type="hidden" name="response[choices][][selected]" value="two" />
|
2008-03-19 08:25:29 +00:00
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:post).with("/login",
|
2008-04-07 04:52:49 +00:00
|
|
|
"options" => ["burger", "fries", "soda", "soda", "dessert"],
|
2008-03-19 13:36:21 +00:00
|
|
|
"response" => { "choices" => [{"selected" => "one"}, {"selected" => "two"}, {"selected" => "two"}]})
|
2008-11-23 05:22:49 +00:00
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should not send default unchecked fields" 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">
|
|
|
|
<input id="user_tos" name="user[tos]" value="1" type="checkbox" />
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", {})
|
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send default textarea values" 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="/posts">
|
|
|
|
<textarea name="post[body]">Post body here!</textarea>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:post).with("/posts", "post" => {"body" => "Post body here!"})
|
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
|
|
|
|
2008-11-29 05:21:49 +00:00
|
|
|
it "should properly handle HTML entities in textarea default values" do
|
2008-12-27 23:22:51 +00:00
|
|
|
spec = lambda do
|
2008-11-29 05:21:49 +00:00
|
|
|
with_html <<-HTML
|
|
|
|
<html>
|
|
|
|
<form method="post" action="/posts">
|
|
|
|
<textarea name="post[body]">Peanut butter & jelly</textarea>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
|
|
|
</html>
|
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:post).with("/posts", "post" => {"body" => "Peanut butter & jelly"})
|
|
|
|
click_button
|
|
|
|
end
|
2008-12-27 23:22:51 +00:00
|
|
|
|
|
|
|
if Webrat.on_java?
|
|
|
|
spec.call
|
|
|
|
else
|
|
|
|
pending("needs bug fix", &spec)
|
|
|
|
end
|
2008-11-29 05:21:49 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send default selected option value from select" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-12 06:04:41 +00:00
|
|
|
<form method="get" action="/login">
|
|
|
|
<select name="month">
|
|
|
|
<option value="1">January</option>
|
|
|
|
<option value="2" selected="selected">February</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "month" => "2")
|
|
|
|
click_button
|
2008-03-12 06:04:41 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send default selected option inner html from select when no value attribute" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-12 06:04:41 +00:00
|
|
|
<form method="get" action="/login">
|
|
|
|
<select name="month">
|
|
|
|
<option>January</option>
|
|
|
|
<option selected="selected">February</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "month" => "February")
|
|
|
|
click_button
|
2008-03-12 06:04:41 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send first select option value when no option selected" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-12 06:04:41 +00:00
|
|
|
<form method="get" action="/login">
|
|
|
|
<select name="month">
|
|
|
|
<option value="1">January</option>
|
|
|
|
<option value="2">February</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "month" => "1")
|
|
|
|
click_button
|
2008-03-12 06:04:41 +00:00
|
|
|
end
|
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should handle nested properties" 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">
|
|
|
|
<input type="text" id="contestant_scores_12" name="contestant[scores][1]" value="2"/>
|
|
|
|
<input type="text" id="contestant_scores_13" name="contestant[scores][3]" value="4"/>
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:post).with("/login", "contestant" => {"scores" => {'1' => '2', '3' => '4'}})
|
|
|
|
click_button
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|
2008-03-04 09:59:40 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should send default empty text field values" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-03-04 09:59:40 +00:00
|
|
|
<form method="get" action="/login">
|
|
|
|
<input id="user_email" name="user[email]" value="" type="text" />
|
|
|
|
<input type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "user" => {"email" => ""})
|
|
|
|
click_button
|
2008-03-04 09:59:40 +00:00
|
|
|
end
|
2008-04-17 16:31:40 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should recognize button tags" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-04-17 16:31:40 +00:00
|
|
|
<form method="get" action="/login">
|
|
|
|
<input id="user_email" name="user[email]" value="" type="text" />
|
|
|
|
<button type="submit" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "user" => {"email" => ""})
|
|
|
|
click_button
|
2008-04-17 16:31:40 +00:00
|
|
|
end
|
|
|
|
|
2008-05-17 18:53:29 +00:00
|
|
|
it "should recognize image button tags" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-05-17 18:53:29 +00:00
|
|
|
<form action="/">
|
|
|
|
<input type="image" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get)
|
|
|
|
click_button
|
2008-05-17 18:53:29 +00:00
|
|
|
end
|
2008-07-25 22:48:53 +00:00
|
|
|
|
2008-10-14 00:50:03 +00:00
|
|
|
it "should find buttons by their IDs" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-10-14 00:50:03 +00:00
|
|
|
<form action="/">
|
|
|
|
<input type="submit" id="my_button" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get)
|
|
|
|
click_button "my_button"
|
2008-10-14 00:50:03 +00:00
|
|
|
end
|
|
|
|
|
2008-07-25 22:48:53 +00:00
|
|
|
it "should find image buttons by their alt text" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-07-25 22:48:53 +00:00
|
|
|
<form action="/">
|
|
|
|
<input type="image" alt="Go" />
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get)
|
|
|
|
click_button "Go"
|
2008-07-25 22:48:53 +00:00
|
|
|
end
|
2008-05-17 18:53:29 +00:00
|
|
|
|
2008-04-27 16:45:01 +00:00
|
|
|
it "should recognize button tags by content" do
|
2008-11-23 05:22:49 +00:00
|
|
|
with_html <<-HTML
|
2008-11-28 05:34:35 +00:00
|
|
|
<html>
|
2008-04-17 16:31:40 +00:00
|
|
|
<form method="get" action="/login">
|
|
|
|
<input id="user_email" name="user[email]" value="" type="text" />
|
|
|
|
<button type="submit">Login</button>
|
|
|
|
</form>
|
2008-11-28 05:34:35 +00:00
|
|
|
</html>
|
2008-11-23 05:22:49 +00:00
|
|
|
HTML
|
|
|
|
webrat_session.should_receive(:get).with("/login", "user" => {"email" => ""})
|
|
|
|
click_button "Login"
|
2008-04-17 16:31:40 +00:00
|
|
|
end
|
2008-03-02 20:14:52 +00:00
|
|
|
end
|