Skip to content

Instantly share code, notes, and snippets.

@maxlinc
Created June 21, 2013 19:33
Show Gist options
  • Save maxlinc/5833720 to your computer and use it in GitHub Desktop.
Save maxlinc/5833720 to your computer and use it in GitHub Desktop.
Record facts for any host, reuse within rspec-puppet
require 'spec_helper'
hosts = Dir['fixtures/facts/*.yaml'].map{|f| File.basename(f, '.yaml')}
hosts.each do |host|
describe host, :type => :host do
let (:facts) {
load_fact_fixtures host
}
# Rspec-puppet has not released the compile matchet yet - you'll need a Gem from master
it { should compile.with_all_deps }
end
end
def load_fact_fixtures(hostname)
YAML.load File.read("fixtures/facts/#{hostname}.yaml")
end
...
config.vm.provision :shell, :inline => "facter --yaml > /vagrant/fixtures/facts/$HOSTNAME.yaml"
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment