1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Add Capybara.deprecate

Deprecate methods using this, and set rspec expectations in suite to
prevent deprecation warnings from getting output.
This commit is contained in:
Bernerd Schaefer 2010-09-18 18:51:33 -05:00
parent 19e1ffc084
commit d584bb34e9
7 changed files with 10 additions and 4 deletions

View file

@ -66,6 +66,10 @@ module Capybara
def drivers
@drivers ||= {}
end
def deprecate(method, alternate_method)
warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead"
end
end
autoload :Server, 'capybara/server'

View file

@ -50,7 +50,7 @@ class Capybara::Driver::Base
end
def cleanup!
warn "DEPRECATED: #cleanup! has been renamed to #reset!"
Capybara.deprecate("cleanup!", "reset!")
reset!
end

View file

@ -77,7 +77,7 @@ module Capybara
# @deprecated node is deprecated, please use {Capybara::Element#native} instead
#
def node
warn "DEPRECATED: #node is deprecated, please use #native instead"
Capybara.deprecate("node", "native")
native
end

View file

@ -36,7 +36,7 @@ module Capybara
# @deprecated {#find} now behaves like locate used to. Use {#find} instead.
#
def locate(*args)
warn "DEPRECATED: Please use #find instead of #locate"
Capybara.deprecate("locate", "find")
find(*args)
end

View file

@ -241,7 +241,7 @@ module Capybara
# @deprecated click is deprecated, please use {Capybara::Node::Actions#click_link_or_button} instead
#
def click(locator)
warn "DEPRECATED: click is deprecated, use click_link_or_button instead"
Capybara.deprecate("click", "click_link_or_button")
current_node.click_link_or_button(locator)
end

View file

@ -13,6 +13,7 @@ shared_examples_for "click_link_or_button" do
end
it "should be aliased as click for backward compatibility" do
Capybara.should_receive(:deprecate).with("click", "click_link_or_button")
@session.visit('/form')
@session.click('awe123')
extract_results(@session)['first_name'].should == 'John'

View file

@ -14,6 +14,7 @@ shared_examples_for "find" do
end
it "should be aliased as locate for backward compatibility" do
Capybara.should_receive(:deprecate).with("locate", "find").twice
@session.locate('//h1').text.should == 'This is a test'
@session.locate("//input[@id='test_field']")[:value].should == 'monkey'
end