require 'spec_helper'

class Mock
  include ActiveRecord::ConnectionHandling
  def logger
    nil
  end
end

describe ActiveRecord::ConnectionHandling do

  it 'raises NoDatabaseError correctly' do
    expect {
      Mock.new.pedant_mysql2_connection({host: 'localhost', database: 'nosuchthing'})
    }.to raise_error(ActiveRecord::NoDatabaseError)
  end

end

require 'spec_helper'

class Mock
  include ActiveRecord::ConnectionHandling
  def logger
    nil
  end
end

describe ActiveRecord::ConnectionHandling do

  it 'raises NoDatabaseError correctly' do
    error_class = defined?(ActiveRecord::NoDatabaseError) ? ActiveRecord::NoDatabaseError : Mysql2::Error
    expect {
      Mock.new.pedant_mysql2_connection({host: 'localhost', database: 'nosuchthing'})
    }.to raise_error(error_class)
  end

end

Fix NoDatabaseError test for AR < 4.1
Fix NoDatabaseError test for AR < 4.1
