Sha256: 6515339623ca5e612922d7f1e9f04f2bf25bd6ff027beebb6b81e02fb696a7e3

Contents?: true

Size: 1.69 KB

Versions: 13

Compression:

Stored size: 1.69 KB

Contents

# Encoding: utf-8
require 'spec_helper'

RSpec.describe Packer::PostProcessor do
  POSTPROCESSOR_TYPE = 'vagrant'

  let(:postprocessor) do
    Packer::PostProcessor.new
  end

  let(:overrides) do
    {
      "key1" => "value1",
      "key2" => "value2"
    }
  end

  describe '.get_postprocessor' do
    it 'returns a post-processor' do
      expect(Packer::PostProcessor.get_postprocessor(POSTPROCESSOR_TYPE)).to be_a_kind_of(Packer::PostProcessor)
    end

    it 'raises an error when the post-processor type is not recognized' do
      expect { Packer::PostProcessor.get_postprocessor('unknown-type') }.to raise_error
    end
  end

  describe '#only' do
    it 'adds an only exception' do
      postprocessor.only('thing1')
      expect(postprocessor.data['only']).to eq(%w[thing1])
      postprocessor.only('thing2')
      expect(postprocessor.data['only']).to eq(%w[thing1 thing2])
    end
  end

  describe '#except' do
    it 'adds an execpt exception' do
      postprocessor.except('thing3')
      expect(postprocessor.data['except']).to eq(%w[thing3])
      postprocessor.except('thing4')
      expect(postprocessor.data['except']).to eq(%w[thing3 thing4])
    end
  end

  describe '#keep_input_artifact' do
    it 'accepts any truthy value and converts it to true' do
      postprocessor.keep_input_artifact('this is true')
      expect(postprocessor.data['keep_input_artifact']).to be_truthy
      postprocessor.data.delete('keep_input_artifact')
    end

    it 'accepts any non-truthy value and converts it to false' do
      postprocessor.keep_input_artifact(false)
      expect(postprocessor.data['keep_input_artifact']).to be_falsey
      postprocessor.data.delete('keep_input_artifact')
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
packer-config-1.6.5 spec/packer/postprocessor_spec.rb
packer-config-1.6.4 spec/packer/postprocessor_spec.rb
packer-config-1.6.3 spec/packer/postprocessor_spec.rb
packer-config-1.6.2 spec/packer/postprocessor_spec.rb
packer-config-1.6.1 spec/packer/postprocessor_spec.rb
packer-config-1.6.0 spec/packer/postprocessor_spec.rb
packer-config-1.5.0 spec/packer/postprocessor_spec.rb
packer-config-1.4.0 spec/packer/postprocessor_spec.rb
packer-config-1.3.1 spec/packer/postprocessor_spec.rb
packer-config-1.3.0 spec/packer/postprocessor_spec.rb
packer-config-1.2.0 spec/packer/postprocessor_spec.rb
packer-config-1.1.0 spec/packer/postprocessor_spec.rb
packer-config-1.0.0 spec/packer/postprocessor_spec.rb