Renaming clicks_button to click_button
This commit is contained in:
parent
c9494968cc
commit
f1bf1013c9
2
TODO.txt
2
TODO.txt
@ -2,6 +2,6 @@ Fix #within scoping for forms that exist outside the scope
|
|||||||
Figure out what the deal is with #select not working
|
Figure out what the deal is with #select not working
|
||||||
Restore SSL support for Rails (See 73d3b72108254c0f1ad00e63f8e712115cc8ca7c)
|
Restore SSL support for Rails (See 73d3b72108254c0f1ad00e63f8e712115cc8ca7c)
|
||||||
Full support for multiple forms on a page
|
Full support for multiple forms on a page
|
||||||
Track the current form based on the location of the last manipulated input, use this as a default for clicks_button
|
Track the current form based on the location of the last manipulated input, use this as a default for click_button
|
||||||
Make current_url work with redirections
|
Make current_url work with redirections
|
||||||
Support for a hash mapping page names to page URLs
|
Support for a hash mapping page names to page URLs
|
@ -127,16 +127,16 @@ module Webrat
|
|||||||
# any redirects, and verifies the final page was successful.
|
# any redirects, and verifies the final page was successful.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# clicks_button "Login"
|
# click_button "Login"
|
||||||
# clicks_button
|
# click_button
|
||||||
#
|
#
|
||||||
# The URL and HTTP method for the form submission are automatically read from the
|
# The URL and HTTP method for the form submission are automatically read from the
|
||||||
# <tt>action</tt> and <tt>method</tt> attributes of the <tt><form></tt> element.
|
# <tt>action</tt> and <tt>method</tt> attributes of the <tt><form></tt> element.
|
||||||
def clicks_button(value = nil)
|
def click_button(value = nil)
|
||||||
find_button(value).click
|
find_button(value).click
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :click_button, :clicks_button
|
alias_method :clicks_button, :click_button
|
||||||
|
|
||||||
def dom # :nodoc:
|
def dom # :nodoc:
|
||||||
@dom ||= Hpricot(scoped_html)
|
@dom ||= Hpricot(scoped_html)
|
||||||
|
@ -18,6 +18,6 @@ describe "Basic Auth HTTP headers" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/form1", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"})
|
@session.should_receive(:post).with("/form1", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -35,7 +35,7 @@ describe "check" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
|
@session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
|
||||||
@session.check "TOS"
|
@session.check "TOS"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should result in the value on being posted if not specified" do
|
it "should result in the value on being posted if not specified" do
|
||||||
@ -47,7 +47,7 @@ describe "check" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "remember_me" => "on")
|
@session.should_receive(:post).with("/login", "remember_me" => "on")
|
||||||
@session.check "remember_me"
|
@session.check "remember_me"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fail if the checkbox is disabled" do
|
it "should fail if the checkbox is disabled" do
|
||||||
@ -69,7 +69,7 @@ describe "check" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "remember_me" => "yes")
|
@session.should_receive(:post).with("/login", "remember_me" => "yes")
|
||||||
@session.check "remember_me"
|
@session.check "remember_me"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ describe "uncheck" do
|
|||||||
@session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
|
@session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
|
||||||
@session.check "TOS"
|
@session.check "TOS"
|
||||||
@session.uncheck "TOS"
|
@session.uncheck "TOS"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should result in value not being posted" do
|
it "should result in value not being posted" do
|
||||||
@ -131,6 +131,6 @@ describe "uncheck" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", {})
|
@session.should_receive(:post).with("/login", {})
|
||||||
@session.uncheck "remember_me"
|
@session.uncheck "remember_me"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -36,7 +36,7 @@ describe "choose" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"gender" => "M"})
|
@session.should_receive(:get).with("/login", "user" => {"gender" => "M"})
|
||||||
@session.choose "Male"
|
@session.choose "Male"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should only submit last chosen value" do
|
it "should only submit last chosen value" do
|
||||||
@ -52,7 +52,7 @@ describe "choose" do
|
|||||||
@session.should_receive(:get).with("/login", "user" => {"gender" => "M"})
|
@session.should_receive(:get).with("/login", "user" => {"gender" => "M"})
|
||||||
@session.choose "Female"
|
@session.choose "Female"
|
||||||
@session.choose "Male"
|
@session.choose "Male"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fail if the radio button is disabled" do
|
it "should fail if the radio button is disabled" do
|
||||||
@ -75,7 +75,7 @@ describe "choose" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "first_option" => "on")
|
@session.should_receive(:post).with("/login", "first_option" => "on")
|
||||||
@session.choose "first_option"
|
@session.choose "first_option"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should result in the value on being posted if not specified and checked by default" do
|
it "should result in the value on being posted if not specified and checked by default" do
|
||||||
@ -86,7 +86,7 @@ describe "choose" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "first_option" => "on")
|
@session.should_receive(:post).with("/login", "first_option" => "on")
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should result in the value of the selected radio button being posted when a subsequent one is checked by default" do
|
it "should result in the value of the selected radio button being posted when a subsequent one is checked by default" do
|
||||||
@ -101,6 +101,6 @@ describe "choose" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "user" => {"gender" => "M"})
|
@session.should_receive(:post).with("/login", "user" => {"gender" => "M"})
|
||||||
@session.choose "Male"
|
@session.choose "Male"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
||||||
|
|
||||||
describe "clicks_button" do
|
describe "click_button" do
|
||||||
before do
|
before do
|
||||||
@session = Webrat::TestSession.new
|
@session = Webrat::TestSession.new
|
||||||
end
|
end
|
||||||
@ -10,7 +10,7 @@ describe "clicks_button" do
|
|||||||
<form method="get" action="/login"></form>
|
<form method="get" action="/login"></form>
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
lambda { @session.clicks_button }.should raise_error
|
lambda { @session.click_button }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fail if input is not a submit button" do
|
it "should fail if input is not a submit button" do
|
||||||
@ -20,7 +20,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
lambda { @session.clicks_button }.should raise_error
|
lambda { @session.click_button }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
lambda { @session.clicks_button }.should raise_error
|
lambda { @session.click_button }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should default to get method" do
|
it "should default to get method" do
|
||||||
@ -41,7 +41,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get)
|
@session.should_receive(:get)
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should assert valid response" do
|
it "should assert valid response" do
|
||||||
@ -51,7 +51,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.response_code = 501
|
@session.response_code = 501
|
||||||
lambda { @session.clicks_button }.should raise_error
|
lambda { @session.click_button }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
[200, 300, 400, 499].each do |status|
|
[200, 300, 400, 499].each do |status|
|
||||||
@ -62,7 +62,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.response_code = status
|
@session.response_code = status
|
||||||
lambda { @session.clicks_button }.should_not raise_error
|
lambda { @session.click_button }.should_not raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/form1", {})
|
@session.should_receive(:get).with("/form1", {})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not explode on file fields" do
|
it "should not explode on file fields" do
|
||||||
@ -86,7 +86,7 @@ describe "clicks_button" do
|
|||||||
<input type="submit" />
|
<input type="submit" />
|
||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should submit the form with the specified button" do
|
it "should submit the form with the specified button" do
|
||||||
@ -99,7 +99,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/form2", {})
|
@session.should_receive(:get).with("/form2", {})
|
||||||
@session.clicks_button "Form2"
|
@session.click_button "Form2"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use action from form" do
|
it "should use action from form" do
|
||||||
@ -109,7 +109,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", {})
|
@session.should_receive(:get).with("/login", {})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use method from form" do
|
it "should use method from form" do
|
||||||
@ -119,7 +119,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post)
|
@session.should_receive(:post)
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send button as param if it has a name" do
|
it "should send button as param if it has a name" do
|
||||||
@ -130,7 +130,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "login" => "Login")
|
@session.should_receive(:post).with("/login", "login" => "Login")
|
||||||
@session.clicks_button("Login")
|
@session.click_button("Login")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not send button as param if it has no name" do
|
it "should not send button as param if it has no name" do
|
||||||
@ -141,7 +141,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", {})
|
@session.should_receive(:post).with("/login", {})
|
||||||
@session.clicks_button("Login")
|
@session.click_button("Login")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send default password field values" do
|
it "should send default password field values" do
|
||||||
@ -152,7 +152,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"password" => "mypass"})
|
@session.should_receive(:get).with("/login", "user" => {"password" => "mypass"})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send default hidden field values" do
|
it "should send default hidden field values" do
|
||||||
@ -163,7 +163,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
|
@session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send default text field values" do
|
it "should send default text field values" do
|
||||||
@ -174,7 +174,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
|
@session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not send disabled field values" do
|
it "should not send disabled field values" do
|
||||||
@ -189,7 +189,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", {})
|
@session.should_receive(:get).with("/login", {})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send default checked fields" do
|
it "should send default checked fields" do
|
||||||
@ -200,7 +200,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
|
@session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send default radio options" do
|
it "should send default radio options" do
|
||||||
@ -214,7 +214,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"gender" => "F"})
|
@session.should_receive(:get).with("/login", "user" => {"gender" => "F"})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send correct data for rails style unchecked fields" do
|
it "should send correct data for rails style unchecked fields" do
|
||||||
@ -226,7 +226,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
|
@session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send correct data for rails style checked fields" do
|
it "should send correct data for rails style checked fields" do
|
||||||
@ -238,7 +238,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
|
@session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send default collection fields" do
|
it "should send default collection fields" do
|
||||||
@ -260,7 +260,7 @@ describe "clicks_button" do
|
|||||||
@session.should_receive(:post).with("/login",
|
@session.should_receive(:post).with("/login",
|
||||||
"options" => ["burger", "fries", "soda", "soda", "dessert"],
|
"options" => ["burger", "fries", "soda", "soda", "dessert"],
|
||||||
"response" => { "choices" => [{"selected" => "one"}, {"selected" => "two"}, {"selected" => "two"}]})
|
"response" => { "choices" => [{"selected" => "one"}, {"selected" => "two"}, {"selected" => "two"}]})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not send default unchecked fields" do
|
it "should not send default unchecked fields" do
|
||||||
@ -271,7 +271,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", {})
|
@session.should_receive(:get).with("/login", {})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send default textarea values" do
|
it "should send default textarea values" do
|
||||||
@ -282,7 +282,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/posts", "post" => {"body" => "Post body here!"})
|
@session.should_receive(:post).with("/posts", "post" => {"body" => "Post body here!"})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send default selected option value from select" do
|
it "should send default selected option value from select" do
|
||||||
@ -296,7 +296,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "month" => "2")
|
@session.should_receive(:get).with("/login", "month" => "2")
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send default selected option inner html from select when no value attribute" do
|
it "should send default selected option inner html from select when no value attribute" do
|
||||||
@ -310,7 +310,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "month" => "February")
|
@session.should_receive(:get).with("/login", "month" => "February")
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send first select option value when no option selected" do
|
it "should send first select option value when no option selected" do
|
||||||
@ -324,7 +324,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "month" => "1")
|
@session.should_receive(:get).with("/login", "month" => "1")
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should handle nested properties" do
|
it "should handle nested properties" do
|
||||||
@ -336,7 +336,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "contestant" => {"scores" => {'1' => '2', '3' => '4'}})
|
@session.should_receive(:post).with("/login", "contestant" => {"scores" => {'1' => '2', '3' => '4'}})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send default empty text field values" do
|
it "should send default empty text field values" do
|
||||||
@ -347,7 +347,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"email" => ""})
|
@session.should_receive(:get).with("/login", "user" => {"email" => ""})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should recognize button tags" do
|
it "should recognize button tags" do
|
||||||
@ -358,7 +358,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"email" => ""})
|
@session.should_receive(:get).with("/login", "user" => {"email" => ""})
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should recognize image button tags" do
|
it "should recognize image button tags" do
|
||||||
@ -368,7 +368,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get)
|
@session.should_receive(:get)
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should find buttons by their IDs" do
|
it "should find buttons by their IDs" do
|
||||||
@ -378,7 +378,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get)
|
@session.should_receive(:get)
|
||||||
@session.clicks_button "my_button"
|
@session.click_button "my_button"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should find image buttons by their alt text" do
|
it "should find image buttons by their alt text" do
|
||||||
@ -388,7 +388,7 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get)
|
@session.should_receive(:get)
|
||||||
@session.clicks_button "Go"
|
@session.click_button "Go"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should recognize button tags by content" do
|
it "should recognize button tags by content" do
|
||||||
@ -399,6 +399,6 @@ describe "clicks_button" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:get).with("/login", "user" => {"email" => ""})
|
@session.should_receive(:get).with("/login", "user" => {"email" => ""})
|
||||||
@session.clicks_button "Login"
|
@session.click_button "Login"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,7 @@ describe "fill_in" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "user" => {"text" => "filling text area"})
|
@session.should_receive(:post).with("/login", "user" => {"text" => "filling text area"})
|
||||||
@session.fill_in "User Text", :with => "filling text area"
|
@session.fill_in "User Text", :with => "filling text area"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should work with password fields" do
|
it "should work with password fields" do
|
||||||
@ -27,7 +27,7 @@ describe "fill_in" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "user" => {"text" => "pass"})
|
@session.should_receive(:post).with("/login", "user" => {"text" => "pass"})
|
||||||
@session.fill_in "user_text", :with => "pass"
|
@session.fill_in "user_text", :with => "pass"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fail if input not found" do
|
it "should fail if input not found" do
|
||||||
@ -61,7 +61,7 @@ describe "fill_in" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
|
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
|
||||||
@session.fill_in "user[email]", :with => "foo@example.com"
|
@session.fill_in "user[email]", :with => "foo@example.com"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should choose the shortest label match" do
|
it "should choose the shortest label match" do
|
||||||
@ -77,7 +77,7 @@ describe "fill_in" do
|
|||||||
|
|
||||||
@session.should_receive(:post).with("/login", "user" => {"mail1" => "", "mail2" => "value"})
|
@session.should_receive(:post).with("/login", "user" => {"mail1" => "", "mail2" => "value"})
|
||||||
@session.fill_in "Some", :with => "value"
|
@session.fill_in "Some", :with => "value"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should choose the first label match if closest is a tie" do
|
it "should choose the first label match if closest is a tie" do
|
||||||
@ -93,7 +93,7 @@ describe "fill_in" do
|
|||||||
|
|
||||||
@session.should_receive(:post).with("/login", "user" => {"mail1" => "value", "mail2" => ""})
|
@session.should_receive(:post).with("/login", "user" => {"mail1" => "value", "mail2" => ""})
|
||||||
@session.fill_in "Some mail", :with => "value"
|
@session.fill_in "Some mail", :with => "value"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should anchor label matches to start of label" do
|
it "should anchor label matches to start of label" do
|
||||||
@ -130,7 +130,7 @@ describe "fill_in" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
|
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
|
||||||
@session.fill_in "Email", :with => "foo@example.com"
|
@session.fill_in "Email", :with => "foo@example.com"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should work with full input names" do
|
it "should work with full input names" do
|
||||||
@ -142,7 +142,7 @@ describe "fill_in" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
|
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
|
||||||
@session.fill_in "user[email]", :with => "foo@example.com"
|
@session.fill_in "user[email]", :with => "foo@example.com"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should work if the input type is not set" do
|
it "should work if the input type is not set" do
|
||||||
@ -154,7 +154,7 @@ describe "fill_in" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
|
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
|
||||||
@session.fill_in "user[email]", :with => "foo@example.com"
|
@session.fill_in "user[email]", :with => "foo@example.com"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should work with symbols" do
|
it "should work with symbols" do
|
||||||
@ -167,7 +167,7 @@ describe "fill_in" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
|
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
|
||||||
@session.fill_in :email, :with => "foo@example.com"
|
@session.fill_in :email, :with => "foo@example.com"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should escape field values" do
|
it "should escape field values" do
|
||||||
@ -180,6 +180,6 @@ describe "fill_in" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/users", "user" => {"phone" => "+1 22 33"})
|
@session.should_receive(:post).with("/users", "user" => {"phone" => "+1 22 33"})
|
||||||
@session.fill_in 'Phone', :with => "+1 22 33"
|
@session.fill_in 'Phone', :with => "+1 22 33"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -57,7 +57,7 @@ describe "selects" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "month" => "1")
|
@session.should_receive(:post).with("/login", "month" => "1")
|
||||||
@session.selects "January", :from => "month"
|
@session.selects "January", :from => "month"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send values with HTML encoded ampersands" do
|
it "should send values with HTML encoded ampersands" do
|
||||||
@ -69,7 +69,7 @@ describe "selects" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "encoded" => "A & B")
|
@session.should_receive(:post).with("/login", "encoded" => "A & B")
|
||||||
@session.selects "Encoded", :from => "encoded"
|
@session.selects "Encoded", :from => "encoded"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should work with empty select lists" do
|
it "should work with empty select lists" do
|
||||||
@ -80,7 +80,7 @@ describe "selects" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", 'month' => '')
|
@session.should_receive(:post).with("/login", 'month' => '')
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should work without specifying the field name or label" do
|
it "should work without specifying the field name or label" do
|
||||||
@ -92,7 +92,7 @@ describe "selects" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "month" => "1")
|
@session.should_receive(:post).with("/login", "month" => "1")
|
||||||
@session.selects "January"
|
@session.selects "January"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send value from option in list specified by name" do
|
it "should send value from option in list specified by name" do
|
||||||
@ -105,7 +105,7 @@ describe "selects" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
@session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
||||||
@session.selects "January", :from => "end_month"
|
@session.selects "January", :from => "end_month"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send value from option in list specified by label" do
|
it "should send value from option in list specified by label" do
|
||||||
@ -120,7 +120,7 @@ describe "selects" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
@session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
||||||
@session.selects "January", :from => "End Month"
|
@session.selects "January", :from => "End Month"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use option text if no value" do
|
it "should use option text if no value" do
|
||||||
@ -132,7 +132,7 @@ describe "selects" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "month" => "January")
|
@session.should_receive(:post).with("/login", "month" => "January")
|
||||||
@session.selects "January", :from => "month"
|
@session.selects "January", :from => "month"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should find option by regexp" do
|
it "should find option by regexp" do
|
||||||
@ -144,7 +144,7 @@ describe "selects" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "month" => "January")
|
@session.should_receive(:post).with("/login", "month" => "January")
|
||||||
@session.selects(/jan/i)
|
@session.selects(/jan/i)
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fail if no option matching the regexp exists" do
|
it "should fail if no option matching the regexp exists" do
|
||||||
@ -172,6 +172,6 @@ describe "selects" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
@session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
|
||||||
@session.selects(/jan/i, :from => "End Month")
|
@session.selects(/jan/i, :from => "End Month")
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -34,7 +34,7 @@ describe "within" do
|
|||||||
@session.should_receive(:get).with("/form2", "email" => "test@example.com")
|
@session.should_receive(:get).with("/form2", "email" => "test@example.com")
|
||||||
@session.within "#form2" do |scope|
|
@session.within "#form2" do |scope|
|
||||||
scope.fill_in "Email", :with => "test@example.com"
|
scope.fill_in "Email", :with => "test@example.com"
|
||||||
scope.clicks_button
|
scope.click_button
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ describe "within" do
|
|||||||
|
|
||||||
@session.within "#form2" do |scope|
|
@session.within "#form2" do |scope|
|
||||||
lambda {
|
lambda {
|
||||||
scope.clicks_button
|
scope.click_button
|
||||||
}.should raise_error
|
}.should raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ describe "attaches_file" do
|
|||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/widgets", { "widget" => { "file" => "" } })
|
@session.should_receive(:post).with("/widgets", { "widget" => { "file" => "" } })
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should submit the attached file" do
|
it "should submit the attached file" do
|
||||||
@ -38,7 +38,7 @@ describe "attaches_file" do
|
|||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/widgets", { "widget" => { "file" => @uploaded_file } })
|
@session.should_receive(:post).with("/widgets", { "widget" => { "file" => @uploaded_file } })
|
||||||
@session.attaches_file "Document", @filename
|
@session.attaches_file "Document", @filename
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should support collections" do
|
it "should support collections" do
|
||||||
@ -54,7 +54,7 @@ describe "attaches_file" do
|
|||||||
@session.should_receive(:post).with("/widgets", { "widget" => { "files" => [@uploaded_file, @uploaded_file] } })
|
@session.should_receive(:post).with("/widgets", { "widget" => { "files" => [@uploaded_file, @uploaded_file] } })
|
||||||
@session.attaches_file "Document", @filename
|
@session.attaches_file "Document", @filename
|
||||||
@session.attaches_file "Spreadsheet", @filename
|
@session.attaches_file "Spreadsheet", @filename
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should allow the content type to be specified" do
|
it "should allow the content type to be specified" do
|
||||||
@ -67,6 +67,6 @@ describe "attaches_file" do
|
|||||||
EOS
|
EOS
|
||||||
ActionController::TestUploadedFile.should_receive(:new).with(@filename, "image/png").any_number_of_times
|
ActionController::TestUploadedFile.should_receive(:new).with(@filename, "image/png").any_number_of_times
|
||||||
@session.attaches_file "Picture", @filename, "image/png"
|
@session.attaches_file "Picture", @filename, "image/png"
|
||||||
@session.clicks_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -7,7 +7,7 @@
|
|||||||
# EOS
|
# EOS
|
||||||
# @page.stub!(:url).and_return("/current")
|
# @page.stub!(:url).and_return("/current")
|
||||||
# @session.should_receive(:get).with("/current", {})
|
# @session.should_receive(:get).with("/current", {})
|
||||||
# @session.clicks_button
|
# @session.click_button
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# it "should follow fully qualified secure local links" do
|
# it "should follow fully qualified secure local links" do
|
||||||
|
Loading…
Reference in New Issue
Block a user