Permalink
Browse files

Cache the result of build_catalog

  • Loading branch information...
1 parent eed11c7 commit 4ae3e45af78d230b4a046ada8480e9a7ae2cd3e3 @fungusakafungus fungusakafungus committed Jul 31, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/rspec-puppet/support.rb
View
11 lib/rspec-puppet/support.rb
@@ -1,6 +1,10 @@
module RSpec::Puppet
module Support
- def build_catalog nodename, facts_val
+
+ @@cache = {}
+
+ protected
+ def build_catalog_without_cache nodename, facts_val
node_obj = Puppet::Node.new(nodename)
node_obj.merge(facts_val)
@@ -13,6 +17,11 @@ def build_catalog nodename, facts_val
end
end
+ public
+ def build_catalog *args
+ @@cache[args] ||= self.build_catalog_without_cache(*args)
+ end
+
def munge_facts(facts)
output = {}
facts.keys.each { |key| output[key.to_s] = facts[key] }

0 comments on commit 4ae3e45

Please sign in to comment.