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

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

Instance Method Summary (collapse)

Constructor Details

- (DeprecationFormatter) initialize(deprecation_stream = $stderr, summary_stream = $stdout)

A new instance of DeprecationFormatter

5
6
7
8
9
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 5
def initialize(deprecation_stream=$stderr, summary_stream=$stdout)
  @deprecation_stream = deprecation_stream
  @summary_stream = summary_stream
  @count = 0
end

Instance Method Details

- (Object) deprecation(data)

15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 15
def deprecation(data)
  @count += 1
  if data[:message]
    @deprecation_stream.print data[:message]
  else
    @deprecation_stream.print "DEPRECATION: " unless File === @deprecation_stream
    @deprecation_stream.print "#{data[:deprecated]} is deprecated."
    @deprecation_stream.print " Use #{data[:replacement]} instead." if data[:replacement]
    @deprecation_stream.print " Called from #{data[:call_site]}." if data[:call_site]
    @deprecation_stream.puts
  end
end

- (Object) deprecation_summary

28
29
30
31
32
33
34
35
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 28
def deprecation_summary
  if @count > 0 && File === @deprecation_stream
    @summary_stream.print "\n#{@count} deprecation"
    @summary_stream.print "s" if @count > 1
    @summary_stream.print " logged to "
    @summary_stream.puts @deprecation_stream.path
  end
end

- (Object) start(example_count = nil)

11
12
13
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 11
def start(example_count=nil)
  #no-op to fix #966
end