Skip to content

Commit

Permalink
Refactor clicks_link_within to use new within functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Jul 26, 2008
1 parent e746335 commit 592f709
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
13 changes: 12 additions & 1 deletion lib/webrat/core/page.rb
Expand Up @@ -55,14 +55,25 @@ def reloads

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
def_delegators :scope, :choose, :chooses
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
Expand Down
10 changes: 0 additions & 10 deletions lib/webrat/core/scope.rb
Expand Up @@ -103,16 +103,6 @@ def clicks_link(link_text, options = {})

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:
Expand Down

0 comments on commit 592f709

Please sign in to comment.