In a fact Im calling
Puppet::Type('user').instances.select do |user|
#do something with user
end
How can I stub that in a spec test? I have something like:
Puppet::Type.type(:user).stubs(:instances).returns(
'User[root]','User[bin]'])
but that stubs it with an array and not a User object. How can I stub it correctly?
The solution was to ensure that the return value was a user object. I did that by:
user1=Puppet::Type::type(:user).new( name: 'root', ensure: 'present')
Puppet::Type.type(:user).stubs(:instances).returns([user1])