Module: Kernel

Defined in:
lib/chefspec/deprecations.rb

Instance Method Summary collapse

Instance Method Details

#deprecated(*messages) ⇒ Object

Kernel extension to print deprecation notices.

Examples:

printing a deprecation warning

deprecated 'no longer in use' #=> "[DEPRECATION] no longer in use"

Parameters:

  • messages (Array<String>)

8
9
10
11
12
13
14
# File 'lib/chefspec/deprecations.rb', line 8

def deprecated(*messages)
  messages.each do |message|
    calling_spec = caller.find { |line| line =~ /(\/spec)|(_spec\.rb)/ }
    calling_spec = 'spec/' + calling_spec.split('/spec/').last
    warn "[DEPRECATION] #{message} (called from #{calling_spec})"
  end
end