Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

44 lines (32 sloc) 1.083 kb
# Copyright (c) 2011, SoundCloud Ltd.
require File.expand_path(File.dirname(__FILE__)) + '/unit_helper'
require 'lhm/connection'
if defined?(DataMapper)
describe Lhm::Connection::DataMapperConnection do
let(:data_mapper) { MiniTest::Mock.new }
let(:options) { { 'path' => '/the db' } }
before do
data_mapper.expect :is_a?, true, [DataMapper::Adapters::AbstractAdapter]
data_mapper.expect :options, options
end
after do
data_mapper.verify
end
it 'creates a DataMapperConnection when the adapter is from DM' do
connection.must_be_instance_of(Lhm::Connection::DataMapperConnection)
end
it 'initializes the db name from the options' do
connection.current_database.must_equal('the db')
end
it 'backticks the table names' do
table_name = 'my_table'
data_mapper.expect :select,
[{ :sql => 'returned sql' }],
["show create table `#{table_name}`"]
connection.show_create(table_name)
end
def connection
Lhm::Connection.new(data_mapper)
end
end
end
Jump to Line
Something went wrong with that request. Please try again.