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.86.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.85.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.85.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
ehbrs-tools-0.16.5 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.84.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.83.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
ehbrs-tools-0.16.4 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.82.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.82.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.81.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
ehbrs-tools-0.16.3 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.80.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.79.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.78.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
ehbrs-tools-0.16.2 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.77.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
ehbrs-tools-0.16.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.76.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
ehbrs-tools-0.16.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb
avm-tools-0.76.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb