From 592f70950d37e527beb10cd255734cf84ce34eb3 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sat, 26 Jul 2008 12:18:51 -0400 Subject: [PATCH] Refactor clicks_link_within to use new within functionality --- lib/webrat/core/page.rb | 13 ++++++++++++- lib/webrat/core/scope.rb | 10 ---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/webrat/core/page.rb b/lib/webrat/core/page.rb index 9b4262a..28b6ee7 100644 --- a/lib/webrat/core/page.rb +++ b/lib/webrat/core/page.rb @@ -55,6 +55,18 @@ module Webrat alias_method :reload, :reloads + # Works like clicks_link, but only looks for the link text within a given selector + # + # Example: + # clicks_link_within "#user_12", "Vote" + def clicks_link_within(selector, link_text) + within(selector) do |scope| + scope.clicks_link(link_text) + end + end + + alias_method :click_link_within, :clicks_link_within + def_delegators :scope, :fill_in, :fills_in def_delegators :scope, :check, :checks def_delegators :scope, :uncheck, :unchecks @@ -62,7 +74,6 @@ module Webrat def_delegators :scope, :select, :selects def_delegators :scope, :attach_file, :attaches_file def_delegators :scope, :click_link, :clicks_link - def_delegators :scope, :click_link_within, :clicks_link_within def_delegators :scope, :click_get_link, :clicks_get_link def_delegators :scope, :click_delete_link, :clicks_delete_link def_delegators :scope, :click_post_link, :clicks_post_link diff --git a/lib/webrat/core/scope.rb b/lib/webrat/core/scope.rb index c6e3d35..f0030b2 100644 --- a/lib/webrat/core/scope.rb +++ b/lib/webrat/core/scope.rb @@ -103,16 +103,6 @@ module Webrat alias_method :click_link, :clicks_link - # Works like clicks_link, but only looks for the link text within a given selector - # - # Example: - # clicks_link_within "#user_12", "Vote" - def clicks_link_within(selector, link_text) - find_link(link_text, selector).click - end - - alias_method :click_link_within, :clicks_link_within - # Works like clicks_link, but forces a GET request # # Example: