diff options
author | Andrew Shafer <andrew@reductivelabs.com> | 2008-12-01 00:07:04 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-12-01 20:52:04 +1100 |
commit | fa9820baaebe29675defb14bc9d64f6cb9b75211 (patch) | |
tree | bb8720b1f2520f7c6b446000c1f9bdcde05252f5 /spec/unit/property | |
parent | f6fa4f7b8c85303dd801fa6e4c5f47845af53c54 (diff) | |
download | puppet-fa9820baaebe29675defb14bc9d64f6cb9b75211.tar.gz puppet-fa9820baaebe29675defb14bc9d64f6cb9b75211.tar.xz puppet-fa9820baaebe29675defb14bc9d64f6cb9b75211.zip |
Bug #1778 - Solaris RBAC profiles should maintain order
Created OrderedList property
Added to profile property
small refactor in List to make inheriting easier
Diffstat (limited to 'spec/unit/property')
-rw-r--r-- | spec/unit/property/list.rb | 9 | ||||
-rw-r--r-- | spec/unit/property/ordered_list.rb | 64 |
2 files changed, 73 insertions, 0 deletions
diff --git a/spec/unit/property/list.rb b/spec/unit/property/list.rb index 9c832c0cd..2fab868db 100644 --- a/spec/unit/property/list.rb +++ b/spec/unit/property/list.rb @@ -143,5 +143,14 @@ describe list_class do @property.insync?(["bar","foo"]).must == false end end + + describe "when calling dearrayify" do + it "should sort and join the array with 'delimiter'" do + array = mock "array" + array.expects(:sort).returns(array) + array.expects(:join).with(@property.delimiter) + @property.dearrayify(array) + end + end end end diff --git a/spec/unit/property/ordered_list.rb b/spec/unit/property/ordered_list.rb new file mode 100644 index 000000000..51c59a7dd --- /dev/null +++ b/spec/unit/property/ordered_list.rb @@ -0,0 +1,64 @@ +#!/usr/bin/env ruby + +Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } + +require 'puppet/property/ordered_list' + +ordered_list_class = Puppet::Property::OrderedList + +describe ordered_list_class do + + it "should be a subclass of List" do + ordered_list_class.superclass.must == Puppet::Property::List + end + + describe "as an instance" do + before do + # Wow that's a messy interface to the resource. + ordered_list_class.initvars + @resource = stub 'resource', :[]= => nil, :property => nil + @property = ordered_list_class.new(:resource => @resource) + end + + describe "when adding should to current" do + it "should add the arrays when current is an array" do + @property.add_should_with_current(["should"], ["current"]).should == ["should", "current"] + end + + it "should return 'should' if current is not a array" do + @property.add_should_with_current(["should"], :absent).should == ["should"] + end + + it "should return only the uniq elements leading with the order of 'should'" do + @property.add_should_with_current(["this", "is", "should"], ["is", "this", "current"]).should == ["this", "is", "should", "current"] + end + end + + describe "when calling should" do + it "should return nil if @should is nil" do + @property.should.must == nil + end + + it "should return the values of @should (without sorting) as a string if inclusive" do + @property.should = ["foo", "bar"] + @property.expects(:inclusive?).returns(true) + @property.should.must == "foo,bar" + end + + it "should return the uniq values of @should + retrieve as a string if !inclusive with the @ values leading" do + @property.should = ["foo", "bar"] + @property.expects(:inclusive?).returns(false) + @property.expects(:retrieve).returns(["foo","baz"]) + @property.should.must == "foo,bar,baz" + end + end + + describe "when calling dearrayify" do + it "should join the array with the delimiter" do + array = mock "array" + array.expects(:join).with(@property.delimiter) + @property.dearrayify(array) + end + end + end +end |