Sha256: 019d52e5a575203095358c27565c4ee6c5b03eb2b828e2d23647d45bc9d801aa

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'rspec/support'
RSpec::Support.require_rspec_support "caller_filter"

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

      # @private
      #
      # Used internally to print deprecation warnings
      # when rspec-core isn't loaded
      def warn_deprecation(message, options = {})
        warn_with "DEPRECATION: \n #{message}", options
      end

      # @private
      #
      # Used internally to print warnings
      def warning(text, options={})
        warn_with "WARNING: #{text}.", options
      end

      # @private
      #
      # Used internally to print longer warnings
      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
        ::Kernel.warn message
      end
    end
  end

  extend RSpec::Support::Warnings
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-support-3.0.4 lib/rspec/support/warnings.rb
rspec-support-3.0.3 lib/rspec/support/warnings.rb