Sha256: 8bfcffdf5ba32e6921f73342280c85294896a5216ea9e5be9c8f616bce124d1a

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

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

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

      config = ROM::Config.build(db_config)

      if RUBY_ENGINE == 'jruby'
        expect(config)
          .to eql(default: "jdbc:sqlite:///somewhere/testing.sqlite")
      else
        expect(config).to eql(default: "sqlite:///somewhere/testing.sqlite")
      end
    end

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

      config = ROM::Config.build(db_config)

      if RUBY_ENGINE == 'jruby'
        expect(config)
          .to eql(default: "jdbc:mysql://piotr:secret@localhost/testing")
      else
        expect(config)
          .to eql(default: "mysql://piotr:secret@localhost/testing")
      end

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

      config = ROM::Config.build(db_config)

      if RUBY_ENGINE == 'jruby'
        expect(config).to eql(default: "jdbc:mysql://localhost/testing")
      else
        expect(config).to eql(default: "mysql://localhost/testing")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-sql-0.3.2 spec/unit/config_spec.rb
rom-sql-0.3.1 spec/unit/config_spec.rb