Sha256: 0f7223cff17c20c40b59fc89e96f47048e8ebcc2db2a7dbd9e8e34904290f0dd

Contents?: true

Size: 1.52 KB

Versions: 46

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require 'avm/tools/runner'
require 'aranha/parsers/source_target_fixtures'
require 'eac_ruby_utils/fs/temp'
require 'fileutils'

::RSpec.describe ::Avm::Tools::Runner::Files::Format do
  before(:all) do # rubocop:disable RSpec/BeforeAfterAll
    source_files = copy_to_target_dir(source_stf.source_files) { |b| b.gsub(/\.source\Z/, '') }
    ::Avm::Tools::Runner.run(argv: ['files', 'format', '--apply',
                                    source_target_fixtures.fixtures_directory])
    copy_to_target_dir(source_stf.target_files)
    source_files.each { |source_file| ::FileUtils.mv(source_file, source_file + '.source') }
  end

  after(:all) do # rubocop:disable RSpec/BeforeAfterAll
    target_dir.remove
  end

  include_examples 'source_target_fixtures', __FILE__

  def source_stf
    @source_stf ||= ::Aranha::Parsers::SourceTargetFixtures.new(
      ::File.join(__dir__, 'format_spec_files')
    )
  end

  def target_dir
    @target_dir ||= ::EacRubyUtils::Fs::Temp.directory
  end

  def fixtures_dir
    target_dir.to_path
  end

  def source_data(source_file)
    ::File.read(source_file)
  end

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

  private

  def copy_to_target_dir(files, &block)
    files.map do |file|
      target_basename = ::File.basename(file)
      target_basename = block.call(target_basename) if block
      target_path = ::File.join(source_target_fixtures.fixtures_directory, target_basename)
      ::FileUtils.cp(file, target_path)
      target_path
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
eac_tools-0.37.2 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.37.1 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.37.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.36.1 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.36.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.35.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.34.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.33.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.32.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.31.1 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.31.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.30.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.29.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.28.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.27.2 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.27.1 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.27.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.26.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.25.1 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb
eac_tools-0.25.0 sub/avm-tools/spec/lib/avm/tools/runner/files/format_spec.rb