Sha256: df55cee4d539d4734bb86737fef81037b15c3e037c7ff7e688b3eace4e8e13f5
Contents?: true
Size: 1.53 KB
Versions: 8
Compression:
Stored size: 1.53 KB
Contents
require 'test_helper' require 'review/makerhelper' require 'tmpdir' require 'fileutils' class MakerHelperTest < Test::Unit::TestCase include ReVIEW def setup @tmpdir1 = Dir.mktmpdir @tmpdir2 = Dir.mktmpdir end def teardown FileUtils.rm_rf(@tmpdir1) FileUtils.rm_rf(@tmpdir2) end def test_copy_images_to_dir types = %w[png gif jpg jpeg svg pdf eps] types.each { |type| touch_file(File.join(@tmpdir1, "foo.#{type}")) } FileUtils.mkdir(File.join(@tmpdir1, 'subdir')) touch_file(File.join(@tmpdir1, 'subdir/foo.png')) image_files = MakerHelper.copy_images_to_dir(@tmpdir1, @tmpdir2) types.each do |type| assert File.exist?(File.join(@tmpdir2, "foo.#{type}")), "Copying #{type} file failed" assert image_files.include?(File.join(@tmpdir1, "foo.#{type}")) end assert File.exist?(File.join(@tmpdir2, 'subdir/foo.png')), 'Copying a image file in a subdirectory' assert image_files.include?(File.join(@tmpdir1, 'subdir/foo.png')) end def test_copy_images_to_dir_with_exts types = %w[png gif jpg jpeg svg pdf eps] types4epub = %w[png gif jpg jpeg svg] types.each { |type| touch_file(File.join(@tmpdir1, "foo.#{type}")) } image_files = MakerHelper.copy_images_to_dir(@tmpdir1, @tmpdir2, exts: types4epub) types4epub.each { |type| assert image_files.include?(File.join(@tmpdir1, "foo.#{type}")), "foo.#{type} is not included" } (types - types4epub).each { |type| assert !image_files.include?(File.join(@tmpdir1, "foo.#{type}")), "foo.#{type} is included" } end end
Version data entries
8 entries across 8 versions & 1 rubygems