In the case where things work, only one instance of Packages is created (early on when inventory.rb is loaded) and is shared across tests, which means there is the potential for state to leak across tests. In the case where things don't work, the call to Facter.reset unregisters the fact. So the next call to Facter.value('_puppet_inventory_1') will force the fact to be reloaded via Kernel.load. My theory is that rspec redefines a method on the class, but then the call to Kernel.load overwrites the rspec method, so rspec's hook is never called. I think we should just remove the call to Facter.reset like nick.burgan-illig suggested earlier. |