Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from rspec/new-deprecation-api
use new deprecation API
- Loading branch information
Showing
9 changed files
with
27 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,17 @@ | ||
module RSpec | ||
unless respond_to?(:deprecate) | ||
class << self | ||
# Used internally by RSpec to display standard deprecation warnings. | ||
# This is also defined in rspec-core, but we can't assume it's loaded | ||
# since rspec-expectations should be usable w/o rspec-core. | ||
def deprecate(method, alternate_method=nil, version=nil) | ||
version_string = version ? "rspec-#{version}" : "a future version of RSpec" | ||
|
||
message = <<-NOTICE | ||
***************************************************************** | ||
DEPRECATION WARNING: you are using deprecated behaviour that will | ||
be removed from #{version_string}. | ||
#{caller(0)[2]} | ||
* #{method} is deprecated. | ||
NOTICE | ||
if alternate_method | ||
message << <<-ADDITIONAL | ||
* please use #{alternate_method} instead. | ||
ADDITIONAL | ||
end | ||
|
||
message << "*****************************************************************" | ||
warn_deprecation(message) | ||
end | ||
|
||
# Used internally by RSpec to display custom deprecation warnings. This | ||
# is also defined in rspec-core, but we can't assume it's loaded since | ||
# rspec-expectations should be usable w/o rspec-core. | ||
def warn_deprecation(message) | ||
warn(message) | ||
module Expectations | ||
module Deprecation | ||
# @private | ||
# | ||
# Used internally to print deprecation warnings | ||
def deprecate(deprecated, options={}) | ||
message = "DEPRECATION: #{deprecated} is deprecated." | ||
message << " Use #{options[:replacement]} instead." if options[:replacement] | ||
message << " Called from #{caller(0)[2]}." | ||
warn message | ||
end | ||
end | ||
end | ||
|
||
extend(Expectations::Deprecation) unless respond_to?(:deprecate) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters