From e3f1f3b9c71bd55e778104cdbd9d27f157159da3 Mon Sep 17 00:00:00 2001 From: Joost Baaij Date: Thu, 18 Aug 2011 10:42:03 +0200 Subject: [PATCH] yank out the DB options and only use in-memory SQLite --- .gitignore | 1 - DEVELOPMENT.rdoc | 9 +++++++-- spec/support/database.rb | 38 +++++++------------------------------- 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 433d95f..466c187 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ Gemfile.lock pkg/* .rvmrc -spec/db/database.yml diff --git a/DEVELOPMENT.rdoc b/DEVELOPMENT.rdoc index eb02bfa..9678604 100644 --- a/DEVELOPMENT.rdoc +++ b/DEVELOPMENT.rdoc @@ -7,5 +7,10 @@ To get started, also no surprises: 1. gem install bundler (if you haven't already) 2. bundle -3. cp spec/db/database.yml.example spec/db/database.yml -4. rake \ No newline at end of file +4. rake + + +== Database + +SimpleSolr uses an in-memory SQLite database. This is more to satisfy +ActiveRecord than for SimpleSolr, but it's so fast it does not matter. \ No newline at end of file diff --git a/spec/support/database.rb b/spec/support/database.rb index b6a93c6..1899c27 100644 --- a/spec/support/database.rb +++ b/spec/support/database.rb @@ -1,33 +1,9 @@ -require 'yaml' +# Create schema and load the models +ActiveRecord::Base.establish_connection({:adapter => "sqlite3", :database => ":memory:"}) -ENV['DB'] ||= 'sqlite3' +ActiveRecord::Base.silence do + ActiveRecord::Migration.verbose = false -database_yml = File.expand_path('../../db/database.yml', __FILE__) -if File.exists?(database_yml) - active_record_configuration = YAML.load_file(database_yml)[ENV['DB']] - - ActiveRecord::Base.establish_connection(active_record_configuration) - - ActiveRecord::Base.silence do - ActiveRecord::Migration.verbose = false - - load(File.dirname(__FILE__) + '/../db/schema.rb') - load(File.dirname(__FILE__) + '/../db/models.rb') - end - -else - abort <<-FAIL - - Please create #{database_yml} first to configure your database. - Take a look at: #{database_yml}.example" - - FAIL -end - -def clean_database! - [SimpleDocument].each do |model| - ActiveRecord::Base.connection.execute "DELETE FROM #{model.table_name}" - end -end - -clean_database! \ No newline at end of file + load(File.dirname(__FILE__) + '/../db/schema.rb') + load(File.dirname(__FILE__) + '/../db/models.rb') +end \ No newline at end of file