Sha256: 59b8b9899a130f140d34b3a00c8d03f8659fed84d36f417e6c108d447ad1474c

Contents?: true

Size: 745 Bytes

Versions: 37

Compression:

Stored size: 745 Bytes

Contents

module Omnibus
  module RSpec
    module LoggingHelpers
      #
      # Grab the result of the log command. Since Omnibus uses the block form of
      # the logger, this method handles both types of logging.
      #
      # @example
      #   output = capture_logging { some_command }
      #   expect(output).to include('whatever')
      #
      def capture_logging
        original = Omnibus.logger
        Omnibus.logger = TestLogger.new
        yield
        Omnibus.logger.output
      ensure
        Omnibus.logger = original
      end

      class TestLogger < Logger
        def initialize(*)
          super(StringIO.new)
          @level = -1
        end

        def output
          io.string
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
omnibus-9.0.24 spec/support/logging_helpers.rb
omnibus-9.0.23 spec/support/logging_helpers.rb
omnibus-9.0.22 spec/support/logging_helpers.rb
omnibus-9.0.17 spec/support/logging_helpers.rb
omnibus-9.0.12 spec/support/logging_helpers.rb
omnibus-9.0.11 spec/support/logging_helpers.rb
omnibus-9.0.8 spec/support/logging_helpers.rb
omnibus-8.3.2 spec/support/logging_helpers.rb
omnibus-8.2.2 spec/support/logging_helpers.rb
omnibus-8.1.15 spec/support/logging_helpers.rb
omnibus-8.0.15 spec/support/logging_helpers.rb
omnibus-8.0.9 spec/support/logging_helpers.rb
omnibus-7.0.34 spec/support/logging_helpers.rb
omnibus-7.0.13 spec/support/logging_helpers.rb
omnibus-7.0.12 spec/support/logging_helpers.rb
omnibus-6.1.9 spec/support/logging_helpers.rb
omnibus-6.1.7 spec/support/logging_helpers.rb
omnibus-6.1.4 spec/support/logging_helpers.rb
omnibus-6.0.30 spec/support/logging_helpers.rb
omnibus-6.0.25 spec/support/logging_helpers.rb