Sha256: 1bbdfd4ff8666f0de49b8733414d9581eea841e90bfd24a24e5f95e9cf6ebf62

Contents?: true

Size: 695 Bytes

Versions: 9

Compression:

Stored size: 695 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 StandardError
        puts raw_logs
        raise
      end

      def raw_logs
        STREAM.string
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kiev-4.9.0 lib/kiev/test.rb
kiev-4.8.3 lib/kiev/test.rb
kiev-4.8.2 lib/kiev/test.rb
kiev-4.8.1 lib/kiev/test.rb
kiev-4.8.0 lib/kiev/test.rb
kiev-4.7.0 lib/kiev/test.rb
kiev-4.6.0 lib/kiev/test.rb
kiev-4.5.0 lib/kiev/test.rb
kiev-4.4.0 lib/kiev/test.rb