diff --git a/lib/voxpupuli/test/spec_helper.rb b/lib/voxpupuli/test/spec_helper.rb index 7f15ed7..ccc3518 100644 --- a/lib/voxpupuli/test/spec_helper.rb +++ b/lib/voxpupuli/test/spec_helper.rb @@ -28,6 +28,15 @@ def suggest_facter_version require 'rspec-puppet-facts' include RspecPuppetFacts +# Generating facts is slow - this memoizes the facts between multiple classes. +# Marshalling is used to get unique instances which helps when tests overrides +# facts. +FACTS_CACHE = {} +def on_supported_os(opts = {}) + result = FACTS_CACHE[opts.to_s] ||= super(opts) + Marshal.load(Marshal.dump(result)) +end + RSpec.configure do |config| config.default_facter_version = suggest_facter_version