diff options
author | Stig Sandbeck Mathisen <ssm@debian.org> | 2014-09-07 10:14:36 +0200 |
---|---|---|
committer | Stig Sandbeck Mathisen <ssm@debian.org> | 2014-09-07 10:14:36 +0200 |
commit | d4b83be375ac1dead058e091191ee7c7b7c24c8a (patch) | |
tree | dc825687392ae3068de5b764be60c53122d9e02a /spec/unit/settings/array_setting_spec.rb | |
parent | 229cbb976fe0f70f5f30548b83517b415840f9bb (diff) | |
parent | 1681684857c6e39d60d87b0b3520d8783977ceff (diff) | |
download | puppet-upstream/3.7.0.tar.gz |
Imported Upstream version 3.7.0upstream/3.7.0
Diffstat (limited to 'spec/unit/settings/array_setting_spec.rb')
-rw-r--r-- | spec/unit/settings/array_setting_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/unit/settings/array_setting_spec.rb b/spec/unit/settings/array_setting_spec.rb new file mode 100644 index 000000000..05cc28d6a --- /dev/null +++ b/spec/unit/settings/array_setting_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +require 'puppet/settings' +require 'puppet/settings/array_setting' + +describe Puppet::Settings::ArraySetting do + subject { described_class.new(:settings => stub('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 |