munge symbol fact names to strings

This commit is contained in:
Tim Sharpe 2011-08-29 14:41:37 +12:00
parent c2fd88f249
commit 26920e9cb5
3 changed files with 12 additions and 2 deletions

View File

@ -36,7 +36,11 @@ module RSpec::Puppet
Puppet[:code] = pre_cond + "\n" + Puppet[:code]
nodename = self.respond_to?(:node) ? node : Puppet[:certname]
facts_val = self.respond_to?(:facts) ? facts : {}
facts_val = {
'hostname' => nodename.split('.').first,
'fqdn' => nodename,
}
facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
build_catalog(nodename, facts_val)
end

View File

@ -42,7 +42,7 @@ module RSpec::Puppet
'hostname' => nodename.split('.').first,
'fqdn' => nodename,
}
facts_val.merge!(facts) if self.respond_to?(:facts)
facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
build_catalog(nodename, facts_val)
end

View File

@ -12,5 +12,11 @@ module RSpec::Puppet
Puppet::Resource::Catalog.indirection.find(node_obj.name, :use_node => node_obj)
end
end
def munge_facts(facts)
output = {}
facts.keys.each { |key| output[key.to_s] = facts[key] }
output
end
end
end