Sha256: b8fcb3752bb06d572481eb3ef6cd587eb049ff4999912f6f1622d4ed15b09719

Contents?: true

Size: 811 Bytes

Versions: 2

Compression:

Stored size: 811 Bytes

Contents

require 'fileutils'
module Mp4Renamer
  class FixtureHelper
    attr_reader :fixture_files,
                :fixtures_dir,
                :sample_files

    def initialize
      @fixtures_dir  = File.expand_path("../../../../fixtures", __FILE__)
      @fixture_files = %w(01.mp4 02.m4a).map { |file| [fixtures_dir, file].join(File::SEPARATOR) }
      @sample_files  = fixture_files.map { |file| sample_file(file) }
    end

    def setup
      fixture_files.each do |file|
        FileUtils.cp file, sample_file(file)
      end
    end

    def teardown
      fixture_files.each do |file|
        FileUtils.rm_rf sample_file(file)
      end
    end

    private

    def sample_file(file)
      [fixtures_dir, "sample_#{File.basename(file, '.*')}#{File.extname(file)}"].join(File::SEPARATOR)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mp4_renamer-0.1.3 test/lib/mp4_renamer/fixture_helper.rb
mp4_renamer-0.1.2 test/lib/mp4_renamer/fixture_helper.rb