diff options
author | Hunter Haugen <hunter@puppetlabs.com> | 2014-03-18 16:16:00 -0700 |
---|---|---|
committer | Hunter Haugen <hunter@puppetlabs.com> | 2014-03-18 16:16:00 -0700 |
commit | 904f1a003e790ba2afaf3452ecda9805e87d80d0 (patch) | |
tree | 93407d68868c37af5d597d33134ba5a16e919a21 /spec/lib/puppet_spec/database.rb | |
parent | db00ce660520abfdc110d1ed0dd10bfbc708e256 (diff) | |
parent | fec943f441f0c6ab8d6b685091d3418ec0e265b4 (diff) | |
download | puppet-stdlib-904f1a003e790ba2afaf3452ecda9805e87d80d0.tar.gz puppet-stdlib-904f1a003e790ba2afaf3452ecda9805e87d80d0.tar.bz2 |
Merge branch '3.2.x' into 3.x
Diffstat (limited to 'spec/lib/puppet_spec/database.rb')
-rw-r--r-- | spec/lib/puppet_spec/database.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/lib/puppet_spec/database.rb b/spec/lib/puppet_spec/database.rb new file mode 100644 index 0000000..069ca15 --- /dev/null +++ b/spec/lib/puppet_spec/database.rb @@ -0,0 +1,29 @@ +# This just makes some nice things available at global scope, and for setup of +# tests to use a real fake database, rather than a fake stubs-that-don't-work +# version of the same. Fun times. +def sqlite? + if $sqlite.nil? + begin + require 'sqlite3' + $sqlite = true + rescue LoadError + $sqlite = false + end + end + $sqlite +end + +def can_use_scratch_database? + sqlite? and Puppet.features.rails? +end + + +# This is expected to be called in your `before :each` block, and will get you +# ready to roll with a serious database and all. Cleanup is handled +# automatically for you. Nothing to do there. +def setup_scratch_database + Puppet[:dbadapter] = 'sqlite3' + Puppet[:dblocation] = ':memory:' + Puppet[:railslog] = PuppetSpec::Files.tmpfile('storeconfigs.log') + Puppet::Rails.init +end |