diff options
author | Hunter Haugen <hunter@puppetlabs.com> | 2014-03-18 16:18:53 -0700 |
---|---|---|
committer | Hunter Haugen <hunter@puppetlabs.com> | 2014-03-18 16:18:53 -0700 |
commit | aedb89d91fe6737b3ed7acc0aa72c9a2fa56cd45 (patch) | |
tree | 9cefab4ff6e6a33c84482e11e0fae929018303db /spec/lib/puppet_spec/database.rb | |
parent | 085a0564428d49a027af0fc224fb4019fba54862 (diff) | |
parent | 904f1a003e790ba2afaf3452ecda9805e87d80d0 (diff) | |
download | puppet-stdlib-aedb89d91fe6737b3ed7acc0aa72c9a2fa56cd45.tar.gz puppet-stdlib-aedb89d91fe6737b3ed7acc0aa72c9a2fa56cd45.tar.bz2 |
Merge branch '3.x' into 4.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 |