From 235c601922c4625eb4fd76052c7bd18b38282d3c Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 26 Oct 2008 17:02:58 -0400 Subject: [PATCH] Cleaning up clicks_link method options --- TODO.txt | 2 ++ lib/webrat/core/link.rb | 4 ++-- lib/webrat/core/logging.rb | 5 +++++ lib/webrat/core/scope.rb | 10 +++++----- spec/api/clicks_link_spec.rb | 8 ++++---- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/TODO.txt b/TODO.txt index 10aa293..9ed88f5 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,3 +1,5 @@ +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 diff --git a/lib/webrat/core/link.rb b/lib/webrat/core/link.rb index a8cb90d..e478494 100644 --- a/lib/webrat/core/link.rb +++ b/lib/webrat/core/link.rb @@ -8,8 +8,8 @@ module Webrat @element = element end - def click(method = nil, options = {}) - method ||= http_method + def click(options = {}) + method = options[:method] || http_method return if href =~ /^#/ && method == :get options[:javascript] = true if options[:javascript].nil? diff --git a/lib/webrat/core/logging.rb b/lib/webrat/core/logging.rb index 6634e96..8f03055 100644 --- a/lib/webrat/core/logging.rb +++ b/lib/webrat/core/logging.rb @@ -1,5 +1,10 @@ module Webrat module Logging + + def warn_log(message) # :nodoc: + return unless logger + logger.warn message + end def debug_log(message) # :nodoc: return unless logger diff --git a/lib/webrat/core/scope.rb b/lib/webrat/core/scope.rb index f09905a..b9444c2 100644 --- a/lib/webrat/core/scope.rb +++ b/lib/webrat/core/scope.rb @@ -113,7 +113,7 @@ module Webrat # # clicks_link "Sign up", :javascript => false def clicks_link(link_text, options = {}) - find_link(link_text).click(nil, options) + find_link(link_text).click(options) end alias_method :click_link, :clicks_link @@ -123,7 +123,7 @@ module Webrat # Example: # clicks_get_link "Log out" def clicks_get_link(link_text) - find_link(link_text).click(:get) + clicks_link link_text, :method => :get end alias_method :click_get_link, :clicks_get_link @@ -133,7 +133,7 @@ module Webrat # Example: # clicks_delete_link "Log out" def clicks_delete_link(link_text) - find_link(link_text).click(:delete) + clicks_link link_text, :method => :delete end alias_method :click_delete_link, :clicks_delete_link @@ -143,7 +143,7 @@ module Webrat # Example: # clicks_post_link "Vote" def clicks_post_link(link_text) - find_link(link_text).click(:post) + clicks_link link_text, :method => :post end alias_method :click_post_link, :clicks_post_link @@ -153,7 +153,7 @@ module Webrat # Example: # clicks_put_link "Update profile" def clicks_put_link(link_text) - find_link(link_text).click(:put) + clicks_link link_text, :method => :put end alias_method :click_put_link, :clicks_put_link diff --git a/spec/api/clicks_link_spec.rb b/spec/api/clicks_link_spec.rb index d57c46e..9b1e8be 100644 --- a/spec/api/clicks_link_spec.rb +++ b/spec/api/clicks_link_spec.rb @@ -18,7 +18,7 @@ describe "clicks_link" do Link text EOS @session.should_receive(:get).with("/page", {}) - @session.clicks_get_link "Link text" + @session.clicks_link "Link text", :method => :get end it "should click delete links" do @@ -26,7 +26,7 @@ describe "clicks_link" do Link text EOS @session.should_receive(:delete).with("/page", {}) - @session.clicks_delete_link "Link text" + @session.clicks_link "Link text", :method => :delete end @@ -35,7 +35,7 @@ describe "clicks_link" do Link text EOS @session.should_receive(:post).with("/page", {}) - @session.clicks_post_link "Link text" + @session.clicks_link "Link text", :method => :post end it "should click put links" do @@ -43,7 +43,7 @@ describe "clicks_link" do Link text EOS @session.should_receive(:put).with("/page", {}) - @session.clicks_put_link "Link text" + @session.clicks_link "Link text", :method => :put end it "should click rails javascript links with authenticity tokens" do