Sha256: a73aa16a9499fb9c2f78d3c4a89119a69eebd76e558969a00ec3081103d78f30

Contents?: true

Size: 947 Bytes

Versions: 8

Compression:

Stored size: 947 Bytes

Contents

require 'support/active_record/database_setup'
require 'support/active_record/schema_setup'

module SQLite3Helper
  puts "Active Record #{ActiveRecord::VERSION::STRING}, sqlite3"

  # ActiveRecord::Base.logger = Logger.new(STDERR)

  def config
    db_config['sqlite3']
  end

  def create_db
    @encoding = config['encoding'] || ENV['CHARSET'] || 'utf8'
    begin
      establish_connection(config.merge('database' => 'sqlite3', 'schema_search_path' => 'public'))
    rescue Exception => e
      $stderr.puts e, *(e.backtrace)
      $stderr.puts "Couldn't create database for #{config.inspect}"
    end
  end

  def establish_connection config = config
    ActiveRecord::Base.establish_connection(config)
  end

  def active_record_sqlite3_setup
    create_db
    establish_connection
    load_schema
  end

  def active_record_sqlite3_connection
    ActiveRecord::Base.connection
  end
end

RSpec.configure do |c|
  c.include SQLite3Helper
end

Version data entries

8 entries across 3 versions & 2 rubygems

Version Path
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/database_cleaner-1.2.0/spec/support/active_record/sqlite3_setup.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/database_cleaner-1.2.0/spec/support/active_record/sqlite3_setup.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/database_cleaner-1.2.0/spec/support/active_record/sqlite3_setup.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/database_cleaner-1.2.0/spec/support/active_record/sqlite3_setup.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/database_cleaner-1.2.0/spec/support/active_record/sqlite3_setup.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/database_cleaner-1.2.0/spec/support/active_record/sqlite3_setup.rb
database_cleaner-1.3.0 spec/support/active_record/sqlite3_setup.rb
database_cleaner-1.2.0 spec/support/active_record/sqlite3_setup.rb