From 3854e076ccb75d1bcb1ddd29f5976b194d857765 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 5 Mar 2014 15:43:58 -0500 Subject: 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. --- spec/lib/puppet_spec/database.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 spec/lib/puppet_spec/database.rb (limited to 'spec/lib/puppet_spec/database.rb') 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 -- cgit v1.2.3