File: deprecation.rb

package info (click to toggle)
ruby-rspec-core 2.14.7-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,756 kB
  • ctags: 1,195
  • sloc: ruby: 12,708; makefile: 14
file content (31 lines) | stat: -rw-r--r-- 992 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module RSpec
  module Core
    module Deprecation
      # @private
      #
      # Used internally to print deprecation warnings
      def deprecate(deprecated, replacement_or_hash={}, ignore_version=nil)
        # Temporarily support old and new APIs while we transition the other
        # rspec libs to use a hash for the 2nd arg and no version arg
        data = Hash === replacement_or_hash ? replacement_or_hash : { :replacement => replacement_or_hash }
        call_site = caller.find { |line| line !~ %r{/lib/rspec/(core|mocks|expectations|matchers|rails)/} }

        RSpec.configuration.reporter.deprecation(
          {
            :deprecated => deprecated,
            :call_site => call_site
          }.merge(data)
        )
      end

      # @private
      #
      # Used internally to print deprecation warnings
      def warn_deprecation(message)
        RSpec.configuration.reporter.deprecation :message => message
      end
    end
  end

  extend(Core::Deprecation)
end