diff options
author | Ashley Penney <ashley.penney@puppetlabs.com> | 2014-03-05 15:43:58 -0500 |
---|---|---|
committer | Ashley Penney <ashley.penney@puppetlabs.com> | 2014-03-08 00:42:51 +0000 |
commit | 3854e076ccb75d1bcb1ddd29f5976b194d857765 (patch) | |
tree | 2624c5c96549324719fbf6eaca781888d6d4646d /spec/lib/puppet_spec/database.rb | |
parent | fecb53d46ed9e926973cdf5be1289c1ea71c2f68 (diff) | |
download | puppet-stdlib-3854e076ccb75d1bcb1ddd29f5976b194d857765.tar.gz puppet-stdlib-3854e076ccb75d1bcb1ddd29f5976b194d857765.tar.bz2 |
Numerous changes to update testing gems.
This work updates a number of Gems to the latest versions (rspec,
rspec-puppet), and updates and tweaks a bunch of tests to work
with the updated gems.
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 |