Sha256: 55b06236c7d34675df1f473fb8a2a207ea2c6060630bb623d9e54da7291bc754

Contents?: true

Size: 1017 Bytes

Versions: 6

Compression:

Stored size: 1017 Bytes

Contents

require 'xlsxwriter'
require_relative './support/xlsx_comparable'

class XlsxWriterTestCaseConfig
  attr_accessor :ignore_elements, :ignore_files
  def initialize
    @ignore_elements = {}
    @ignore_files = []
  end
end

class XlsxWriterTestCase < Test::Unit::TestCase
  include XlsxComparable

  def self.test(name, opts=nil, &block)
    define_method(:"test_#{name}") do
      file_path = "tmp/#{name}.xlsx"
      ref_file_path = "ext/xlsxwriter/libxlsxwriter/test/functional/xlsx_files/#{name}.xlsx"
      begin
        tc = XlsxWriterTestCaseConfig.new
        args = [file_path, opts].compact
        XlsxWriter::Workbook.open(*args) do |wb|
          yield wb, tc
        end

        assert_xlsx_equal file_path, ref_file_path, tc.ignore_files, tc.ignore_elements
      ensure
        File.delete file_path if File.exist? file_path
      end
    end
  end

  def self.image_path(path)
    File.expand_path(File.join('../../ext/xlsxwriter/libxlsxwriter/test/functional/src/images', path), __FILE__)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
xlsxwriter-0.0.6 test/xlsx-func-testcase.rb
xlsxwriter-0.0.5 test/xlsx-func-testcase.rb
xlsxwriter-0.0.4 test/xlsx-func-testcase.rb
xlsxwriter-0.0.4.pre.2 test/xlsx-func-testcase.rb
xlsxwriter-0.0.3 test/xlsx-func-testcase.rb
xlsxwriter-0.0.2 test/xlsx-func-testcase.rb