Sha256: b4b0146c055068876f65414c66d298037f65324fc52632c84fbdb5777980dd7c

Contents?: true

Size: 696 Bytes

Versions: 3

Compression:

Stored size: 696 Bytes

Contents

module Helper
  def fixture_path(*components)
    base_dir = File.expand_path(__dir__)
    File.join(base_dir, "fixture", *components)
  end

  class CaptureLogger
    def initialize(output)
      @output = output
    end

    def error(message=nil)
      @output << [:error, message || yield]
    end
  end

  def capture_log
    original_logger = ChupaText.logger
    begin
      output = []
      ChupaText.logger = CaptureLogger.new(output)
      yield
      normalize_log(output)
    ensure
      ChupaText.logger = original_logger
    end
  end

  def normalize_log(log)
    log.collect do |level, message|
      message = message.split("\n", 2)[0]
      [level, message]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chupa-text-decomposer-spreadsheet-1.0.6 test/helper.rb
chupa-text-decomposer-spreadsheet-1.0.5 test/helper.rb
chupa-text-decomposer-spreadsheet-1.0.4 test/helper.rb