Sha256: be815d321d6dc2fffc77ca85a7ac1899fa097fd32b9563d54fda88fa27f5a0cf

Contents?: true

Size: 680 Bytes

Versions: 6

Compression:

Stored size: 680 Bytes

Contents

# frozen_string_literal: true

require "json"

module Kiev
  # Test helpers for testing both Kiev itself and products that use it.
  module Test
    module Log
      STREAM = StringIO.new

      module_function

      def configure
        @logs = []
        Kiev.configure do |c|
          c.log_path = STREAM
        end
      end

      def clear
        STREAM.rewind
        STREAM.truncate(0)
        @logs = []
      end

      def entries
        return @logs unless @logs.empty?
        @logs = raw_logs.each_line.map(&::JSON.method(:parse))
      rescue
        puts raw_logs
        raise
      end

      def raw_logs
        STREAM.string
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kiev-4.3.0 lib/kiev/test.rb
kiev-4.2.0 lib/kiev/test.rb
kiev-4.1.0 lib/kiev/test.rb
kiev-4.0.0 lib/kiev/test.rb
kiev-3.0.0 lib/kiev/test.rb
kiev-2.8.0 lib/kiev/test.rb