puppetlabs/puppet — pull request #2206 by fhrbek (2013-12-31 13:53:39+00:00)
Title: PUP-1321 ruby_manifest_spec does not test everything properly

This PR fixes the ruby manifest testing so that it would test certain things properly (see https://tickets.puppetlabs.com/browse/PUP-1321) and it also cleans the code.

Changes made:

1. The compile method can operate in two modes:
a) With contents specified - this resets the puppet code together with the cached environments
b) Without contents specified - this recompiles the recent contents without clearing the cache

2. The improved compilation method is used in the "should be properly cached for multiple compiles" test (making the code equivalent but simpler and easier to read)

3. The test "should be properly reloaded when stale" was fixed to that it would test what it was supposed to test:
- the "sleep 1" was removed since it's not needed when all files are considered as stale (thanks to file timeout set to -1)
- the second compilation is called without resetting Puppet[:code] since otherwise it cleared the cache and the test passed with any setting of the puppet file timeout, even when it was longer that the sleep

With the changes from this PR applied
- all tests pass
- the test "should be properly cached for multiple compiles" is simpler and cleaner
- the test "should be properly reloaded when stale" passes in its current form or if the file timeout is set to a smaller value than an eventual sleep, and fails if the file timeout is set to a positive value larger than an eventual sleep (or zero if there's no sleep)