]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/lib/puppet_spec/database.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / lib / puppet_spec / database.rb
1 #! /usr/bin/env ruby -S rspec
2 # This just makes some nice things available at global scope, and for setup of
3 # tests to use a real fake database, rather than a fake stubs-that-don't-work
4 # version of the same.  Fun times.
5 def sqlite?
6   if $sqlite.nil?
7     begin
8       require 'sqlite3'
9       $sqlite = true
10     rescue LoadError
11       $sqlite = false
12     end
13   end
14   $sqlite
15 end
16
17 def can_use_scratch_database?
18   sqlite? and Puppet.features.rails?
19 end
20
21
22 # This is expected to be called in your `before :each` block, and will get you
23 # ready to roll with a serious database and all.  Cleanup is handled
24 # automatically for you.  Nothing to do there.
25 def setup_scratch_database
26   Puppet[:dbadapter] = 'sqlite3'
27   Puppet[:dblocation] = ':memory:'
28   Puppet[:railslog] = PuppetSpec::Files.tmpfile('storeconfigs.log')
29   Puppet::Rails.init
30 end