Sha256: 087ff49aeafad28fe045be5b85467a40259997102069bf1a7426dba52c76eb06

Contents?: true

Size: 929 Bytes

Versions: 2

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true

require 'avm/file_formats/search_formatter'
require 'eac_ruby_utils/core_ext'

::RSpec.shared_examples 'avm_file_formats_with_fixtures' do |the_spec_file|
  include_examples 'source_target_fixtures', the_spec_file

  def format_files_in_directory(target_dir)
    ::Avm::FileFormats::SearchFormatter
      .new([target_dir], recursive: true, apply: true, verbose: false)
      .run
  end

  def source_data(source_file)
    dir = temp_dir
    source_basename = source_file_basename_without_source_extname(source_file)
    source_path = dir.join(source_basename)
    ::FileUtils.cp(source_file, source_path)
    format_files_in_directory(dir)
    source_path.read
  end

  def source_file_basename_without_source_extname(source_file)
    source_file.to_pathname.basename_sub { |b| b.to_path.gsub(/\.source/, '') }.basename
  end

  def target_data(target_file)
    ::File.read(target_file)
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
avm-0.84.0 lib/avm/rspec/shared_examples/avm_file_formats_with_fixtures.rb
eac_tools-0.83.0 sub/avm/lib/avm/rspec/shared_examples/avm_file_formats_with_fixtures.rb