/usr/lib/ruby/vendor_ruby/rspec/core/formatters/base_formatter.rb is in ruby-rspec-core 3.5.0c3e0m0s0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | RSpec::Support.require_rspec_core "formatters/helpers"
require 'stringio'
module RSpec
module Core
module Formatters
# RSpec's built-in formatters are all subclasses of
# RSpec::Core::Formatters::BaseTextFormatter.
#
# @see RSpec::Core::Formatters::BaseTextFormatter
# @see RSpec::Core::Reporter
# @see RSpec::Core::Formatters::Protocol
class BaseFormatter
# All formatters inheriting from this formatter will receive these
# notifications.
Formatters.register self, :start, :example_group_started, :close
attr_accessor :example_group
attr_reader :output
# @api public
# @param output [IO] the formatter output
# @see RSpec::Core::Formatters::Protocol#initialize
def initialize(output)
@output = output || StringIO.new
@example_group = nil
end
# @api public
#
# @param notification [StartNotification]
# @see RSpec::Core::Formatters::Protocol#start
def start(notification)
start_sync_output
@example_count = notification.count
end
# @api public
#
# @param notification [GroupNotification] containing example_group
# subclass of `RSpec::Core::ExampleGroup`
# @see RSpec::Core::Formatters::Protocol#example_group_started
def example_group_started(notification)
@example_group = notification.group
end
# @api public
#
# @param _notification [NullNotification] (Ignored)
# @see RSpec::Core::Formatters::Protocol#close
def close(_notification)
restore_sync_output
end
private
def start_sync_output
@old_sync, output.sync = output.sync, true if output_supports_sync
end
def restore_sync_output
output.sync = @old_sync if output_supports_sync && !output.closed?
end
def output_supports_sync
output.respond_to?(:sync=)
end
end
end
end
end
|