Sha256: 44e5b2d0a024448cb96b863a7957f0c751768e58ab24b3fdea3b9ec9d0fa5144

Contents?: true

Size: 963 Bytes

Versions: 3

Compression:

Stored size: 963 Bytes

Contents

# frozen_string_literal: true

require 'minitest/autorun'
require 'minitest/spec'
require 'minitest/unit'
require 'mocha/mini_test'
require 'pdf/inspector'

require 'digest/sha1'
require 'pathname'
require 'thinreports'

require 'schema_helper'

module Thinreports::TestHelper
  ROOT = Pathname.new(File.expand_path('..', __FILE__))

  include Thinreports::SchemaHelper

  def assert_deprecated(&block)
    _out, err = capture_io { block.call }
    assert err.to_s.include?('[DEPRECATION]')
  end

  def data_file(*paths)
    ROOT.join('data', *paths).to_s
  end

  def read_data_file(*paths)
    File.read(data_file(*paths))
  end

  def temp_path
    ROOT.join('tmp')
  end

  def analyze_pdf_images(pdf_data)
    analyzer = PDF::Inspector::XObject.analyze(pdf_data)
    analyzer.page_xobjects
      .reduce(:merge).values
      .select { |o| o.hash[:Subtype] == :Image }
  end

  def teardown
    super
    FileUtils.rm Dir.glob(temp_path.join('*'))
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.10.2 test/test_helper.rb
thinreports-0.10.1 test/test_helper.rb
thinreports-0.10.0 test/test_helper.rb