Adding tests for the user retrieve method

Signed-off-by: Luke Kanies <luke@madstop.com>
This commit is contained in:
Luke Kanies 2008-09-30 18:08:55 -05:00
Родитель 679fede620
Коммит 2afc4f5f15
2 изменённых файлов: 25 добавлений и 2 удалений

Просмотреть файл

@ -272,7 +272,7 @@ module Puppet
current_value = :absent current_value = :absent
if absent if absent
prophash[property] = :absent prophash[property] = :absent
else else
current_value = property.retrieve current_value = property.retrieve
prophash[property] = current_value prophash[property] = current_value
@ -280,7 +280,6 @@ module Puppet
if property.name == :ensure and current_value == :absent if property.name == :ensure and current_value == :absent
absent = true absent = true
# next
end end
prophash prophash
} }

Просмотреть файл

@ -48,6 +48,30 @@ describe user do
end end
end end
describe "when retrieving all current values" do
before do
@user = user.create(:name => "foo", :uid => 10, :gid => 10)
@properties = {}
end
it "should return a hash containing values for all set properties" do
values = @user.retrieve
[@user.property(:uid), @user.property(:gid)].each { |property| values.should be_include(property) }
end
it "should set all values to :absent if the user is absent" do
@user.property(:ensure).expects(:retrieve).returns :absent
@user.property(:uid).expects(:retrieve).never
@user.retrieve[@user.property(:uid)].should == :absent
end
it "should include the result of retrieving each property's current value if the user is present" do
@user.property(:ensure).expects(:retrieve).returns :present
@user.property(:uid).expects(:retrieve).returns 15
@user.retrieve[@user.property(:uid)].should == 15
end
end
describe "when managing the ensure property" do describe "when managing the ensure property" do
before do before do
@ensure = user.attrclass(:ensure).new(:resource => @resource) @ensure = user.attrclass(:ensure).new(:resource => @resource)