Skip to content

Commit

Permalink
Alias visits as visit, clicks_link as click_link, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Jul 22, 2008
1 parent 13a8688 commit c07c6af
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -56,7 +56,7 @@ end

require 'spec/rake/verify_rcov'
RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
t.threshold = 97.1 # Make sure you have rcov 0.7 or higher!
t.threshold = 97.2 # Make sure you have rcov 0.7 or higher!
end

remove_task "default"
Expand Down
30 changes: 30 additions & 0 deletions lib/webrat/core/page.rb
Expand Up @@ -36,6 +36,8 @@ def fills_in(id_or_name_or_label, options = {})
field.set(options[:with])
end

alias_method :fill_in, :fills_in

# Verifies that an input checkbox exists on the current page and marks it
# as checked, so that the value will be submitted with the form.
#
Expand All @@ -46,6 +48,8 @@ def checks(id_or_name_or_label)
field.check
end

alias_method :check, :checks

# Verifies that an input checkbox exists on the current page and marks it
# as unchecked, so that the value will not be submitted with the form.
#
Expand All @@ -56,6 +60,8 @@ def unchecks(id_or_name_or_label)
field.uncheck
end

alias_method :uncheck, :unchecks

# Verifies that an input radio button exists on the current page and marks it
# as checked, so that the value will be submitted with the form.
#
Expand All @@ -66,6 +72,8 @@ def chooses(label)
field.choose
end

alias_method :choose, :chooses

# Verifies that a an option element exists on the current page with the specified
# text. You can optionally restrict the search to a specific select list by
# assigning <tt>options[:from]</tt> the value of the select list's name or
Expand All @@ -89,6 +97,8 @@ def selects(option_text, options = {})
option.choose
end

alias_method :select, :selects

# Verifies that an input file field exists on the current page and sets
# its value to the given +file+, so that the file will be uploaded
# along with the form.
Expand All @@ -100,6 +110,8 @@ def attaches_file(id_or_name_or_label, path)
field.set(path)
end

alias_method :attach_file, :attaches_file

# Saves the page out to RAILS_ROOT/tmp/ and opens it in the default
# web browser if on OS X. Useful for debugging.
#
Expand Down Expand Up @@ -139,6 +151,8 @@ def clicks_link(link_text, options = {})
link.click(nil, options)
end

alias_method :click_link, :clicks_link

# Works like clicks_link, but only looks for the link text within a given selector
#
# Example:
Expand All @@ -148,6 +162,8 @@ def clicks_link_within(selector, link_text)
link.click
end

alias_method :click_link_within, :clicks_link_within

# Works like clicks_link, but forces a GET request
#
# Example:
Expand All @@ -157,6 +173,8 @@ def clicks_get_link(link_text)
link.click(:get)
end

alias_method :click_get_link, :clicks_get_link

# Works like clicks_link, but issues a DELETE request instead of a GET
#
# Example:
Expand All @@ -166,6 +184,8 @@ def clicks_delete_link(link_text)
link.click(:delete)
end

alias_method :click_delete_link, :clicks_delete_link

# Works like clicks_link, but issues a POST request instead of a GET
#
# Example:
Expand All @@ -175,6 +195,8 @@ def clicks_post_link(link_text)
link.click(:post)
end

alias_method :click_post_link, :clicks_post_link

# Works like clicks_link, but issues a PUT request instead of a GET
#
# Example:
Expand All @@ -184,6 +206,8 @@ def clicks_put_link(link_text)
link.click(:put)
end

alias_method :click_put_link, :clicks_put_link

# Verifies that a submit button exists for the form, then submits the form, follows
# any redirects, and verifies the final page was successful.
#
Expand All @@ -205,6 +229,8 @@ def clicks_button(value = nil)
button.click
end

alias_method :click_button, :clicks_button

# Reloads the last page requested. Note that this will resubmit forms
# and their data.
#
Expand All @@ -214,9 +240,13 @@ def reloads
load_page
end

alias_method :reload, :reloads

def submits_form(form_id = nil) # :nodoc:
end

alias_method :submit_form, :submits_form

protected

def load_page
Expand Down
2 changes: 2 additions & 0 deletions lib/webrat/core/session.rb
Expand Up @@ -21,6 +21,8 @@ def visits(*args)
Page.new(self, *args)
end

alias_method :visit, :visits

def respond_to?(name)
super || current_page.respond_to?(name)
end
Expand Down

0 comments on commit c07c6af

Please sign in to comment.