Class: RSpec::Core::Formatters::DeprecationFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/core/formatters/deprecation_formatter.rb

Defined Under Namespace

Classes: DelayedPrinter, FileStream, GeneratedDeprecationMessage, ImmediatePrinter, RaiseErrorStream, SpecifiedDeprecationMessage

Constant Summary collapse

RAISE_ERROR_CONFIG_NOTICE =
<<-EOS.gsub(/^\s+\|/, '')
  |
  |If you need more of the backtrace for any of these deprecations to
  |identify where to make the necessary changes, you can configure
  |`config.raise_errors_for_deprecations!`, and it will turn the
  |deprecation warnings into errors, giving you the full backtrace.
EOS
DEPRECATION_STREAM_NOTICE =
"Pass `--deprecation-out` or set " +
"`config.deprecation_stream` to a file for full output."

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deprecation_stream, summary_stream) ⇒ DeprecationFormatter

Returns a new instance of DeprecationFormatter.



10
11
12
13
14
15
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 10

def initialize(deprecation_stream, summary_stream)
  @deprecation_stream = deprecation_stream
  @summary_stream = summary_stream
  @seen_deprecations = Set.new
  @count = 0
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



8
9
10
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 8

def count
  @count
end

#deprecation_streamObject (readonly)

Returns the value of attribute deprecation_stream.



8
9
10
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 8

def deprecation_stream
  @deprecation_stream
end

#summary_streamObject (readonly)

Returns the value of attribute summary_stream.



8
9
10
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 8

def summary_stream
  @summary_stream
end

Instance Method Details

#deprecation(data) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 28

def deprecation(data)
  return if @seen_deprecations.include?(data)

  @count += 1
  printer.print_deprecation_message data
  @seen_deprecations << data
end

#deprecation_message_for(data) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 44

def deprecation_message_for(data)
  if data[:message]
    SpecifiedDeprecationMessage.new(data)
  else
    GeneratedDeprecationMessage.new(data)
  end
end

#deprecation_summaryObject



36
37
38
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 36

def deprecation_summary
  printer.deprecation_summary
end

#printerObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 17

def printer
  @printer ||= case deprecation_stream
               when File
                 ImmediatePrinter.new(FileStream.new(deprecation_stream), summary_stream, self)
               when RaiseErrorStream
                 ImmediatePrinter.new(deprecation_stream, summary_stream, self)
               else
                 DelayedPrinter.new(deprecation_stream, summary_stream, self)
               end
end

#start(example_count = nil) ⇒ Object



40
41
42
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 40

def start(example_count=nil)
  #no-op to fix #966
end