Sha256: f593c7d3cb47f151118e57b543962a71b2d0b937c8f9b735eb267a1190d59fce

Contents?: true

Size: 835 Bytes

Versions: 6

Compression:

Stored size: 835 Bytes

Contents

#! /usr/bin/env ruby -S rspec
# 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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puppet-retrospec-0.12.1 spec/fixtures/modules/stdlib/spec/lib/puppet_spec/database.rb
puppet-retrospec-0.12.0 spec/fixtures/modules/stdlib/spec/lib/puppet_spec/database.rb
puppet-retrospec-0.11.0 spec/fixtures/modules/stdlib/spec/lib/puppet_spec/database.rb
puppet-retrospec-0.10.0 spec/fixtures/modules/stdlib/spec/lib/puppet_spec/database.rb
puppet-retrospec-0.9.1 spec/fixtures/modules/stdlib/spec/lib/puppet_spec/database.rb
puppet-retrospec-0.9.0 spec/fixtures/modules/stdlib/spec/lib/puppet_spec/database.rb