Sha256: b7c973193fee447dd7feb1668394de0e0aaddc2d0daea45d45443ec7c2802888

Contents?: true

Size: 861 Bytes

Versions: 9

Compression:

Stored size: 861 Bytes

Contents

# 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::Rails.stubs(:database_arguments).returns(
    :adapter => 'sqlite3',
    :log_level => Puppet[:rails_loglevel],
    :database => ':memory:'
  )
  Puppet[:railslog]     = '/dev/null'
  Puppet::Rails.init
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
puppet-2.7.26 spec/lib/puppet_spec/database.rb
puppet-2.7.25 spec/lib/puppet_spec/database.rb
puppet-2.7.24 spec/lib/puppet_spec/database.rb
puppet-2.7.23 spec/lib/puppet_spec/database.rb
puppet-2.7.22 spec/lib/puppet_spec/database.rb
puppet-2.7.21 spec/lib/puppet_spec/database.rb
puppet-2.7.20 spec/lib/puppet_spec/database.rb
puppet-2.7.20.rc1 spec/lib/puppet_spec/database.rb
puppet-2.7.19 spec/lib/puppet_spec/database.rb