Sha256: 1f9ea7b8fa75d42aae733d30810c07290580fdee0aed8b7245b650cca1f5b44e

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require 'eac_config/old_configs'
require 'eac_templates/variables/file'

RSpec.describe EacTemplates::Variables::Content do
  let(:files_dir) { File.join(__dir__, 'content_spec_files').to_pathname }
  let(:source_path) { files_dir.join('source.template') }
  let(:instance) { described_class.from_file(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) { EacConfig::OldConfigs.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

2 entries across 2 versions & 1 rubygems

Version Path
eac_tools-0.93.0 sub/eac_templates/spec/lib/eac_templates/variables/content_spec.rb
eac_tools-0.91.0 sub/eac_templates/spec/lib/eac_templates/variables/content_spec.rb