sethvargo/chefspec — pull request #426 by dougbarth (2014-05-01 04:45:13+00:00)
Title: Stop leaking LWRP Resource classes

Chef::Resource retains a reference to all subclasses in
Chef::Resource.resource_classes. When an LWRP is reloaded, Chef's
implementation will remove the reference to the old class from that
array.

Unfortunately, ChefSpec is wrapping the build_from_file methods to
suppress a warning about LWRP classes being redefined. By removing the
constants for those classes, it is causing Chef's cleanup code to not be
executed.

Since I assume the wrapping logic is there to support older versions of
Chef (removing the wrapping logic on Chef::Resource does not show a
warning with Chef 11.12.2), I opted to perform the same cleanup that
Chef does in its own implementation.

Retaining the reference to old LWRP classes can cause lots of state from
previous ChefSpec::Runner instances to remain in memory, bloating the
test suite process size and slowing down garbage collection.