From f1bf1013c9f870d01d9bb8af02c6f3f364fb1ba8 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Wed, 5 Nov 2008 18:32:36 -0500 Subject: [PATCH] Renaming clicks_button to click_button --- TODO.txt | 2 +- lib/webrat/core/scope.rb | 8 +-- spec/api/basic_auth_spec.rb | 2 +- spec/api/check_spec.rb | 10 ++-- spec/api/choose_spec.rb | 10 ++-- spec/api/click_button_spec.rb | 70 ++++++++++++------------- spec/api/fill_in_spec.rb | 20 +++---- spec/api/selects_spec.rb | 18 +++---- spec/api/within_spec.rb | 4 +- spec/webrat/rails/attaches_file_spec.rb | 8 +-- spec/webrat/rails/rails_spec.rb | 2 +- 11 files changed, 77 insertions(+), 77 deletions(-) diff --git a/TODO.txt b/TODO.txt index 9ed88f5..25e5df3 100644 --- a/TODO.txt +++ b/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 Restore SSL support for Rails (See 73d3b72108254c0f1ad00e63f8e712115cc8ca7c) 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 Support for a hash mapping page names to page URLs \ No newline at end of file diff --git a/lib/webrat/core/scope.rb b/lib/webrat/core/scope.rb index e990df0..483ab6e 100644 --- a/lib/webrat/core/scope.rb +++ b/lib/webrat/core/scope.rb @@ -127,16 +127,16 @@ module Webrat # any redirects, and verifies the final page was successful. # # Example: - # clicks_button "Login" - # clicks_button + # click_button "Login" + # click_button # # The URL and HTTP method for the form submission are automatically read from the # action and method attributes of the
element. - def clicks_button(value = nil) + def click_button(value = nil) find_button(value).click end - alias_method :click_button, :clicks_button + alias_method :clicks_button, :click_button def dom # :nodoc: @dom ||= Hpricot(scoped_html) diff --git a/spec/api/basic_auth_spec.rb b/spec/api/basic_auth_spec.rb index 77a2045..a2fc1e3 100644 --- a/spec/api/basic_auth_spec.rb +++ b/spec/api/basic_auth_spec.rb @@ -18,6 +18,6 @@ describe "Basic Auth HTTP headers" do
EOS @session.should_receive(:post).with("/form1", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"}) - @session.clicks_button + @session.click_button end end diff --git a/spec/api/check_spec.rb b/spec/api/check_spec.rb index 647a27a..8668eb3 100644 --- a/spec/api/check_spec.rb +++ b/spec/api/check_spec.rb @@ -35,7 +35,7 @@ describe "check" do EOS @session.should_receive(:get).with("/login", "user" => {"tos" => "1"}) @session.check "TOS" - @session.clicks_button + @session.click_button end it "should result in the value on being posted if not specified" do @@ -47,7 +47,7 @@ describe "check" do EOS @session.should_receive(:post).with("/login", "remember_me" => "on") @session.check "remember_me" - @session.clicks_button + @session.click_button end it "should fail if the checkbox is disabled" do @@ -69,7 +69,7 @@ describe "check" do EOS @session.should_receive(:post).with("/login", "remember_me" => "yes") @session.check "remember_me" - @session.clicks_button + @session.click_button end end @@ -119,7 +119,7 @@ describe "uncheck" do @session.should_receive(:get).with("/login", "user" => {"tos" => "0"}) @session.check "TOS" @session.uncheck "TOS" - @session.clicks_button + @session.click_button end it "should result in value not being posted" do @@ -131,6 +131,6 @@ describe "uncheck" do EOS @session.should_receive(:post).with("/login", {}) @session.uncheck "remember_me" - @session.clicks_button + @session.click_button end end diff --git a/spec/api/choose_spec.rb b/spec/api/choose_spec.rb index 055950a..dcb8af6 100644 --- a/spec/api/choose_spec.rb +++ b/spec/api/choose_spec.rb @@ -36,7 +36,7 @@ describe "choose" do EOS @session.should_receive(:get).with("/login", "user" => {"gender" => "M"}) @session.choose "Male" - @session.clicks_button + @session.click_button end 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.choose "Female" @session.choose "Male" - @session.clicks_button + @session.click_button end it "should fail if the radio button is disabled" do @@ -75,7 +75,7 @@ describe "choose" do EOS @session.should_receive(:post).with("/login", "first_option" => "on") @session.choose "first_option" - @session.clicks_button + @session.click_button end it "should result in the value on being posted if not specified and checked by default" do @@ -86,7 +86,7 @@ describe "choose" do EOS @session.should_receive(:post).with("/login", "first_option" => "on") - @session.clicks_button + @session.click_button end 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 @session.should_receive(:post).with("/login", "user" => {"gender" => "M"}) @session.choose "Male" - @session.clicks_button + @session.click_button end end diff --git a/spec/api/click_button_spec.rb b/spec/api/click_button_spec.rb index 7824703..4a337b0 100644 --- a/spec/api/click_button_spec.rb +++ b/spec/api/click_button_spec.rb @@ -1,6 +1,6 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") -describe "clicks_button" do +describe "click_button" do before do @session = Webrat::TestSession.new end @@ -10,7 +10,7 @@ describe "clicks_button" do
EOS - lambda { @session.clicks_button }.should raise_error + lambda { @session.click_button }.should raise_error end it "should fail if input is not a submit button" do @@ -20,7 +20,7 @@ describe "clicks_button" do EOS - lambda { @session.clicks_button }.should raise_error + lambda { @session.click_button }.should raise_error end @@ -31,7 +31,7 @@ describe "clicks_button" do EOS - lambda { @session.clicks_button }.should raise_error + lambda { @session.click_button }.should raise_error end it "should default to get method" do @@ -41,7 +41,7 @@ describe "clicks_button" do EOS @session.should_receive(:get) - @session.clicks_button + @session.click_button end it "should assert valid response" do @@ -51,7 +51,7 @@ describe "clicks_button" do EOS @session.response_code = 501 - lambda { @session.clicks_button }.should raise_error + lambda { @session.click_button }.should raise_error end [200, 300, 400, 499].each do |status| @@ -62,7 +62,7 @@ describe "clicks_button" do EOS @session.response_code = status - lambda { @session.clicks_button }.should_not raise_error + lambda { @session.click_button }.should_not raise_error end end @@ -76,7 +76,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/form1", {}) - @session.clicks_button + @session.click_button end it "should not explode on file fields" do @@ -86,7 +86,7 @@ describe "clicks_button" do EOS - @session.clicks_button + @session.click_button end it "should submit the form with the specified button" do @@ -99,7 +99,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/form2", {}) - @session.clicks_button "Form2" + @session.click_button "Form2" end it "should use action from form" do @@ -109,7 +109,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", {}) - @session.clicks_button + @session.click_button end it "should use method from form" do @@ -119,7 +119,7 @@ describe "clicks_button" do EOS @session.should_receive(:post) - @session.clicks_button + @session.click_button end it "should send button as param if it has a name" do @@ -130,7 +130,7 @@ describe "clicks_button" do EOS @session.should_receive(:post).with("/login", "login" => "Login") - @session.clicks_button("Login") + @session.click_button("Login") end it "should not send button as param if it has no name" do @@ -141,7 +141,7 @@ describe "clicks_button" do EOS @session.should_receive(:post).with("/login", {}) - @session.clicks_button("Login") + @session.click_button("Login") end it "should send default password field values" do @@ -152,7 +152,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "user" => {"password" => "mypass"}) - @session.clicks_button + @session.click_button end it "should send default hidden field values" do @@ -163,7 +163,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"}) - @session.clicks_button + @session.click_button end it "should send default text field values" do @@ -174,7 +174,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"}) - @session.clicks_button + @session.click_button end it "should not send disabled field values" do @@ -189,7 +189,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", {}) - @session.clicks_button + @session.click_button end it "should send default checked fields" do @@ -200,7 +200,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "user" => {"tos" => "1"}) - @session.clicks_button + @session.click_button end it "should send default radio options" do @@ -214,7 +214,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "user" => {"gender" => "F"}) - @session.clicks_button + @session.click_button end it "should send correct data for rails style unchecked fields" do @@ -226,7 +226,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "user" => {"tos" => "0"}) - @session.clicks_button + @session.click_button end it "should send correct data for rails style checked fields" do @@ -238,7 +238,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "user" => {"tos" => "1"}) - @session.clicks_button + @session.click_button end it "should send default collection fields" do @@ -260,7 +260,7 @@ describe "clicks_button" do @session.should_receive(:post).with("/login", "options" => ["burger", "fries", "soda", "soda", "dessert"], "response" => { "choices" => [{"selected" => "one"}, {"selected" => "two"}, {"selected" => "two"}]}) - @session.clicks_button + @session.click_button end it "should not send default unchecked fields" do @@ -271,7 +271,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", {}) - @session.clicks_button + @session.click_button end it "should send default textarea values" do @@ -282,7 +282,7 @@ describe "clicks_button" do EOS @session.should_receive(:post).with("/posts", "post" => {"body" => "Post body here!"}) - @session.clicks_button + @session.click_button end it "should send default selected option value from select" do @@ -296,7 +296,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "month" => "2") - @session.clicks_button + @session.click_button end it "should send default selected option inner html from select when no value attribute" do @@ -310,7 +310,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "month" => "February") - @session.clicks_button + @session.click_button end it "should send first select option value when no option selected" do @@ -324,7 +324,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "month" => "1") - @session.clicks_button + @session.click_button end it "should handle nested properties" do @@ -336,7 +336,7 @@ describe "clicks_button" do EOS @session.should_receive(:post).with("/login", "contestant" => {"scores" => {'1' => '2', '3' => '4'}}) - @session.clicks_button + @session.click_button end it "should send default empty text field values" do @@ -347,7 +347,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "user" => {"email" => ""}) - @session.clicks_button + @session.click_button end it "should recognize button tags" do @@ -358,7 +358,7 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "user" => {"email" => ""}) - @session.clicks_button + @session.click_button end it "should recognize image button tags" do @@ -368,7 +368,7 @@ describe "clicks_button" do EOS @session.should_receive(:get) - @session.clicks_button + @session.click_button end it "should find buttons by their IDs" do @@ -378,7 +378,7 @@ describe "clicks_button" do EOS @session.should_receive(:get) - @session.clicks_button "my_button" + @session.click_button "my_button" end it "should find image buttons by their alt text" do @@ -388,7 +388,7 @@ describe "clicks_button" do EOS @session.should_receive(:get) - @session.clicks_button "Go" + @session.click_button "Go" end it "should recognize button tags by content" do @@ -399,6 +399,6 @@ describe "clicks_button" do EOS @session.should_receive(:get).with("/login", "user" => {"email" => ""}) - @session.clicks_button "Login" + @session.click_button "Login" end end diff --git a/spec/api/fill_in_spec.rb b/spec/api/fill_in_spec.rb index 7331896..e2150b6 100644 --- a/spec/api/fill_in_spec.rb +++ b/spec/api/fill_in_spec.rb @@ -15,7 +15,7 @@ describe "fill_in" do EOS @session.should_receive(:post).with("/login", "user" => {"text" => "filling text area"}) @session.fill_in "User Text", :with => "filling text area" - @session.clicks_button + @session.click_button end it "should work with password fields" do @@ -27,7 +27,7 @@ describe "fill_in" do EOS @session.should_receive(:post).with("/login", "user" => {"text" => "pass"}) @session.fill_in "user_text", :with => "pass" - @session.clicks_button + @session.click_button end it "should fail if input not found" do @@ -61,7 +61,7 @@ describe "fill_in" do EOS @session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"}) @session.fill_in "user[email]", :with => "foo@example.com" - @session.clicks_button + @session.click_button end 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.fill_in "Some", :with => "value" - @session.clicks_button + @session.click_button end 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.fill_in "Some mail", :with => "value" - @session.clicks_button + @session.click_button end it "should anchor label matches to start of label" do @@ -130,7 +130,7 @@ describe "fill_in" do EOS @session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"}) @session.fill_in "Email", :with => "foo@example.com" - @session.clicks_button + @session.click_button end it "should work with full input names" do @@ -142,7 +142,7 @@ describe "fill_in" do EOS @session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"}) @session.fill_in "user[email]", :with => "foo@example.com" - @session.clicks_button + @session.click_button end it "should work if the input type is not set" do @@ -154,7 +154,7 @@ describe "fill_in" do EOS @session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"}) @session.fill_in "user[email]", :with => "foo@example.com" - @session.clicks_button + @session.click_button end it "should work with symbols" do @@ -167,7 +167,7 @@ describe "fill_in" do EOS @session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"}) @session.fill_in :email, :with => "foo@example.com" - @session.clicks_button + @session.click_button end it "should escape field values" do @@ -180,6 +180,6 @@ describe "fill_in" do EOS @session.should_receive(:post).with("/users", "user" => {"phone" => "+1 22 33"}) @session.fill_in 'Phone', :with => "+1 22 33" - @session.clicks_button + @session.click_button end end diff --git a/spec/api/selects_spec.rb b/spec/api/selects_spec.rb index d33afce..e2a1d24 100644 --- a/spec/api/selects_spec.rb +++ b/spec/api/selects_spec.rb @@ -57,7 +57,7 @@ describe "selects" do EOS @session.should_receive(:post).with("/login", "month" => "1") @session.selects "January", :from => "month" - @session.clicks_button + @session.click_button end it "should send values with HTML encoded ampersands" do @@ -69,7 +69,7 @@ describe "selects" do EOS @session.should_receive(:post).with("/login", "encoded" => "A & B") @session.selects "Encoded", :from => "encoded" - @session.clicks_button + @session.click_button end it "should work with empty select lists" do @@ -80,7 +80,7 @@ describe "selects" do EOS @session.should_receive(:post).with("/login", 'month' => '') - @session.clicks_button + @session.click_button end it "should work without specifying the field name or label" do @@ -92,7 +92,7 @@ describe "selects" do EOS @session.should_receive(:post).with("/login", "month" => "1") @session.selects "January" - @session.clicks_button + @session.click_button end it "should send value from option in list specified by name" do @@ -105,7 +105,7 @@ describe "selects" do EOS @session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1") @session.selects "January", :from => "end_month" - @session.clicks_button + @session.click_button end it "should send value from option in list specified by label" do @@ -120,7 +120,7 @@ describe "selects" do EOS @session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1") @session.selects "January", :from => "End Month" - @session.clicks_button + @session.click_button end it "should use option text if no value" do @@ -132,7 +132,7 @@ describe "selects" do EOS @session.should_receive(:post).with("/login", "month" => "January") @session.selects "January", :from => "month" - @session.clicks_button + @session.click_button end it "should find option by regexp" do @@ -144,7 +144,7 @@ describe "selects" do EOS @session.should_receive(:post).with("/login", "month" => "January") @session.selects(/jan/i) - @session.clicks_button + @session.click_button end it "should fail if no option matching the regexp exists" do @@ -172,6 +172,6 @@ describe "selects" do EOS @session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1") @session.selects(/jan/i, :from => "End Month") - @session.clicks_button + @session.click_button end end diff --git a/spec/api/within_spec.rb b/spec/api/within_spec.rb index a334fbb..c80ba8e 100644 --- a/spec/api/within_spec.rb +++ b/spec/api/within_spec.rb @@ -34,7 +34,7 @@ describe "within" do @session.should_receive(:get).with("/form2", "email" => "test@example.com") @session.within "#form2" do |scope| scope.fill_in "Email", :with => "test@example.com" - scope.clicks_button + scope.click_button end end @@ -49,7 +49,7 @@ describe "within" do @session.within "#form2" do |scope| lambda { - scope.clicks_button + scope.click_button }.should raise_error end end diff --git a/spec/webrat/rails/attaches_file_spec.rb b/spec/webrat/rails/attaches_file_spec.rb index 0f5c97b..1e1a291 100644 --- a/spec/webrat/rails/attaches_file_spec.rb +++ b/spec/webrat/rails/attaches_file_spec.rb @@ -25,7 +25,7 @@ describe "attaches_file" do EOS @session.should_receive(:post).with("/widgets", { "widget" => { "file" => "" } }) - @session.clicks_button + @session.click_button end it "should submit the attached file" do @@ -38,7 +38,7 @@ describe "attaches_file" do EOS @session.should_receive(:post).with("/widgets", { "widget" => { "file" => @uploaded_file } }) @session.attaches_file "Document", @filename - @session.clicks_button + @session.click_button end 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.attaches_file "Document", @filename @session.attaches_file "Spreadsheet", @filename - @session.clicks_button + @session.click_button end it "should allow the content type to be specified" do @@ -67,6 +67,6 @@ describe "attaches_file" do EOS ActionController::TestUploadedFile.should_receive(:new).with(@filename, "image/png").any_number_of_times @session.attaches_file "Picture", @filename, "image/png" - @session.clicks_button + @session.click_button end end \ No newline at end of file diff --git a/spec/webrat/rails/rails_spec.rb b/spec/webrat/rails/rails_spec.rb index d3d379b..0cd2849 100644 --- a/spec/webrat/rails/rails_spec.rb +++ b/spec/webrat/rails/rails_spec.rb @@ -7,7 +7,7 @@ # EOS # @page.stub!(:url).and_return("/current") # @session.should_receive(:get).with("/current", {}) -# @session.clicks_button +# @session.click_button # end # # it "should follow fully qualified secure local links" do