Skip to content

Commit

Permalink
Deprecating old style methods
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Nov 25, 2008
1 parent 2c26bc8 commit 9b15035
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
26 changes: 13 additions & 13 deletions lib/webrat/core/scope.rb
@@ -1,5 +1,6 @@
require "webrat/core/form"
require "webrat/core/locators"
require "webrat/core_extensions/deprecate"

module Webrat
class NotFoundError < WebratError
Expand Down Expand Up @@ -44,7 +45,7 @@ def fill_in(field_locator, options = {})
field.set(options[:with])
end

alias_method :fills_in, :fill_in
webrat_deprecate :fills_in, :fill_in

def set_hidden_field(field_locator, options = {})
field = locate_field(field_locator, HiddenField)
Expand All @@ -60,7 +61,7 @@ def check(field_locator)
locate_field(field_locator, CheckboxField).check
end

alias_method :checks, :check
webrat_deprecate :checks, :check

# 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 @@ -71,7 +72,7 @@ def uncheck(field_locator)
locate_field(field_locator, CheckboxField).uncheck
end

alias_method :unchecks, :uncheck
webrat_deprecate :unchecks, :uncheck

# 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 @@ -82,7 +83,7 @@ def choose(field_locator)
locate_field(field_locator, RadioField).choose
end

alias_method :chooses, :choose
webrat_deprecate :chooses, :choose

# 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
Expand All @@ -102,7 +103,7 @@ def select(option_text, options = {})
end
end

alias_method :selects, :select
webrat_deprecate :selects, :select

DATE_TIME_SUFFIXES = {
:year => '1i',
Expand Down Expand Up @@ -142,7 +143,7 @@ def select_date(date_to_select, options ={})
select date.day, :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:day]}"
end

alias_method :selects_date, :select_date
webrat_deprecate :selects_date, :select_date

# Verifies that time elements (hour, minute) exist on the current page
# with the specified values. You can optionally restrict the search to a specific
Expand Down Expand Up @@ -175,8 +176,7 @@ def select_time(time_to_select, options ={})
select time.min.to_s.rjust(2,'0'), :from => "#{id_prefix}_#{DATE_TIME_SUFFIXES[:minute]}"
end


alias_method :selects_time, :select_time
webrat_deprecate :selects_time, :select_time

# Verifies and selects all the date and time elements on the current page.
# See #select_time and #select_date for more details and available options.
Expand All @@ -195,7 +195,7 @@ def select_datetime(time_to_select, options ={})
select_time time, options
end

alias_method :selects_datetime, :select_datetime
webrat_deprecate :selects_datetime, :select_datetime

# 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
Expand All @@ -208,13 +208,13 @@ def attach_file(field_locator, path, content_type = nil)
locate_field(field_locator, FileField).set(path, content_type)
end

alias_method :attaches_file, :attach_file
webrat_deprecate :attaches_file, :attach_file

def click_area(area_name)
find_area(area_name).click
end

alias_method :clicks_area, :click_area
webrat_deprecate :clicks_area, :click_area

# Issues a request for the URL pointed to by a link on the current page,
# follows any redirects, and verifies the final page load was successful.
Expand Down Expand Up @@ -246,7 +246,7 @@ def click_link(text_or_title_or_id, options = {})
find_link(text_or_title_or_id).click(options)
end

alias_method :clicks_link, :click_link
webrat_deprecate :clicks_link, :click_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 @@ -261,7 +261,7 @@ def click_button(value = nil)
find_button(value).click
end

alias_method :clicks_button, :click_button
webrat_deprecate :clicks_button, :click_button

def submit_form(id)
form = forms.detect { |f| f.matches_id?(id) }
Expand Down
6 changes: 3 additions & 3 deletions lib/webrat/core/session.rb
Expand Up @@ -139,7 +139,7 @@ def reloads
request_page(@current_url, @http_method, @data)
end

alias_method :reload, :reloads
webrat_deprecate :reload, :reloads


# Works like click_link, but only looks for the link text within a given selector
Expand All @@ -152,7 +152,7 @@ def click_link_within(selector, link_text)
end
end

alias_method :clicks_link_within, :click_link_within
webrat_deprecate :clicks_link_within, :click_link_within

def within(selector)
scopes.push(Scope.from_scope(self, current_scope, selector))
Expand All @@ -170,7 +170,7 @@ def visit(url = nil, http_method = :get, data = {})
request_page(url, http_method, data)
end

alias_method :visits, :visit
webrat_deprecate :visits, :visit

def open_in_browser(path) # :nodoc
platform = ruby_platform
Expand Down
2 changes: 1 addition & 1 deletion lib/webrat/core_extensions/deprecate.rb
@@ -1,5 +1,5 @@
class Module #:nodoc:
def deprecate(old_method_name, new_method_name)
def webrat_deprecate(old_method_name, new_method_name)
define_method old_method_name do |*args|
warn "#{old_method_name} is deprecated. Use #{new_method_name} instead."
__send__(new_method_name, *args)
Expand Down
6 changes: 3 additions & 3 deletions spec/api/click_link_spec.rb
Expand Up @@ -30,7 +30,7 @@
<a href="/page">Link text</a>
HTML
webrat_session.should_receive(:get).with("/page", {})
clicks_link "ink tex", :method => :get
click_link "ink tex", :method => :get
end

it "should click delete links" do
Expand Down Expand Up @@ -71,15 +71,15 @@
<a id="link_text_link" href="/page">Link text</a>
HTML
webrat_session.should_receive(:get).with("/page", {})
clicks_link "link_text_link"
click_link "link_text_link"
end

it "should click links by id regexp" do
with_html <<-HTML
<a id="link_text_link" href="/page">Link text</a>
HTML
webrat_session.should_receive(:get).with("/page", {})
clicks_link /_text_/
click_link /_text_/
end

it "should click rails javascript links with authenticity tokens" do
Expand Down

1 comment on commit 9b15035

@pd
Copy link
Contributor

@pd pd commented on 9b15035 Dec 10, 2008

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the reload/reloads deprecation intentionally the opposite of the rest?

Please sign in to comment.