Sha256: ce0dcb80537db44507b8feb72fb7be44fb0ab042b427816ff7b7089e9b907aa1

Contents?: true

Size: 867 Bytes

Versions: 5

Compression:

Stored size: 867 Bytes

Contents

require 'alf'
require 'rspec'
require 'sap'

ENV['DATABASE'] ||= 'postgres'

FIXTURES_FOLDER = Path.backfind('fixtures')

class Adapters

  def fake
    @fake ||= Alf.examples_adapter
  end

  def sqlite
    @sqlite ||= begin
      url = FIXTURES_FOLDER/"suppliers-and-parts/suppliers-and-parts.db"
      Alf::Sequel::Adapter.sequel_db(url)
    end
  end

  def postgres
    @postgres ||= begin
      url = "postgres://alf@localhost/suppliers_and_parts"
      Alf::Sequel::Adapter.sequel_db(url)
    end
  end

end
ADAPTERS = Adapters.new

module AlfIntegrationHelpers

  def fixtures_folder
    FIXTURES_FOLDER
  end

  def adapter
    ADAPTERS.send ENV['DATABASE']
  end

  def db
    @db ||= Alf::Database.new(adapter, viewpoint: Sap::Views[])
  end

  def conn
    @conn ||= db.connection
  end

end

RSpec.configure do |c|
  c.include(AlfIntegrationHelpers)
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.16.3 spec/test_helpers.rb
alf-0.16.2 spec/test_helpers.rb
alf-0.16.1 spec/test_helpers.rb
alf-0.16.0 spec/test_helpers.rb
alf-0.15.0 spec/test_helpers.rb