Skip to content

Instantly share code, notes, and snippets.

@e1senh0rn
Forked from lunich/deprecate_assertions.rb
Last active December 10, 2015 00:48
Show Gist options
  • Save e1senh0rn/4353554 to your computer and use it in GitHub Desktop.
Save e1senh0rn/4353554 to your computer and use it in GitHub Desktop.
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
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