diff options
| author | Markus Roberts <Markus@reality.com> | 2009-09-18 16:12:08 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-09-22 09:31:19 +1000 |
| commit | a5950339f43e08516130ff0b7463dbe3fa925890 (patch) | |
| tree | 3c1f4b60f2310e5133311433fe10f954e72e3d01 /spec | |
| parent | a951163d3d8a52fff4f0340b4ed1e827f2399147 (diff) | |
Fix for #2654 (error generating error message)
Since required_features can (and frequently does) return a single
item instead of an Array, the error message needed to be more robust.
The tests were not specific enough to catch the fact that an error
was being raised in the generation of the error, so a more specific
test was added and the required_features accessor test was beefed up
a little.
Signed-off-by: Markus Roberts <Markus@reality.com>
Signed-off-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/property.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/spec/unit/property.rb b/spec/unit/property.rb index 07ab9c319..26a5765a2 100755 --- a/spec/unit/property.rb +++ b/spec/unit/property.rb @@ -34,10 +34,12 @@ describe Puppet::Property do @class.should respond_to(:required_features=) end - it "should always convert required features into an array of symbols" do - @class.required_features = %w{one two} - @class.required_features.should == [:one, :two] - end + {"one" => [:one],:one => [:one],%w{a} => [:a],[:b] => [:b],%w{one two} => [:one,:two],[:a,:b] => [:a,:b]}.each { |in_value,out_value| + it "should always convert required features into an array of symbols (e.g. #{in_value.inspect} --> #{out_value.inspect})" do + @class.required_features = in_value + @class.required_features.should == out_value + end + } it "should be able to shadow metaparameters" do @property.must respond_to(:shadow) @@ -200,6 +202,14 @@ describe Puppet::Property do lambda { @property.should = :foo }.should raise_error(Puppet::Error) end + it "should internally raise an ArgumentError if required features are missing" do + @class.newvalue(:foo, :required_features => [:a, :b]) + + @provider.expects(:satisfies?).with([:a, :b]).returns false + + lambda { @property.validate_features_per_value :foo }.should raise_error(ArgumentError) + end + it "should validate that all required features are present for regexes" do value = @class.newvalue(/./, :required_features => [:a, :b]) |
