~ubuntu-branches/ubuntu/quantal/puppet/quantal

« back to all changes in this revision

Viewing changes to spec/lib/puppet_spec/database.rb

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-07-14 01:56:30 UTC
  • mfrom: (1.1.29) (3.1.43 sid)
  • Revision ID: package-import@ubuntu.com-20120714015630-ntj41rkvkq4zph4y
Tags: 2.7.18-1ubuntu1
* Resynchronise with Debian. (LP: #1023931) Remaining changes:
  - debian/puppetmaster-passenger.postinst: Make sure we error if puppet
    config print doesn't work
  - debian/puppetmaster-passenger.postinst: Ensure upgrades from
    <= 2.7.11-1 fixup passenger apache configuration.
* Dropped upstreamed patches:
  - debian/patches/CVE-2012-1906_CVE-2012-1986_to_CVE-2012-1989.patch
  - debian/patches/puppet-12844
  - debian/patches/2.7.17-Puppet-July-2012-CVE-fixes.patch
* Drop Build-Depends on ruby-rspec (in universe):
  - debian/control: remove ruby-rspec from Build-Depends
  - debian/patches/no-rspec.patch: make Rakefile work anyway if rspec
    isn't installed so we can use it in debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# This just makes some nice things available at global scope, and for setup of
 
2
# tests to use a real fake database, rather than a fake stubs-that-don't-work
 
3
# version of the same.  Fun times.
 
4
def sqlite?
 
5
  if $sqlite.nil?
 
6
    begin
 
7
      require 'sqlite3'
 
8
      $sqlite = true
 
9
    rescue LoadError
 
10
      $sqlite = false
 
11
    end
 
12
  end
 
13
  $sqlite
 
14
end
 
15
 
 
16
def can_use_scratch_database?
 
17
  sqlite? and Puppet.features.rails?
 
18
end
 
19
 
 
20
 
 
21
# This is expected to be called in your `before :each` block, and will get you
 
22
# ready to roll with a serious database and all.  Cleanup is handled
 
23
# automatically for you.  Nothing to do there.
 
24
def setup_scratch_database
 
25
  dir = PuppetSpec::Files.tmpdir('puppet-sqlite')
 
26
  Puppet[:dbadapter]    = 'sqlite3'
 
27
  Puppet[:dblocation]   = (dir + 'storeconfigs.sqlite').to_s
 
28
  Puppet[:railslog]     = '/dev/null'
 
29
  Puppet::Rails.init
 
30
end