File: array_setting_spec.rb

package info (click to toggle)
puppet-agent 7.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 19,092 kB
  • sloc: ruby: 245,074; sh: 456; makefile: 38; xml: 33
file content (39 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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