Sha256: 01a3eb64da3a46050a2c03eb32afcdd1f6e65447e2a093152530651e5263caae

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe ROM::Rails::Configuration do
  let(:root) { '/somewhere' }

  describe '.rewrite_config' do
    it 'rewrites database config hash to a URI for sqlite' do
      db_config = { adapter: 'sqlite', database: 'testing.sqlite' }

      config = ROM::Rails::Configuration.rewrite_config(root, db_config)

      expect(config).to eql(default: "sqlite:///somewhere/testing.sqlite")
    end

    it 'rewrites database config hash to a URI for postgres' do
      db_config = {
        adapter: 'postgres',
        database: 'testing',
        username: 'piotr',
        hostname: 'localhost',
        password: 'secret'
      }

      config = ROM::Rails::Configuration.rewrite_config(root, db_config)

      expect(config).to eql(default: "postgres://piotr:secret@localhost/testing")

      db_config = {
        adapter: 'postgres',
        database: 'testing'
      }

      config = ROM::Rails::Configuration.rewrite_config(root, db_config)

      expect(config).to eql(default: "postgres://localhost/testing")
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-rails-0.1.0 spec/unit/configuration_spec.rb
rom-rails-0.0.2 spec/unit/configuration_spec.rb