From 64e77d0bfa71f9dd133fd47d7f39630a7c425c12 Mon Sep 17 00:00:00 2001 From: stanislaw Date: Thu, 2 Aug 2012 22:18:06 +0300 Subject: [PATCH] require abstract_mysql_adapter if it exists --- Gemfile | 6 +++--- lib/database_cleaner/active_record/truncation.rb | 7 +++++++ spec/database_cleaner/configuration_spec.rb | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index e2e9477..129fa11 100755 --- a/Gemfile +++ b/Gemfile @@ -16,11 +16,11 @@ group :development do gem "dm-migrations", "1.0.0" gem "dm-sqlite-adapter", "1.0.0" gem "mongoid" - gem "tzinfo" + gem "tzinfo" gem "mongo_ext" gem "bson_ext" - gem "mongo_mapper" - gem "couch_potato" + gem "mongo_mapper" + gem "couch_potato" gem "sequel", "~>3.21.0" #gem "ibm_db" # I don't want to add this dependency, even as a dev one since it requires DB2 to be installed gem 'mysql' diff --git a/lib/database_cleaner/active_record/truncation.rb b/lib/database_cleaner/active_record/truncation.rb index 8649c98..5d882fc 100755 --- a/lib/database_cleaner/active_record/truncation.rb +++ b/lib/database_cleaner/active_record/truncation.rb @@ -1,5 +1,12 @@ require 'active_record/base' + require 'active_record/connection_adapters/abstract_adapter' + +begin + require 'active_record/connection_adapters/abstract_mysql_adapter' +rescue LoadError +end + require "database_cleaner/generic/truncation" require 'database_cleaner/active_record/base' diff --git a/spec/database_cleaner/configuration_spec.rb b/spec/database_cleaner/configuration_spec.rb index 45f6594..f05c5f5 100644 --- a/spec/database_cleaner/configuration_spec.rb +++ b/spec/database_cleaner/configuration_spec.rb @@ -17,7 +17,7 @@ describe ::DatabaseCleaner do context "orm specification" do it "should not accept unrecognised orms" do - expect { ::DatabaseCleaner[nil] }.should raise_error(::DatabaseCleaner::NoORMDetected) + expect { ::DatabaseCleaner[nil] }.to raise_error(::DatabaseCleaner::NoORMDetected) end it "should accept :active_record" do