-
-
Save e1senh0rn/4353554 to your computer and use it in GitHub Desktop.
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
module DeprecateAssertions | |
def self.methods_to_replace | |
[ | |
:assert, | |
:assert_block, | |
:assert_equal, | |
:assert_no_match, | |
:assert_not_equal, | |
:assert_nothing_raised, | |
:assert_nothing_thrown, | |
:assert_not_nil, | |
:assert_not_same, | |
:assert_raise, | |
:assert_respond_to, | |
:assert_difference, | |
:assert_in_delta, | |
:assert_nil, | |
] | |
end | |
def self.included a | |
a.class_eval do | |
DeprecateAssertions.methods_to_replace.each do |m| | |
alias :"old_#{m}" :"#{m}" | |
alias :"#{m}" :"new_#{m}" | |
end | |
end | |
end | |
DeprecateAssertions.methods_to_replace.each do |m| | |
define_method(:"new_#{m}") do |*args| | |
warn "[DEPRECATED] '#{m}' is deprecated. Please use RSpec methods instead." | |
warn "from: #{caller[0]}" | |
send(:"old_#{m}", *args) | |
end | |
end | |
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
RSpec.configure do |config| | |
config.include DeprecateAssertions | |
# ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment