Module: RSpec::Support::Warnings

Included in:
RSpec
Defined in:
lib/rspec/support/warnings.rb

Instance Method Summary collapse

Instance Method Details

#deprecate(deprecated, options = {}) ⇒ Object



7
8
9
# File 'lib/rspec/support/warnings.rb', line 7

def deprecate(deprecated, options={})
  warn_with "DEPRECATION: #{deprecated} is deprecated.", options
end

#warn_deprecation(message, options = {}) ⇒ Object

Used internally to print deprecation warnings when rspec-core isn’t loaded



15
16
17
# File 'lib/rspec/support/warnings.rb', line 15

def warn_deprecation(message, options={})
  warn_with "DEPRECATION: \n #{message}", options
end

#warn_with(message, options = {}) ⇒ Object

Used internally to print longer warnings



29
30
31
32
33
34
# File 'lib/rspec/support/warnings.rb', line 29

def warn_with(message, options={})
  call_site = options.fetch(:call_site) { CallerFilter.first_non_rspec_line }
  message += " Use #{options[:replacement]} instead." if options[:replacement]
  message += " Called from #{call_site}." if call_site
  Support.warning_notifier.call message
end

#warning(text, options = {}) ⇒ Object

Used internally to print warnings



22
23
24
# File 'lib/rspec/support/warnings.rb', line 22

def warning(text, options={})
  warn_with "WARNING: #{text}.", options
end