Sha256: 69ca6e0b2b5089c40d2e9909cd189e2cf42510c261c6d9e83c1dbf84bd44827e

Contents?: true

Size: 1.05 KB

Versions: 86

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/configs'
require 'eac_ruby_utils/templates/file'

RSpec.describe ::EacRubyUtils::Templates::File do
  let(:files_dir) { ::File.join(__dir__, 'file_spec_files') }
  let(:source_path) { ::File.join(files_dir, 'source.template') }
  let(:instance) { described_class.new(source_path) }
  let(:expected_content) { ::File.read(::File.join(files_dir, 'expected_content')) }

  describe '#apply' do
    context 'when config is a hash' do
      let(:config) { { name: 'Fulano de Tal', age: 33 } }

      it { expect(instance.apply(config)).to eq(expected_content) }
    end

    context 'when config responds to read_entry' do
      let(:config) { ::EacRubyUtils::Configs.new('rspec_describe_eac_ruby_utils_templates_file') }

      before do
        config.clear
        config['name'] = 'Fulano de Tal'
        config['age'] = '33'
      end

      it { expect(instance.apply(config)).to eq(expected_content) }
    end
  end

  describe '#variables' do
    it { expect(instance.variables).to eq(::Set.new(%w[name age])) }
  end
end

Version data entries

86 entries across 86 versions & 2 rubygems

Version Path
avm-tools-0.75.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.75.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.74.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.74.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.73.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.72.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.71.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.70.2 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
ehbrs-tools-0.15.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
ehbrs-tools-0.14.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.70.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.70.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.69.3 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
ehbrs-tools-0.14.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.69.2 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.69.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.69.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
ehbrs-tools-0.13.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.68.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.67.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb