Sha256: 065bae3c248f70d574f2d84842a3f4e9f16dbf8fb8235c62de8ce120a09d62dc

Contents?: true

Size: 1.07 KB

Versions: 340

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

require 'puppet/settings'
require 'puppet/settings/array_setting'

describe Puppet::Settings::ArraySetting do
  subject { described_class.new(:settings => double('settings'), :desc => "test") }

  it "is of type :array" do
    expect(subject.type).to eq :array
  end

  describe "munging the value" do
    describe "when given a string" do
      it "splits multiple values into an array" do
        expect(subject.munge("foo,bar")).to eq %w[foo bar]
      end
      it "strips whitespace between elements" do
        expect(subject.munge("foo , bar")).to eq %w[foo bar]
      end

      it "creates an array when one item is given" do
        expect(subject.munge("foo")).to eq %w[foo]
      end
    end

    describe "when given an array" do
      it "returns the array" do
        expect(subject.munge(%w[foo])).to eq %w[foo]
      end
    end

    it "raises an error when given an unexpected object type" do
        expect {
          subject.munge({:foo => 'bar'})
        }.to raise_error(ArgumentError, "Expected an Array or String, got a Hash")
    end
  end
end

Version data entries

340 entries across 340 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/unit/settings/array_setting_spec.rb
puppet-8.3.0-x86-mingw32 spec/unit/settings/array_setting_spec.rb
puppet-8.3.0-x64-mingw32 spec/unit/settings/array_setting_spec.rb
puppet-8.3.0-universal-darwin spec/unit/settings/array_setting_spec.rb
puppet-8.4.0 spec/unit/settings/array_setting_spec.rb
puppet-8.4.0-x86-mingw32 spec/unit/settings/array_setting_spec.rb
puppet-8.4.0-x64-mingw32 spec/unit/settings/array_setting_spec.rb
puppet-8.4.0-universal-darwin spec/unit/settings/array_setting_spec.rb
puppet-7.28.0 spec/unit/settings/array_setting_spec.rb
puppet-7.28.0-x86-mingw32 spec/unit/settings/array_setting_spec.rb
puppet-7.28.0-x64-mingw32 spec/unit/settings/array_setting_spec.rb
puppet-7.28.0-universal-darwin spec/unit/settings/array_setting_spec.rb
puppet-8.3.1 spec/unit/settings/array_setting_spec.rb
puppet-8.3.1-x86-mingw32 spec/unit/settings/array_setting_spec.rb
puppet-8.3.1-x64-mingw32 spec/unit/settings/array_setting_spec.rb
puppet-8.3.1-universal-darwin spec/unit/settings/array_setting_spec.rb
puppet-7.27.0 spec/unit/settings/array_setting_spec.rb
puppet-7.27.0-x86-mingw32 spec/unit/settings/array_setting_spec.rb
puppet-7.27.0-x64-mingw32 spec/unit/settings/array_setting_spec.rb
puppet-7.27.0-universal-darwin spec/unit/settings/array_setting_spec.rb