From 2da1f4976fc695a64bb0c7d4a1d58d38e2958a0a Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Sat, 1 Feb 2020 15:24:32 -0800 Subject: [PATCH 01/21] begin development on v2.0.0.beta. --- lib/database_cleaner/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/database_cleaner/version.rb b/lib/database_cleaner/version.rb index e74c7527..7a328e46 100644 --- a/lib/database_cleaner/version.rb +++ b/lib/database_cleaner/version.rb @@ -1,3 +1,3 @@ module DatabaseCleaner - VERSION = "1.8.2" + VERSION = "2.0.0.beta" end From e658c11c4fd37387637a4db01999f0648251c792 Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Thu, 30 Jan 2020 16:19:26 -0800 Subject: [PATCH 02/21] split all adapter gems into their own repos. --- Gemfile | 13 - Gemfile.lock | 53 +--- Rakefile | 11 +- .../database_cleaner-active_record/.gitignore | 13 - .../database_cleaner-active_record/.rspec | 3 - .../.travis.yml | 4 - .../database_cleaner-active_record/Gemfile | 8 - .../Gemfile.lock | 73 ----- .../LICENSE.txt | 21 -- .../database_cleaner-active_record/README.md | 110 ------- .../database_cleaner-active_record/Rakefile | 6 - .../bin/console | 14 - .../database_cleaner-active_record/bin/setup | 8 - .../database_cleaner-active_record.gemspec | 40 --- .../lib/database_cleaner-active_record.rb | 1 - .../lib/database_cleaner/active_record.rb | 6 - .../database_cleaner/active_record/base.rb | 101 ------- .../active_record/deletion.rb | 108 ------- .../active_record/transaction.rb | 59 ---- .../active_record/truncation.rb | 280 ------------------ .../database_cleaner/active_record/version.rb | 5 - .../active_record/base_spec.rb | 170 ----------- .../active_record/transaction_spec.rb | 155 ---------- .../active_record/truncation_spec.rb | 120 -------- .../spec/spec_helper.rb | 14 - .../spec/support/active_record_helper.rb | 40 --- .../spec/support/example.database.yml | 3 - .../spec/support/sample.config.yml | 34 --- .../database_cleaner-active_record/tmp/.keep | 0 .../database_cleaner-couch_potato/.gitignore | 11 - adapters/database_cleaner-couch_potato/.rspec | 3 - .../database_cleaner-couch_potato/.travis.yml | 4 - .../database_cleaner-couch_potato/Gemfile | 8 - .../Gemfile.lock | 80 ----- .../database_cleaner-couch_potato/LICENSE.txt | 21 -- .../database_cleaner-couch_potato/README.md | 59 ---- .../database_cleaner-couch_potato/Rakefile | 6 - .../database_cleaner-couch_potato/bin/console | 14 - .../database_cleaner-couch_potato/bin/setup | 6 - .../database_cleaner-couch_potato.gemspec | 30 -- .../lib/database_cleaner-couch_potato.rb | 1 - .../lib/database_cleaner/couch_potato.rb | 11 - .../lib/database_cleaner/couch_potato/base.rb | 7 - .../couch_potato/truncation.rb | 28 -- .../database_cleaner/couch_potato/version.rb | 5 - .../couch_potato/base_spec.rb | 8 - .../couch_potato/truncation_spec.rb | 40 --- .../spec/spec_helper.rb | 14 - .../database_cleaner-data_mapper/.gitignore | 13 - adapters/database_cleaner-data_mapper/.rspec | 3 - .../database_cleaner-data_mapper/.travis.yml | 4 - adapters/database_cleaner-data_mapper/Gemfile | 8 - .../database_cleaner-data_mapper/Gemfile.lock | 103 ------- .../database_cleaner-data_mapper/LICENSE.txt | 21 -- .../database_cleaner-data_mapper/README.md | 59 ---- .../database_cleaner-data_mapper/Rakefile | 6 - .../database_cleaner-data_mapper/bin/console | 14 - .../database_cleaner-data_mapper/bin/setup | 8 - .../database_cleaner-data_mapper.gemspec | 34 --- .../lib/database_cleaner-data_mapper.rb | 1 - .../lib/database_cleaner/data_mapper.rb | 4 - .../lib/database_cleaner/data_mapper/base.rb | 25 -- .../data_mapper/transaction.rb | 28 -- .../data_mapper/truncation.rb | 173 ----------- .../database_cleaner/data_mapper/version.rb | 5 - .../database_cleaner/data_mapper/base_spec.rb | 33 --- .../data_mapper/transaction_spec.rb | 22 -- .../data_mapper/truncation/sqlite3_spec.rb | 25 -- .../data_mapper/truncation_spec.rb | 11 - .../spec/spec_helper.rb | 15 - .../spec/support/data_mapper_helper.rb | 36 --- .../spec/support/sample.config.yml | 34 --- .../database_cleaner-data_mapper/tmp/.keep | 0 adapters/database_cleaner-mongo/.gitignore | 11 - adapters/database_cleaner-mongo/.rspec | 3 - adapters/database_cleaner-mongo/.travis.yml | 4 - adapters/database_cleaner-mongo/Gemfile | 8 - adapters/database_cleaner-mongo/Gemfile.lock | 46 --- adapters/database_cleaner-mongo/LICENSE.txt | 21 -- adapters/database_cleaner-mongo/README.md | 57 ---- adapters/database_cleaner-mongo/Rakefile | 6 - adapters/database_cleaner-mongo/bin/console | 14 - adapters/database_cleaner-mongo/bin/setup | 6 - .../database_cleaner-mongo.gemspec | 30 -- .../lib/database_cleaner-mongo.rb | 1 - .../lib/database_cleaner/mongo.rb | 10 - .../lib/database_cleaner/mongo/base.rb | 16 - .../lib/database_cleaner/mongo/truncation.rb | 62 ---- .../mongo/truncation_mixin.rb | 26 -- .../lib/database_cleaner/mongo/version.rb | 5 - .../spec/database_cleaner/mongo/base_spec.rb | 8 - .../database_cleaner/mongo/mongo_examples.rb | 26 -- .../database_cleaner/mongo/truncation_spec.rb | 50 ---- .../spec/spec_helper.rb | 14 - .../database_cleaner-mongo_mapper/.gitignore | 11 - adapters/database_cleaner-mongo_mapper/.rspec | 3 - .../database_cleaner-mongo_mapper/.travis.yml | 4 - .../database_cleaner-mongo_mapper/Gemfile | 8 - .../Gemfile.lock | 59 ---- .../database_cleaner-mongo_mapper/LICENSE.txt | 21 -- .../database_cleaner-mongo_mapper/README.md | 57 ---- .../database_cleaner-mongo_mapper/Rakefile | 6 - .../database_cleaner-mongo_mapper/bin/console | 14 - .../database_cleaner-mongo_mapper/bin/setup | 7 - .../database_cleaner-mongo_mapper.gemspec | 30 -- .../lib/database_cleaner-mongo_mapper.rb | 1 - .../lib/database_cleaner/mongo_mapper.rb | 4 - .../lib/database_cleaner/mongo_mapper/base.rb | 24 -- .../mongo_mapper/truncation.rb | 35 --- .../database_cleaner/mongo_mapper/version.rb | 5 - .../mongo_mapper/base_spec.rb | 36 --- .../mongo_mapper/mongo_examples.rb | 10 - .../mongo_mapper/truncation_spec.rb | 49 --- .../spec/spec_helper.rb | 14 - adapters/database_cleaner-mongoid/.gitignore | 11 - adapters/database_cleaner-mongoid/.rspec | 3 - adapters/database_cleaner-mongoid/.travis.yml | 5 - adapters/database_cleaner-mongoid/Gemfile | 9 - .../database_cleaner-mongoid/Gemfile.lock | 72 ----- adapters/database_cleaner-mongoid/LICENSE.txt | 21 -- adapters/database_cleaner-mongoid/README.md | 57 ---- adapters/database_cleaner-mongoid/Rakefile | 6 - adapters/database_cleaner-mongoid/bin/console | 14 - adapters/database_cleaner-mongoid/bin/setup | 7 - .../database_cleaner-mongoid.gemspec | 31 -- .../lib/database_cleaner-mongoid.rb | 1 - .../lib/database_cleaner/mongoid.rb | 10 - .../lib/database_cleaner/mongoid/base.rb | 20 -- .../mongoid/mongo1_truncation_mixin.rb | 26 -- .../mongoid/mongo2_truncation_mixin.rb | 38 --- .../mongoid/mongoid_truncation_mixin.rb | 65 ---- .../database_cleaner/mongoid/truncation.rb | 49 --- .../lib/database_cleaner/mongoid/version.rb | 5 - .../database_cleaner/mongoid/base_spec.rb | 8 - .../spec/spec_helper.rb | 14 - adapters/database_cleaner-moped/.gitignore | 11 - adapters/database_cleaner-moped/.rspec | 3 - adapters/database_cleaner-moped/.travis.yml | 4 - adapters/database_cleaner-moped/Gemfile | 8 - adapters/database_cleaner-moped/Gemfile.lock | 50 ---- adapters/database_cleaner-moped/LICENSE.txt | 21 -- adapters/database_cleaner-moped/README.md | 57 ---- adapters/database_cleaner-moped/Rakefile | 6 - adapters/database_cleaner-moped/bin/console | 14 - adapters/database_cleaner-moped/bin/setup | 7 - .../database_cleaner-moped.gemspec | 30 -- .../lib/database_cleaner-moped.rb | 1 - .../lib/database_cleaner/moped.rb | 10 - .../lib/database_cleaner/moped/base.rb | 39 --- .../lib/database_cleaner/moped/truncation.rb | 9 - .../database_cleaner/moped/truncation_base.rb | 44 --- .../lib/database_cleaner/moped/version.rb | 5 - .../spec/database_cleaner/moped/base_spec.rb | 8 - .../database_cleaner/moped/moped_examples.rb | 32 -- .../database_cleaner/moped/truncation_spec.rb | 51 ---- .../spec/spec_helper.rb | 14 - adapters/database_cleaner-neo4j/.gitignore | 11 - adapters/database_cleaner-neo4j/.rspec | 3 - adapters/database_cleaner-neo4j/.travis.yml | 4 - adapters/database_cleaner-neo4j/Gemfile | 8 - adapters/database_cleaner-neo4j/Gemfile.lock | 81 ----- adapters/database_cleaner-neo4j/LICENSE.txt | 21 -- adapters/database_cleaner-neo4j/README.md | 75 ----- adapters/database_cleaner-neo4j/Rakefile | 6 - adapters/database_cleaner-neo4j/bin/console | 14 - adapters/database_cleaner-neo4j/bin/setup | 7 - .../database_cleaner-neo4j.gemspec | 30 -- .../lib/database_cleaner-neo4j.rb | 1 - .../lib/database_cleaner/neo4j.rb | 6 - .../lib/database_cleaner/neo4j/base.rb | 66 ----- .../lib/database_cleaner/neo4j/deletion.rb | 16 - .../lib/database_cleaner/neo4j/transaction.rb | 35 --- .../lib/database_cleaner/neo4j/truncation.rb | 9 - .../lib/database_cleaner/neo4j/version.rb | 5 - .../spec/database_cleaner/neo4j/base_spec.rb | 46 --- .../neo4j/transaction_spec.rb | 25 -- .../spec/spec_helper.rb | 14 - adapters/database_cleaner-ohm/.gitignore | 11 - adapters/database_cleaner-ohm/.rspec | 3 - adapters/database_cleaner-ohm/.travis.yml | 4 - adapters/database_cleaner-ohm/Gemfile | 9 - adapters/database_cleaner-ohm/Gemfile.lock | 64 ---- adapters/database_cleaner-ohm/LICENSE.txt | 21 -- adapters/database_cleaner-ohm/README.md | 59 ---- adapters/database_cleaner-ohm/Rakefile | 6 - adapters/database_cleaner-ohm/bin/console | 14 - adapters/database_cleaner-ohm/bin/setup | 7 - .../database_cleaner-ohm.gemspec | 31 -- .../lib/database_cleaner-ohm.rb | 1 - .../lib/database_cleaner/ohm.rb | 12 - .../lib/database_cleaner/ohm/truncation.rb | 24 -- .../lib/database_cleaner/ohm/version.rb | 5 - .../spec/database_cleaner/ohm/base_spec.rb | 8 - .../database_cleaner/ohm/truncation_spec.rb | 55 ---- .../database_cleaner-ohm/spec/spec_helper.rb | 14 - .../spec/support/redis.yml | 8 - adapters/database_cleaner-redis/.gitignore | 11 - adapters/database_cleaner-redis/.rspec | 3 - adapters/database_cleaner-redis/.travis.yml | 4 - adapters/database_cleaner-redis/Gemfile | 8 - adapters/database_cleaner-redis/Gemfile.lock | 44 --- adapters/database_cleaner-redis/LICENSE.txt | 21 -- adapters/database_cleaner-redis/README.md | 59 ---- adapters/database_cleaner-redis/Rakefile | 6 - adapters/database_cleaner-redis/bin/console | 14 - adapters/database_cleaner-redis/bin/setup | 7 - .../database_cleaner-redis.gemspec | 30 -- .../lib/database_cleaner-redis.rb | 1 - .../lib/database_cleaner/redis.rb | 4 - .../lib/database_cleaner/redis/base.rb | 41 --- .../lib/database_cleaner/redis/truncation.rb | 26 -- .../lib/database_cleaner/redis/version.rb | 5 - .../spec/database_cleaner/redis/base_spec.rb | 46 --- .../database_cleaner/redis/truncation_spec.rb | 44 --- .../spec/spec_helper.rb | 14 - .../spec/support/redis.yml | 8 - adapters/database_cleaner-sequel/.gitignore | 13 - adapters/database_cleaner-sequel/.rspec | 3 - adapters/database_cleaner-sequel/.travis.yml | 4 - adapters/database_cleaner-sequel/Gemfile | 8 - adapters/database_cleaner-sequel/Gemfile.lock | 52 ---- adapters/database_cleaner-sequel/LICENSE.txt | 21 -- adapters/database_cleaner-sequel/README.md | 65 ---- adapters/database_cleaner-sequel/Rakefile | 6 - adapters/database_cleaner-sequel/bin/console | 14 - adapters/database_cleaner-sequel/bin/setup | 8 - .../database_cleaner-sequel.gemspec | 35 --- .../lib/database_cleaner-sequel.rb | 1 - .../lib/database_cleaner/sequel.rb | 6 - .../lib/database_cleaner/sequel/base.rb | 26 -- .../lib/database_cleaner/sequel/deletion.rb | 47 --- .../database_cleaner/sequel/transaction.rb | 40 --- .../lib/database_cleaner/sequel/truncation.rb | 79 ----- .../lib/database_cleaner/sequel/version.rb | 5 - .../spec/database_cleaner/sequel/base_spec.rb | 32 -- .../database_cleaner/sequel/deletion_spec.rb | 41 --- .../sequel/transaction_spec.rb | 20 -- .../sequel/truncation_spec.rb | 92 ------ .../spec/spec_helper.rb | 14 - .../spec/support/sample.config.yml | 34 --- .../spec/support/sequel_helper.rb | 12 - adapters/database_cleaner-sequel/tmp/.keep | 0 bin/setup | 4 - .../active_record/base_spec.rb | 166 ----------- .../active_record/transaction_spec.rb | 155 ---------- .../active_record/truncation_spec.rb | 120 -------- .../couch_potato/truncation_spec.rb | 40 --- .../database_cleaner/data_mapper/base_spec.rb | 29 -- .../data_mapper/transaction_spec.rb | 22 -- .../data_mapper/truncation/sqlite3_spec.rb | 26 -- .../data_mapper/truncation_spec.rb | 11 - spec/database_cleaner/generic/base_spec.rb | 59 ---- .../generic/truncation_spec.rb | 129 -------- spec/database_cleaner/mongo/mongo_examples.rb | 26 -- .../database_cleaner/mongo/truncation_spec.rb | 50 ---- .../mongo_mapper/base_spec.rb | 32 -- .../mongo_mapper/mongo_examples.rb | 10 - .../mongo_mapper/truncation_spec.rb | 49 --- spec/database_cleaner/moped/moped_examples.rb | 32 -- .../database_cleaner/moped/truncation_spec.rb | 51 ---- spec/database_cleaner/neo4j/base_spec.rb | 42 --- .../neo4j/transaction_spec.rb | 25 -- spec/database_cleaner/ohm/truncation_spec.rb | 54 ---- spec/database_cleaner/redis/base_spec.rb | 42 --- .../database_cleaner/redis/truncation_spec.rb | 43 --- spec/database_cleaner/sequel/base_spec.rb | 28 -- spec/database_cleaner/sequel/deletion_spec.rb | 41 --- .../sequel/transaction_spec.rb | 20 -- .../sequel/truncation_spec.rb | 92 ------ 269 files changed, 2 insertions(+), 7541 deletions(-) delete mode 100644 adapters/database_cleaner-active_record/.gitignore delete mode 100644 adapters/database_cleaner-active_record/.rspec delete mode 100644 adapters/database_cleaner-active_record/.travis.yml delete mode 100644 adapters/database_cleaner-active_record/Gemfile delete mode 100644 adapters/database_cleaner-active_record/Gemfile.lock delete mode 100644 adapters/database_cleaner-active_record/LICENSE.txt delete mode 100644 adapters/database_cleaner-active_record/README.md delete mode 100644 adapters/database_cleaner-active_record/Rakefile delete mode 100755 adapters/database_cleaner-active_record/bin/console delete mode 100755 adapters/database_cleaner-active_record/bin/setup delete mode 100644 adapters/database_cleaner-active_record/database_cleaner-active_record.gemspec delete mode 100644 adapters/database_cleaner-active_record/lib/database_cleaner-active_record.rb delete mode 100644 adapters/database_cleaner-active_record/lib/database_cleaner/active_record.rb delete mode 100644 adapters/database_cleaner-active_record/lib/database_cleaner/active_record/base.rb delete mode 100644 adapters/database_cleaner-active_record/lib/database_cleaner/active_record/deletion.rb delete mode 100644 adapters/database_cleaner-active_record/lib/database_cleaner/active_record/transaction.rb delete mode 100644 adapters/database_cleaner-active_record/lib/database_cleaner/active_record/truncation.rb delete mode 100644 adapters/database_cleaner-active_record/lib/database_cleaner/active_record/version.rb delete mode 100644 adapters/database_cleaner-active_record/spec/database_cleaner/active_record/base_spec.rb delete mode 100644 adapters/database_cleaner-active_record/spec/database_cleaner/active_record/transaction_spec.rb delete mode 100644 adapters/database_cleaner-active_record/spec/database_cleaner/active_record/truncation_spec.rb delete mode 100644 adapters/database_cleaner-active_record/spec/spec_helper.rb delete mode 100644 adapters/database_cleaner-active_record/spec/support/active_record_helper.rb delete mode 100644 adapters/database_cleaner-active_record/spec/support/example.database.yml delete mode 100644 adapters/database_cleaner-active_record/spec/support/sample.config.yml delete mode 100644 adapters/database_cleaner-active_record/tmp/.keep delete mode 100644 adapters/database_cleaner-couch_potato/.gitignore delete mode 100644 adapters/database_cleaner-couch_potato/.rspec delete mode 100644 adapters/database_cleaner-couch_potato/.travis.yml delete mode 100644 adapters/database_cleaner-couch_potato/Gemfile delete mode 100644 adapters/database_cleaner-couch_potato/Gemfile.lock delete mode 100644 adapters/database_cleaner-couch_potato/LICENSE.txt delete mode 100644 adapters/database_cleaner-couch_potato/README.md delete mode 100644 adapters/database_cleaner-couch_potato/Rakefile delete mode 100755 adapters/database_cleaner-couch_potato/bin/console delete mode 100755 adapters/database_cleaner-couch_potato/bin/setup delete mode 100644 adapters/database_cleaner-couch_potato/database_cleaner-couch_potato.gemspec delete mode 100644 adapters/database_cleaner-couch_potato/lib/database_cleaner-couch_potato.rb delete mode 100644 adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato.rb delete mode 100644 adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/base.rb delete mode 100644 adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/truncation.rb delete mode 100644 adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/version.rb delete mode 100644 adapters/database_cleaner-couch_potato/spec/database_cleaner/couch_potato/base_spec.rb delete mode 100644 adapters/database_cleaner-couch_potato/spec/database_cleaner/couch_potato/truncation_spec.rb delete mode 100644 adapters/database_cleaner-couch_potato/spec/spec_helper.rb delete mode 100644 adapters/database_cleaner-data_mapper/.gitignore delete mode 100644 adapters/database_cleaner-data_mapper/.rspec delete mode 100644 adapters/database_cleaner-data_mapper/.travis.yml delete mode 100644 adapters/database_cleaner-data_mapper/Gemfile delete mode 100644 adapters/database_cleaner-data_mapper/Gemfile.lock delete mode 100644 adapters/database_cleaner-data_mapper/LICENSE.txt delete mode 100644 adapters/database_cleaner-data_mapper/README.md delete mode 100644 adapters/database_cleaner-data_mapper/Rakefile delete mode 100755 adapters/database_cleaner-data_mapper/bin/console delete mode 100755 adapters/database_cleaner-data_mapper/bin/setup delete mode 100644 adapters/database_cleaner-data_mapper/database_cleaner-data_mapper.gemspec delete mode 100644 adapters/database_cleaner-data_mapper/lib/database_cleaner-data_mapper.rb delete mode 100644 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper.rb delete mode 100644 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/base.rb delete mode 100644 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb delete mode 100644 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/truncation.rb delete mode 100644 adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/version.rb delete mode 100644 adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/base_spec.rb delete mode 100644 adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/transaction_spec.rb delete mode 100644 adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/truncation/sqlite3_spec.rb delete mode 100644 adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/truncation_spec.rb delete mode 100644 adapters/database_cleaner-data_mapper/spec/spec_helper.rb delete mode 100644 adapters/database_cleaner-data_mapper/spec/support/data_mapper_helper.rb delete mode 100644 adapters/database_cleaner-data_mapper/spec/support/sample.config.yml delete mode 100644 adapters/database_cleaner-data_mapper/tmp/.keep delete mode 100644 adapters/database_cleaner-mongo/.gitignore delete mode 100644 adapters/database_cleaner-mongo/.rspec delete mode 100644 adapters/database_cleaner-mongo/.travis.yml delete mode 100644 adapters/database_cleaner-mongo/Gemfile delete mode 100644 adapters/database_cleaner-mongo/Gemfile.lock delete mode 100644 adapters/database_cleaner-mongo/LICENSE.txt delete mode 100644 adapters/database_cleaner-mongo/README.md delete mode 100644 adapters/database_cleaner-mongo/Rakefile delete mode 100755 adapters/database_cleaner-mongo/bin/console delete mode 100755 adapters/database_cleaner-mongo/bin/setup delete mode 100644 adapters/database_cleaner-mongo/database_cleaner-mongo.gemspec delete mode 100644 adapters/database_cleaner-mongo/lib/database_cleaner-mongo.rb delete mode 100644 adapters/database_cleaner-mongo/lib/database_cleaner/mongo.rb delete mode 100644 adapters/database_cleaner-mongo/lib/database_cleaner/mongo/base.rb delete mode 100644 adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation.rb delete mode 100644 adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation_mixin.rb delete mode 100644 adapters/database_cleaner-mongo/lib/database_cleaner/mongo/version.rb delete mode 100644 adapters/database_cleaner-mongo/spec/database_cleaner/mongo/base_spec.rb delete mode 100644 adapters/database_cleaner-mongo/spec/database_cleaner/mongo/mongo_examples.rb delete mode 100644 adapters/database_cleaner-mongo/spec/database_cleaner/mongo/truncation_spec.rb delete mode 100644 adapters/database_cleaner-mongo/spec/spec_helper.rb delete mode 100644 adapters/database_cleaner-mongo_mapper/.gitignore delete mode 100644 adapters/database_cleaner-mongo_mapper/.rspec delete mode 100644 adapters/database_cleaner-mongo_mapper/.travis.yml delete mode 100644 adapters/database_cleaner-mongo_mapper/Gemfile delete mode 100644 adapters/database_cleaner-mongo_mapper/Gemfile.lock delete mode 100644 adapters/database_cleaner-mongo_mapper/LICENSE.txt delete mode 100644 adapters/database_cleaner-mongo_mapper/README.md delete mode 100644 adapters/database_cleaner-mongo_mapper/Rakefile delete mode 100755 adapters/database_cleaner-mongo_mapper/bin/console delete mode 100755 adapters/database_cleaner-mongo_mapper/bin/setup delete mode 100644 adapters/database_cleaner-mongo_mapper/database_cleaner-mongo_mapper.gemspec delete mode 100644 adapters/database_cleaner-mongo_mapper/lib/database_cleaner-mongo_mapper.rb delete mode 100644 adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper.rb delete mode 100644 adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/base.rb delete mode 100644 adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/truncation.rb delete mode 100644 adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/version.rb delete mode 100644 adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/base_spec.rb delete mode 100644 adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/mongo_examples.rb delete mode 100644 adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/truncation_spec.rb delete mode 100644 adapters/database_cleaner-mongo_mapper/spec/spec_helper.rb delete mode 100644 adapters/database_cleaner-mongoid/.gitignore delete mode 100644 adapters/database_cleaner-mongoid/.rspec delete mode 100644 adapters/database_cleaner-mongoid/.travis.yml delete mode 100644 adapters/database_cleaner-mongoid/Gemfile delete mode 100644 adapters/database_cleaner-mongoid/Gemfile.lock delete mode 100644 adapters/database_cleaner-mongoid/LICENSE.txt delete mode 100644 adapters/database_cleaner-mongoid/README.md delete mode 100644 adapters/database_cleaner-mongoid/Rakefile delete mode 100755 adapters/database_cleaner-mongoid/bin/console delete mode 100755 adapters/database_cleaner-mongoid/bin/setup delete mode 100644 adapters/database_cleaner-mongoid/database_cleaner-mongoid.gemspec delete mode 100644 adapters/database_cleaner-mongoid/lib/database_cleaner-mongoid.rb delete mode 100644 adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid.rb delete mode 100644 adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/base.rb delete mode 100644 adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo1_truncation_mixin.rb delete mode 100644 adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo2_truncation_mixin.rb delete mode 100644 adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongoid_truncation_mixin.rb delete mode 100644 adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/truncation.rb delete mode 100644 adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/version.rb delete mode 100644 adapters/database_cleaner-mongoid/spec/database_cleaner/mongoid/base_spec.rb delete mode 100644 adapters/database_cleaner-mongoid/spec/spec_helper.rb delete mode 100644 adapters/database_cleaner-moped/.gitignore delete mode 100644 adapters/database_cleaner-moped/.rspec delete mode 100644 adapters/database_cleaner-moped/.travis.yml delete mode 100644 adapters/database_cleaner-moped/Gemfile delete mode 100644 adapters/database_cleaner-moped/Gemfile.lock delete mode 100644 adapters/database_cleaner-moped/LICENSE.txt delete mode 100644 adapters/database_cleaner-moped/README.md delete mode 100644 adapters/database_cleaner-moped/Rakefile delete mode 100755 adapters/database_cleaner-moped/bin/console delete mode 100755 adapters/database_cleaner-moped/bin/setup delete mode 100644 adapters/database_cleaner-moped/database_cleaner-moped.gemspec delete mode 100644 adapters/database_cleaner-moped/lib/database_cleaner-moped.rb delete mode 100644 adapters/database_cleaner-moped/lib/database_cleaner/moped.rb delete mode 100644 adapters/database_cleaner-moped/lib/database_cleaner/moped/base.rb delete mode 100644 adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation.rb delete mode 100644 adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation_base.rb delete mode 100644 adapters/database_cleaner-moped/lib/database_cleaner/moped/version.rb delete mode 100644 adapters/database_cleaner-moped/spec/database_cleaner/moped/base_spec.rb delete mode 100644 adapters/database_cleaner-moped/spec/database_cleaner/moped/moped_examples.rb delete mode 100644 adapters/database_cleaner-moped/spec/database_cleaner/moped/truncation_spec.rb delete mode 100644 adapters/database_cleaner-moped/spec/spec_helper.rb delete mode 100644 adapters/database_cleaner-neo4j/.gitignore delete mode 100644 adapters/database_cleaner-neo4j/.rspec delete mode 100644 adapters/database_cleaner-neo4j/.travis.yml delete mode 100644 adapters/database_cleaner-neo4j/Gemfile delete mode 100644 adapters/database_cleaner-neo4j/Gemfile.lock delete mode 100644 adapters/database_cleaner-neo4j/LICENSE.txt delete mode 100644 adapters/database_cleaner-neo4j/README.md delete mode 100644 adapters/database_cleaner-neo4j/Rakefile delete mode 100755 adapters/database_cleaner-neo4j/bin/console delete mode 100755 adapters/database_cleaner-neo4j/bin/setup delete mode 100644 adapters/database_cleaner-neo4j/database_cleaner-neo4j.gemspec delete mode 100644 adapters/database_cleaner-neo4j/lib/database_cleaner-neo4j.rb delete mode 100644 adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j.rb delete mode 100644 adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/base.rb delete mode 100644 adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/deletion.rb delete mode 100644 adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/transaction.rb delete mode 100644 adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/truncation.rb delete mode 100644 adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/version.rb delete mode 100644 adapters/database_cleaner-neo4j/spec/database_cleaner/neo4j/base_spec.rb delete mode 100644 adapters/database_cleaner-neo4j/spec/database_cleaner/neo4j/transaction_spec.rb delete mode 100644 adapters/database_cleaner-neo4j/spec/spec_helper.rb delete mode 100644 adapters/database_cleaner-ohm/.gitignore delete mode 100644 adapters/database_cleaner-ohm/.rspec delete mode 100644 adapters/database_cleaner-ohm/.travis.yml delete mode 100644 adapters/database_cleaner-ohm/Gemfile delete mode 100644 adapters/database_cleaner-ohm/Gemfile.lock delete mode 100644 adapters/database_cleaner-ohm/LICENSE.txt delete mode 100644 adapters/database_cleaner-ohm/README.md delete mode 100644 adapters/database_cleaner-ohm/Rakefile delete mode 100755 adapters/database_cleaner-ohm/bin/console delete mode 100755 adapters/database_cleaner-ohm/bin/setup delete mode 100644 adapters/database_cleaner-ohm/database_cleaner-ohm.gemspec delete mode 100644 adapters/database_cleaner-ohm/lib/database_cleaner-ohm.rb delete mode 100644 adapters/database_cleaner-ohm/lib/database_cleaner/ohm.rb delete mode 100644 adapters/database_cleaner-ohm/lib/database_cleaner/ohm/truncation.rb delete mode 100644 adapters/database_cleaner-ohm/lib/database_cleaner/ohm/version.rb delete mode 100644 adapters/database_cleaner-ohm/spec/database_cleaner/ohm/base_spec.rb delete mode 100644 adapters/database_cleaner-ohm/spec/database_cleaner/ohm/truncation_spec.rb delete mode 100644 adapters/database_cleaner-ohm/spec/spec_helper.rb delete mode 100644 adapters/database_cleaner-ohm/spec/support/redis.yml delete mode 100644 adapters/database_cleaner-redis/.gitignore delete mode 100644 adapters/database_cleaner-redis/.rspec delete mode 100644 adapters/database_cleaner-redis/.travis.yml delete mode 100644 adapters/database_cleaner-redis/Gemfile delete mode 100644 adapters/database_cleaner-redis/Gemfile.lock delete mode 100644 adapters/database_cleaner-redis/LICENSE.txt delete mode 100644 adapters/database_cleaner-redis/README.md delete mode 100644 adapters/database_cleaner-redis/Rakefile delete mode 100755 adapters/database_cleaner-redis/bin/console delete mode 100755 adapters/database_cleaner-redis/bin/setup delete mode 100644 adapters/database_cleaner-redis/database_cleaner-redis.gemspec delete mode 100644 adapters/database_cleaner-redis/lib/database_cleaner-redis.rb delete mode 100644 adapters/database_cleaner-redis/lib/database_cleaner/redis.rb delete mode 100644 adapters/database_cleaner-redis/lib/database_cleaner/redis/base.rb delete mode 100644 adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb delete mode 100644 adapters/database_cleaner-redis/lib/database_cleaner/redis/version.rb delete mode 100644 adapters/database_cleaner-redis/spec/database_cleaner/redis/base_spec.rb delete mode 100644 adapters/database_cleaner-redis/spec/database_cleaner/redis/truncation_spec.rb delete mode 100644 adapters/database_cleaner-redis/spec/spec_helper.rb delete mode 100644 adapters/database_cleaner-redis/spec/support/redis.yml delete mode 100644 adapters/database_cleaner-sequel/.gitignore delete mode 100644 adapters/database_cleaner-sequel/.rspec delete mode 100644 adapters/database_cleaner-sequel/.travis.yml delete mode 100644 adapters/database_cleaner-sequel/Gemfile delete mode 100644 adapters/database_cleaner-sequel/Gemfile.lock delete mode 100644 adapters/database_cleaner-sequel/LICENSE.txt delete mode 100644 adapters/database_cleaner-sequel/README.md delete mode 100644 adapters/database_cleaner-sequel/Rakefile delete mode 100755 adapters/database_cleaner-sequel/bin/console delete mode 100755 adapters/database_cleaner-sequel/bin/setup delete mode 100644 adapters/database_cleaner-sequel/database_cleaner-sequel.gemspec delete mode 100644 adapters/database_cleaner-sequel/lib/database_cleaner-sequel.rb delete mode 100644 adapters/database_cleaner-sequel/lib/database_cleaner/sequel.rb delete mode 100644 adapters/database_cleaner-sequel/lib/database_cleaner/sequel/base.rb delete mode 100644 adapters/database_cleaner-sequel/lib/database_cleaner/sequel/deletion.rb delete mode 100644 adapters/database_cleaner-sequel/lib/database_cleaner/sequel/transaction.rb delete mode 100644 adapters/database_cleaner-sequel/lib/database_cleaner/sequel/truncation.rb delete mode 100644 adapters/database_cleaner-sequel/lib/database_cleaner/sequel/version.rb delete mode 100644 adapters/database_cleaner-sequel/spec/database_cleaner/sequel/base_spec.rb delete mode 100644 adapters/database_cleaner-sequel/spec/database_cleaner/sequel/deletion_spec.rb delete mode 100644 adapters/database_cleaner-sequel/spec/database_cleaner/sequel/transaction_spec.rb delete mode 100644 adapters/database_cleaner-sequel/spec/database_cleaner/sequel/truncation_spec.rb delete mode 100644 adapters/database_cleaner-sequel/spec/spec_helper.rb delete mode 100644 adapters/database_cleaner-sequel/spec/support/sample.config.yml delete mode 100644 adapters/database_cleaner-sequel/spec/support/sequel_helper.rb delete mode 100644 adapters/database_cleaner-sequel/tmp/.keep delete mode 100644 spec/database_cleaner/active_record/base_spec.rb delete mode 100644 spec/database_cleaner/active_record/transaction_spec.rb delete mode 100644 spec/database_cleaner/active_record/truncation_spec.rb delete mode 100644 spec/database_cleaner/couch_potato/truncation_spec.rb delete mode 100644 spec/database_cleaner/data_mapper/base_spec.rb delete mode 100644 spec/database_cleaner/data_mapper/transaction_spec.rb delete mode 100644 spec/database_cleaner/data_mapper/truncation/sqlite3_spec.rb delete mode 100644 spec/database_cleaner/data_mapper/truncation_spec.rb delete mode 100644 spec/database_cleaner/generic/base_spec.rb delete mode 100644 spec/database_cleaner/generic/truncation_spec.rb delete mode 100644 spec/database_cleaner/mongo/mongo_examples.rb delete mode 100644 spec/database_cleaner/mongo/truncation_spec.rb delete mode 100644 spec/database_cleaner/mongo_mapper/base_spec.rb delete mode 100644 spec/database_cleaner/mongo_mapper/mongo_examples.rb delete mode 100644 spec/database_cleaner/mongo_mapper/truncation_spec.rb delete mode 100644 spec/database_cleaner/moped/moped_examples.rb delete mode 100644 spec/database_cleaner/moped/truncation_spec.rb delete mode 100644 spec/database_cleaner/neo4j/base_spec.rb delete mode 100644 spec/database_cleaner/neo4j/transaction_spec.rb delete mode 100644 spec/database_cleaner/ohm/truncation_spec.rb delete mode 100644 spec/database_cleaner/redis/base_spec.rb delete mode 100644 spec/database_cleaner/redis/truncation_spec.rb delete mode 100644 spec/database_cleaner/sequel/base_spec.rb delete mode 100644 spec/database_cleaner/sequel/deletion_spec.rb delete mode 100644 spec/database_cleaner/sequel/transaction_spec.rb delete mode 100644 spec/database_cleaner/sequel/truncation_spec.rb diff --git a/Gemfile b/Gemfile index 63284041..7e55a3bc 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,2 @@ gemspec -path "./adapters" do - gem "database_cleaner-active_record" - gem "database_cleaner-couch_potato" - gem "database_cleaner-data_mapper" - gem "database_cleaner-mongo" - gem "database_cleaner-mongoid" - gem "database_cleaner-mongo_mapper" - gem "database_cleaner-moped" - gem "database_cleaner-neo4j" - gem "database_cleaner-ohm" - gem "database_cleaner-redis" - gem "database_cleaner-sequel" -end diff --git a/Gemfile.lock b/Gemfile.lock index b9cbd9ee..ee56f508 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,47 +1,7 @@ PATH remote: . specs: - database_cleaner (1.8.2) - -PATH - remote: adapters - specs: - database_cleaner-active_record (1.8.0) - activerecord - database_cleaner (~> 1.8.0) - database_cleaner-couch_potato (1.8.0) - couch_potato - database_cleaner (~> 1.8.0) - database_cleaner-data_mapper (1.8.0) - database_cleaner (~> 1.8.0) - datamapper - dm-transactions - database_cleaner-mongo (1.8.0) - database_cleaner (~> 1.8.0) - mongo - database_cleaner-mongo_mapper (1.8.1) - database_cleaner (~> 1.8.0) - mongo_mapper - database_cleaner-mongoid (1.8.1) - database_cleaner (~> 1.8.0) - database_cleaner-mongo (~> 1.8.0) - mongoid - database_cleaner-moped (1.8.0) - database_cleaner (~> 1.8.0) - moped - database_cleaner-neo4j (1.8.0) - database_cleaner (~> 1.8.0) - neo4j-core - database_cleaner-ohm (1.8.1) - database_cleaner (~> 1.8.0) - database_cleaner-redis (~> 1.8.0) - ohm - database_cleaner-redis (1.8.0) - database_cleaner (~> 1.8.0) - redis - database_cleaner-sequel (1.8.0) - database_cleaner (~> 1.8.0) - sequel + database_cleaner (2.0.0.beta) GEM remote: https://rubygems.org/ @@ -287,17 +247,6 @@ DEPENDENCIES couch_potato cucumber database_cleaner! - database_cleaner-active_record! - database_cleaner-couch_potato! - database_cleaner-data_mapper! - database_cleaner-mongo! - database_cleaner-mongo_mapper! - database_cleaner-mongoid! - database_cleaner-moped! - database_cleaner-neo4j! - database_cleaner-ohm! - database_cleaner-redis! - database_cleaner-sequel! datamapper dm-migrations dm-sqlite-adapter diff --git a/Rakefile b/Rakefile index ffc098fd..e262d789 100644 --- a/Rakefile +++ b/Rakefile @@ -18,16 +18,7 @@ end require 'cucumber/rake/task' Cucumber::Rake::Task.new(:features) -desc "Run adapter test suites" -task :adapters do - Dir["adapters/*"].each do |adapter_dir| - Dir.chdir adapter_dir do - sh "bundle exec rake" - end - end -end - -task :default => [:spec, :features, :adapters] +task :default => [:spec, :features] desc "Cleans the project of any tmp file that should not be included in the gemspec." task :clean do diff --git a/adapters/database_cleaner-active_record/.gitignore b/adapters/database_cleaner-active_record/.gitignore deleted file mode 100644 index a2164d5d..00000000 --- a/adapters/database_cleaner-active_record/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/spec/support/config.yml -/tmp/ -!/tmp/.keep - -# rspec failure tracking -.rspec_status diff --git a/adapters/database_cleaner-active_record/.rspec b/adapters/database_cleaner-active_record/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/adapters/database_cleaner-active_record/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/adapters/database_cleaner-active_record/.travis.yml b/adapters/database_cleaner-active_record/.travis.yml deleted file mode 100644 index 9912d68f..00000000 --- a/adapters/database_cleaner-active_record/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -rvm: - - 2.2.9 -before_install: gem install bundler -v 1.17.2 diff --git a/adapters/database_cleaner-active_record/Gemfile b/adapters/database_cleaner-active_record/Gemfile deleted file mode 100644 index ac29054f..00000000 --- a/adapters/database_cleaner-active_record/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -# Specify your gem's dependencies in database_cleaner-active_record.gemspec -gemspec - -gem "database_cleaner", path: "../.." diff --git a/adapters/database_cleaner-active_record/Gemfile.lock b/adapters/database_cleaner-active_record/Gemfile.lock deleted file mode 100644 index 70790e53..00000000 --- a/adapters/database_cleaner-active_record/Gemfile.lock +++ /dev/null @@ -1,73 +0,0 @@ -PATH - remote: ../.. - specs: - database_cleaner (1.8.2) - -PATH - remote: . - specs: - database_cleaner-active_record (1.8.0) - activerecord - database_cleaner (~> 1.8.0) - -GEM - remote: https://rubygems.org/ - specs: - activemodel (5.2.4.1) - activesupport (= 5.2.4.1) - activerecord (5.2.4.1) - activemodel (= 5.2.4.1) - activesupport (= 5.2.4.1) - arel (>= 9.0) - activerecord-mysql2-adapter (0.0.3) - mysql2 - activesupport (5.2.4.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - arel (9.0.0) - concurrent-ruby (1.1.5) - diff-lcs (1.3) - i18n (1.5.1) - concurrent-ruby (~> 1.0) - minitest (5.14.0) - mysql (2.9.1) - mysql2 (0.3.18) - pg (0.18.2) - rake (10.4.2) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - sqlite3 (1.3.10) - thread_safe (0.3.6) - tzinfo (1.2.6) - thread_safe (~> 0.1) - -PLATFORMS - ruby - -DEPENDENCIES - activerecord-mysql2-adapter - bundler (~> 1.16) - database_cleaner! - database_cleaner-active_record! - mysql (~> 2.9.1) - mysql2 - pg - rake (~> 10.0) - rspec (~> 3.0) - sqlite3 - -BUNDLED WITH - 1.17.3 diff --git a/adapters/database_cleaner-active_record/LICENSE.txt b/adapters/database_cleaner-active_record/LICENSE.txt deleted file mode 100644 index 392bc0d3..00000000 --- a/adapters/database_cleaner-active_record/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2009 Ben Mabey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/adapters/database_cleaner-active_record/README.md b/adapters/database_cleaner-active_record/README.md deleted file mode 100644 index 9e66ece5..00000000 --- a/adapters/database_cleaner-active_record/README.md +++ /dev/null @@ -1,110 +0,0 @@ -# Database Cleaner Adapter for ActiveRecord - -[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-active_record.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-active_record) -[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-active_record/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-active_record) - -Clean your ActiveRecord databases with Database Cleaner. - -See https://github.com/DatabaseCleaner/database_cleaner for more information. - -## Installation - -```ruby -# Gemfile -group :test do - gem 'database_cleaner-active_record' -end -``` - -## Supported Strategies - -Here is an overview of the supported strategies: - - - - - - - - - - - - - - -
TruncationTransactionDeletion
Yes Yes Yes
- -(Default strategy is denoted in bold) - -For support or to discuss development please use the [Google Group](https://groups.google.com/group/database_cleaner). - -## What strategy is fastest? - -For the SQL libraries the fastest option will be to use `:transaction` as transactions are simply rolled back. If you can use this strategy you should. However, if you wind up needing to use multiple database connections in your tests (i.e. your tests run in a different process than your application) then using this strategy becomes a bit more difficult. You can get around the problem a number of ways. - -One common approach is to force all processes to use the same database connection ([common ActiveRecord hack](http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/)) however this approach has been reported to result in non-deterministic failures. - -Another approach is to have the transactions rolled back in the application's process and relax the isolation level of the database (so the tests can read the uncommitted transactions). - -An easier, but slower, solution is to use the `:truncation` or `:deletion` strategy. - -So what is fastest out of `:deletion` and `:truncation`? Well, it depends on your table structure and what percentage of tables you populate in an average test. The reasoning is out of the scope of this README but here is a [good SO answer on this topic for Postgres](https://stackoverflow.com/questions/11419536/postgresql-truncation-speed/11423886#11423886). - -Some people report much faster speeds with `:deletion` while others say `:truncation` is faster for them. The best approach therefore is it try all options on your test suite and see what is faster. - -If you are using ActiveRecord then take a look at the [additional options](#additional-activerecord-options-for-truncation) available for `:truncation`. - -## Configuration options - - - - - - - - - - - - - - -
ORMHow to accessNotes
Active Record DatabaseCleaner[:active_record] Connection specified as :symbol keys, loaded from config/database.yml. You may also pass in the ActiveRecord model under the :model key.
- -### Additional ActiveRecord options for Truncation - -The following options are available for ActiveRecord's `:truncation` strategy _only_ for MySQL and Postgres. - -* `:pre_count` - When set to `true` this will check each table for existing rows before truncating it. This can speed up test suites when many of the tables to be truncated are never populated. Defaults to `:false`. (Also, see the section on [What strategy is fastest?](#what-strategy-is-fastest)) -* `:reset_ids` - This only matters when `:pre_count` is used, and it will make sure that a tables auto-incrementing id is reset even if there are no rows in the table (e.g. records were created in the test but also removed before DatabaseCleaner gets to it). Defaults to `true`. - -The following option is available for ActiveRecord's `:truncation` and `:deletion` strategy for any DB. - -* `:cache_tables` - When set to `true` the list of tables to truncate or delete from will only be read from the DB once, otherwise it will be read before each cleanup run. Set this to `false` if (1) you create and drop tables in your tests, or (2) you change Postgres schemas (`ActiveRecord::Base.connection.schema_search_path`) in your tests (for example, in a multitenancy setup with each tenant in a different Postgres schema). Defaults to `true`. - - -## Common Errors - -### STDERR is being flooded when using Postgres - -If you are using Postgres and have foreign key constraints, the truncation strategy will cause a lot of extra noise to appear on STDERR (in the form of "NOTICE truncate cascades" messages). - -To silence these warnings set the following log level in your `postgresql.conf` file: - -```ruby -client_min_messages = warning -``` - -For ActiveRecord, you add the following parameter in your database.yml file: - -
-test:
-  adapter: postgresql
-  # ...
-  min_messages: WARNING  
-
- -## COPYRIGHT - -See [LICENSE] for details. diff --git a/adapters/database_cleaner-active_record/Rakefile b/adapters/database_cleaner-active_record/Rakefile deleted file mode 100644 index b7e9ed54..00000000 --- a/adapters/database_cleaner-active_record/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/adapters/database_cleaner-active_record/bin/console b/adapters/database_cleaner-active_record/bin/console deleted file mode 100755 index 90ef12a1..00000000 --- a/adapters/database_cleaner-active_record/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "database_cleaner/active_record" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/adapters/database_cleaner-active_record/bin/setup b/adapters/database_cleaner-active_record/bin/setup deleted file mode 100755 index 268b1b43..00000000 --- a/adapters/database_cleaner-active_record/bin/setup +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle check || bundle install -cp spec/support/sample.config.yml spec/support/config.yml - diff --git a/adapters/database_cleaner-active_record/database_cleaner-active_record.gemspec b/adapters/database_cleaner-active_record/database_cleaner-active_record.gemspec deleted file mode 100644 index 2b0d6d7e..00000000 --- a/adapters/database_cleaner-active_record/database_cleaner-active_record.gemspec +++ /dev/null @@ -1,40 +0,0 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/active_record/version" - -Gem::Specification.new do |spec| - spec.name = "database_cleaner-active_record" - spec.version = DatabaseCleaner::ActiveRecord::VERSION - spec.authors = ["Ernesto Tagwerker"] - spec.email = ["ernesto@ombulabs.com"] - - spec.summary = "Strategies for cleaning databases using ActiveRecord. Can be used to ensure a clean state for testing." - spec.description = "Strategies for cleaning databases using ActiveRecord. Can be used to ensure a clean state for testing." - spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-active_record" - spec.license = "MIT" - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency "database_cleaner", "~> 1.8.0" - spec.add_dependency "activerecord" - - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "bundler", "~> 1.16" - spec.add_development_dependency "rspec", "~> 3.0" - - unless RUBY_PLATFORM =~ /java/ - spec.add_development_dependency 'mysql', '~> 2.9.1' - spec.add_development_dependency 'mysql2' - spec.add_development_dependency "activerecord-mysql2-adapter" - spec.add_development_dependency 'pg' - spec.add_development_dependency "sqlite3" - else - spec.add_development_dependency "activerecord-jdbc-adapter" - end -end diff --git a/adapters/database_cleaner-active_record/lib/database_cleaner-active_record.rb b/adapters/database_cleaner-active_record/lib/database_cleaner-active_record.rb deleted file mode 100644 index ad7a57b3..00000000 --- a/adapters/database_cleaner-active_record/lib/database_cleaner-active_record.rb +++ /dev/null @@ -1 +0,0 @@ -require "database_cleaner/active_record" diff --git a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record.rb b/adapters/database_cleaner-active_record/lib/database_cleaner/active_record.rb deleted file mode 100644 index f90e80ad..00000000 --- a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'database_cleaner/active_record/version' -require 'database_cleaner' -require 'database_cleaner/active_record/deletion' -require 'database_cleaner/active_record/transaction' -require 'database_cleaner/active_record/truncation' - diff --git a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/base.rb b/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/base.rb deleted file mode 100644 index 8bf81020..00000000 --- a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/base.rb +++ /dev/null @@ -1,101 +0,0 @@ -require 'active_record' -require 'database_cleaner/generic/base' -require 'erb' -require 'yaml' - -module DatabaseCleaner - module ActiveRecord - def self.available_strategies - %w[truncation transaction deletion] - end - - def self.default_strategy - :transaction - end - - def self.config_file_location=(path) - @config_file_location = path - end - - def self.config_file_location - @config_file_location ||= begin - # Has DC.app_root been set? Check in this intrusive way to avoid triggering deprecation warnings if it hasn't. - app_root = DatabaseCleaner.send(:configuration).instance_variable_get(:@app_root) - root = app_root || Dir.pwd - "#{root}/config/database.yml" - end - end - - module Base - include ::DatabaseCleaner::Generic::Base - - attr_accessor :connection_hash - - def db=(desired_db) - @db = desired_db - load_config - end - - def db - @db ||= super - end - - def load_config - if self.db != :default && self.db.is_a?(Symbol) && File.file?(ActiveRecord.config_file_location) - connection_details = YAML::load(ERB.new(IO.read(ActiveRecord.config_file_location)).result) - @connection_hash = valid_config(connection_details)[self.db.to_s] - end - end - - def valid_config(connection_file) - if !::ActiveRecord::Base.configurations.nil? && !::ActiveRecord::Base.configurations.empty? - if connection_file != ::ActiveRecord::Base.configurations - return ::ActiveRecord::Base.configurations - end - end - connection_file - end - - def connection_class - @connection_class ||= if db && !db.is_a?(Symbol) - db - elsif connection_hash - lookup_from_connection_pool || establish_connection - else - ::ActiveRecord::Base - end - end - - def self.migration_table_name - if ::ActiveRecord::VERSION::MAJOR < 5 - ::ActiveRecord::Migrator.schema_migrations_table_name - else - ::ActiveRecord::SchemaMigration.table_name - end - end - - def self.exclusion_condition(column_name) - result = " #{column_name} <> '#{::DatabaseCleaner::ActiveRecord::Base.migration_table_name}' " - if ::ActiveRecord::VERSION::MAJOR >= 5 - result += " AND #{column_name} <> '#{::ActiveRecord::Base.internal_metadata_table_name}' " - end - result - end - - private - - def lookup_from_connection_pool - if ::ActiveRecord::Base.respond_to?(:descendants) - database_name = connection_hash["database"] || connection_hash[:database] - models = ::ActiveRecord::Base.descendants - models.select(&:connection_pool).detect { |m| m.connection_pool.spec.config[:database] == database_name } - end - end - - def establish_connection - ::ActiveRecord::Base.establish_connection(connection_hash) - ::ActiveRecord::Base - end - end - end -end diff --git a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/deletion.rb b/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/deletion.rb deleted file mode 100644 index 09d93942..00000000 --- a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/deletion.rb +++ /dev/null @@ -1,108 +0,0 @@ -require 'active_record' -require 'active_record/connection_adapters/abstract_adapter' -require "database_cleaner/generic/truncation" -require 'database_cleaner/active_record/truncation' - -module DatabaseCleaner - module ConnectionAdapters - module AbstractDeleteAdapter - def delete_table(table_name) - raise NotImplementedError - end - end - - module GenericDeleteAdapter - def delete_table(table_name) - execute("DELETE FROM #{quote_table_name(table_name)};") - end - end - - module OracleDeleteAdapter - def delete_table(table_name) - execute("DELETE FROM #{quote_table_name(table_name)}") - end - end - end -end - -module ActiveRecord - module ConnectionAdapters - AbstractAdapter.class_eval { include DatabaseCleaner::ConnectionAdapters::AbstractDeleteAdapter } - - JdbcAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::GenericDeleteAdapter } if defined?(JdbcAdapter) - AbstractMysqlAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::GenericDeleteAdapter } if defined?(AbstractMysqlAdapter) - Mysql2Adapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::GenericDeleteAdapter } if defined?(Mysql2Adapter) - SQLiteAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::GenericDeleteAdapter } if defined?(SQLiteAdapter) - SQLite3Adapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::GenericDeleteAdapter } if defined?(SQLite3Adapter) - PostgreSQLAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::GenericDeleteAdapter } if defined?(PostgreSQLAdapter) - IBM_DBAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::GenericDeleteAdapter } if defined?(IBM_DBAdapter) - SQLServerAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::GenericDeleteAdapter } if defined?(SQLServerAdapter) - OracleEnhancedAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::OracleDeleteAdapter } if defined?(OracleEnhancedAdapter) - end -end - -module DatabaseCleaner::ActiveRecord - module SelectiveTruncation - def tables_to_truncate(connection) - if information_schema_exists?(connection) - (@only || tables_with_new_rows(connection)) - @tables_to_exclude - else - super - end - end - - def tables_with_new_rows(connection) - stats = table_stats_query(connection) - if stats != '' - connection.select_values(stats) - else - [] - end - end - - def table_stats_query(connection) - @table_stats_query ||= build_table_stats_query(connection) - ensure - @table_stats_query = nil unless @cache_tables - end - - def build_table_stats_query(connection) - tables = connection.select_values(<<-SQL) - SELECT table_name - FROM information_schema.tables - WHERE table_schema = database() - AND #{::DatabaseCleaner::ActiveRecord::Base.exclusion_condition('table_name')}; - SQL - queries = tables.map do |table| - "(SELECT #{connection.quote(table)} FROM #{connection.quote_table_name(table)} LIMIT 1)" - end - queries.join(' UNION ALL ') - end - - def information_schema_exists? connection - return false unless connection.is_a? ActiveRecord::ConnectionAdapters::Mysql2Adapter - @information_schema_exists ||= - begin - connection.execute("SELECT 1 FROM information_schema.tables") - true - rescue - false - end - end - end - - class Deletion < Truncation - if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) - include SelectiveTruncation - end - - def clean - connection = connection_class.connection - connection.disable_referential_integrity do - tables_to_truncate(connection).each do |table_name| - connection.delete_table table_name - end - end - end - end -end diff --git a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/transaction.rb b/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/transaction.rb deleted file mode 100644 index 540011a2..00000000 --- a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/transaction.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'database_cleaner/active_record/base' -require 'database_cleaner/generic/transaction' - -module DatabaseCleaner::ActiveRecord - class Transaction - include ::DatabaseCleaner::ActiveRecord::Base - include ::DatabaseCleaner::Generic::Transaction - - def start - # Hack to make sure that the connection is properly setup for - # the clean code. - connection_class.connection.transaction{ } - - if connection_maintains_transaction_count? - if connection_class.connection.respond_to?(:increment_open_transactions) - connection_class.connection.increment_open_transactions - else - connection_class.__send__(:increment_open_transactions) - end - end - if connection_class.connection.respond_to?(:begin_transaction) - connection_class.connection.begin_transaction :joinable => false - else - connection_class.connection.begin_db_transaction - end - end - - - def clean - connection_class.connection_pool.connections.each do |connection| - next unless connection.open_transactions > 0 - - if connection.respond_to?(:rollback_transaction) - connection.rollback_transaction - else - connection.rollback_db_transaction - end - - # The below is for handling after_commit hooks.. see https://github.com/bmabey/database_cleaner/issues/99 - if connection.respond_to?(:rollback_transaction_records, true) - connection.send(:rollback_transaction_records, true) - end - - if connection_maintains_transaction_count? - if connection.respond_to?(:decrement_open_transactions) - connection.decrement_open_transactions - else - connection_class.__send__(:decrement_open_transactions) - end - end - end - end - - def connection_maintains_transaction_count? - ActiveRecord::VERSION::MAJOR < 4 - end - - end -end diff --git a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/truncation.rb b/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/truncation.rb deleted file mode 100644 index ed138530..00000000 --- a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/truncation.rb +++ /dev/null @@ -1,280 +0,0 @@ -require 'active_record/base' -require 'database_cleaner/active_record/base' -require 'active_record/connection_adapters/abstract_adapter' - -#Load available connection adapters -%w( - abstract_mysql_adapter postgresql_adapter sqlite3_adapter mysql_adapter mysql2_adapter oracle_enhanced_adapter -).each do |known_adapter| - begin - require "active_record/connection_adapters/#{known_adapter}" - rescue LoadError - end -end - -require "database_cleaner/generic/truncation" -require 'database_cleaner/active_record/base' - -module DatabaseCleaner - module ConnectionAdapters - - module AbstractAdapter - # used to be called views but that can clash with gems like schema_plus - # this gem is not meant to be exposing such an extra interface any way - def database_cleaner_view_cache - @views ||= select_values("select table_name from information_schema.views where table_schema = '#{current_database}'") rescue [] - end - - def database_cleaner_table_cache - # the adapters don't do caching (#130) but we make the assumption that the list stays the same in tests - @database_cleaner_tables ||= database_tables - end - - def database_tables - ::ActiveRecord::VERSION::MAJOR >= 5 ? data_sources : tables - end - - def truncate_table(table_name) - raise NotImplementedError - end - - def truncate_tables(tables) - tables.each do |table_name| - self.truncate_table(table_name) - end - end - end - - module AbstractMysqlAdapter - def truncate_table(table_name) - execute("TRUNCATE TABLE #{quote_table_name(table_name)};") - end - - def truncate_tables(tables) - tables.each { |t| truncate_table(t) } - end - - def pre_count_truncate_tables(tables, options = {:reset_ids => true}) - filter = options[:reset_ids] ? method(:has_been_used?) : method(:has_rows?) - truncate_tables(tables.select(&filter)) - end - - private - - def row_count(table) - # Patch for MysqlAdapter with ActiveRecord 3.2.7 later - # select_value("SELECT 1") #=> "1" - select_value("SELECT EXISTS (SELECT 1 FROM #{quote_table_name(table)} LIMIT 1)").to_i - end - - def auto_increment_value(table) - select_value(<<-SQL).to_i - SELECT auto_increment - FROM information_schema.tables - WHERE table_name = '#{table}' - AND table_schema = database() - SQL - end - - # This method tells us if the given table has been inserted into since its - # last truncation. Note that the table might have been populated, which - # increased the auto-increment counter, but then cleaned again such that - # it appears empty now. - def has_been_used?(table) - has_rows?(table) || auto_increment_value(table) > 1 - end - - def has_rows?(table) - row_count(table) > 0 - end - end - - module IBM_DBAdapter - def truncate_table(table_name) - execute("TRUNCATE #{quote_table_name(table_name)} IMMEDIATE") - end - end - - module SQLiteAdapter - def delete_table(table_name) - execute("DELETE FROM #{quote_table_name(table_name)};") - if uses_sequence - execute("DELETE FROM sqlite_sequence where name = '#{table_name}';") - end - end - alias truncate_table delete_table - - def truncate_tables(tables) - tables.each { |t| truncate_table(t) } - end - - private - - # Returns a boolean indicating if the SQLite database is using the sqlite_sequence table. - def uses_sequence - select_value("SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';") - end - end - - module TruncateOrDelete - def truncate_table(table_name) - begin - execute("TRUNCATE TABLE #{quote_table_name(table_name)};") - rescue ::ActiveRecord::StatementInvalid - execute("DELETE FROM #{quote_table_name(table_name)};") - end - end - end - - module OracleAdapter - def truncate_table(table_name) - execute("TRUNCATE TABLE #{quote_table_name(table_name)}") - end - end - - module PostgreSQLAdapter - def db_version - @db_version ||= postgresql_version - end - - def cascade - @cascade ||= db_version >= 80200 ? 'CASCADE' : '' - end - - def restart_identity - @restart_identity ||= db_version >= 80400 ? 'RESTART IDENTITY' : '' - end - - def truncate_table(table_name) - truncate_tables([table_name]) - end - - def truncate_tables(table_names) - return if table_names.nil? || table_names.empty? - execute("TRUNCATE TABLE #{table_names.map{|name| quote_table_name(name)}.join(', ')} #{restart_identity} #{cascade};") - end - - def pre_count_truncate_tables(tables, options = {:reset_ids => true}) - filter = options[:reset_ids] ? method(:has_been_used?) : method(:has_rows?) - truncate_tables(tables.select(&filter)) - end - - def database_cleaner_table_cache - # AR returns a list of tables without schema but then returns a - # migrations table with the schema. There are other problems, too, - # with using the base list. If a table exists in multiple schemas - # within the search path, truncation without the schema name could - # result in confusing, if not unexpected results. - @database_cleaner_tables ||= tables_with_schema - end - - private - - # Returns a boolean indicating if the given table has an auto-inc number higher than 0. - # Note, this is different than an empty table since an table may populated, the index increased, - # but then the table is cleaned. In other words, this function tells us if the given table - # was ever inserted into. - def has_been_used?(table) - return has_rows?(table) unless has_sequence?(table) - - cur_val = select_value("SELECT currval('#{table}_id_seq');").to_i rescue 0 - cur_val > 0 - end - - def has_sequence?(table) - select_value("SELECT true FROM pg_class WHERE relname = '#{table}_id_seq';") - end - - def has_rows?(table) - select_value("SELECT true FROM #{table} LIMIT 1;") - end - - def tables_with_schema - rows = select_rows <<-_SQL - SELECT schemaname || '.' || tablename - FROM pg_tables - WHERE - tablename !~ '_prt_' AND - #{::DatabaseCleaner::ActiveRecord::Base.exclusion_condition('tablename')} AND - schemaname = ANY (current_schemas(false)) - _SQL - rows.collect { |result| result.first } - end - end - end -end - -module ActiveRecord - module ConnectionAdapters - #Apply adapter decoraters where applicable (adapter should be loaded) - AbstractAdapter.class_eval { include DatabaseCleaner::ConnectionAdapters::AbstractAdapter } - - if defined?(JdbcAdapter) - if defined?(OracleJdbcConnection) - JdbcAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::OracleAdapter } - else - JdbcAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::TruncateOrDelete } - end - end - AbstractMysqlAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::AbstractMysqlAdapter } if defined?(AbstractMysqlAdapter) - Mysql2Adapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::AbstractMysqlAdapter } if defined?(Mysql2Adapter) - MysqlAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::AbstractMysqlAdapter } if defined?(MysqlAdapter) - SQLiteAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::SQLiteAdapter } if defined?(SQLiteAdapter) - SQLite3Adapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::SQLiteAdapter } if defined?(SQLite3Adapter) - PostgreSQLAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::PostgreSQLAdapter } if defined?(PostgreSQLAdapter) - IBM_DBAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::IBM_DBAdapter } if defined?(IBM_DBAdapter) - SQLServerAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::TruncateOrDelete } if defined?(SQLServerAdapter) - OracleEnhancedAdapter.class_eval { include ::DatabaseCleaner::ConnectionAdapters::OracleAdapter } if defined?(OracleEnhancedAdapter) - end -end - -module DatabaseCleaner::ActiveRecord - class Truncation - include ::DatabaseCleaner::ActiveRecord::Base - include ::DatabaseCleaner::Generic::Truncation - - def clean - connection = connection_class.connection - connection.disable_referential_integrity do - if pre_count? && connection.respond_to?(:pre_count_truncate_tables) - connection.pre_count_truncate_tables(tables_to_truncate(connection), {:reset_ids => reset_ids?}) - else - connection.truncate_tables(tables_to_truncate(connection)) - end - end - end - - private - - def tables_to_truncate(connection) - tables_in_db = cache_tables? ? connection.database_cleaner_table_cache : connection.database_tables - to_reject = (@tables_to_exclude + connection.database_cleaner_view_cache) - (@only || tables_in_db).reject do |table| - if ( m = table.match(/([^.]+)$/) ) - to_reject.include?(m[1]) - else - false - end - end - end - - # overwritten - def migration_storage_names - result = [::DatabaseCleaner::ActiveRecord::Base.migration_table_name] - result << ::ActiveRecord::Base.internal_metadata_table_name if ::ActiveRecord::VERSION::MAJOR >= 5 - result - end - - def cache_tables? - !!@cache_tables - end - - def pre_count? - @pre_count == true - end - - def reset_ids? - @reset_ids != false - end - end -end diff --git a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/version.rb b/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/version.rb deleted file mode 100644 index 29fe3e18..00000000 --- a/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DatabaseCleaner - module ActiveRecord - VERSION = "1.8.0" - end -end diff --git a/adapters/database_cleaner-active_record/spec/database_cleaner/active_record/base_spec.rb b/adapters/database_cleaner-active_record/spec/database_cleaner/active_record/base_spec.rb deleted file mode 100644 index 10243293..00000000 --- a/adapters/database_cleaner-active_record/spec/database_cleaner/active_record/base_spec.rb +++ /dev/null @@ -1,170 +0,0 @@ -require 'active_record' -require 'database_cleaner/active_record/base' -require 'database_cleaner/spec' - -class FakeModel - def self.connection - :fake_connection - end -end - -RSpec.describe DatabaseCleaner::ActiveRecord do - it { is_expected.to respond_to(:available_strategies) } - - it "has a default_strategy of transaction" do - expect(described_class.default_strategy).to eq(:transaction) - end - - describe "config_file_location" do - after do - # prevent global state leakage - DatabaseCleaner::ActiveRecord.config_file_location=nil - DatabaseCleaner.app_root = nil - end - - it "should default to \#{DatabaseCleaner.app_root}/config/database.yml" do - DatabaseCleaner::ActiveRecord.config_file_location = nil - DatabaseCleaner.app_root = "/path/to" - expect(DatabaseCleaner::ActiveRecord.config_file_location).to eq '/path/to/config/database.yml' - end - end -end - -module DatabaseCleaner - module ActiveRecord - class ExampleStrategy - include DatabaseCleaner::ActiveRecord::Base - end - - RSpec.describe ExampleStrategy do - let(:config_location) { '/path/to/config/database.yml' } - - around do |example| - DatabaseCleaner::ActiveRecord.config_file_location = config_location - example.run - DatabaseCleaner::ActiveRecord.config_file_location = nil - end - - it_should_behave_like "a generic strategy" - - describe "db" do - it "should store my desired db" do - subject.db = :my_db - expect(subject.db).to eq :my_db - end - - it "should default to :default" do - expect(subject.db).to eq :default - end - end - - describe "db=" do - let(:config_location) { "spec/support/example.database.yml" } - - it "should process erb in the config" do - subject.db = :my_db - expect(subject.connection_hash).to eq({ "database" => "one" }) - end - - context 'when config file differs from established ActiveRecord configuration' do - before do - allow(::ActiveRecord::Base).to receive(:configurations).and_return({ "my_db" => { "database" => "two"} }) - end - - it 'uses the ActiveRecord configuration' do - subject.db = :my_db - expect(subject.connection_hash).to eq({ "database" => "two"}) - end - end - - context 'when config file agrees with ActiveRecord configuration' do - before do - allow(::ActiveRecord::Base).to receive(:configurations).and_return({ "my_db" => { "database" => "one"} }) - end - - it 'uses the config file' do - subject.db = :my_db - expect(subject.connection_hash).to eq({ "database" => "one"}) - end - end - - context 'when ::ActiveRecord::Base.configurations nil' do - before do - allow(::ActiveRecord::Base).to receive(:configurations).and_return(nil) - end - - it 'uses the config file' do - subject.db = :my_db - expect(subject.connection_hash).to eq({ "database" => "one"}) - end - end - - context 'when ::ActiveRecord::Base.configurations empty' do - before do - allow(::ActiveRecord::Base).to receive(:configurations).and_return({}) - end - - it 'uses the config file' do - subject.db = :my_db - expect(subject.connection_hash).to eq({ "database" => "one"}) - end - end - - context 'when config file is not available' do - before do - allow(File).to receive(:file?).with(config_location).and_return(false) - end - - it "should skip config" do - subject.db = :my_db - expect(subject.connection_hash).not_to be - end - end - - it "skips the file when the model is set" do - subject.db = FakeModel - expect(subject.connection_hash).not_to be - end - - it "skips the file when the db is set to :default" do - # to avoid https://github.com/bmabey/database_cleaner/issues/72 - subject.db = :default - expect(subject.connection_hash).not_to be - end - end - - describe "connection_class" do - it "should default to ActiveRecord::Base" do - expect(subject.connection_class).to eq ::ActiveRecord::Base - end - - context "with database models" do - context "connection_hash is set" do - it "reuses the model's connection" do - subject.connection_hash = {} - subject.db = FakeModel - expect(subject.connection_class).to eq FakeModel - end - end - - context "connection_hash is not set" do - it "reuses the model's connection" do - subject.db = FakeModel - expect(subject.connection_class).to eq FakeModel - end - end - end - - context "when connection_hash is set" do - let(:hash) { {} } - before { subject.connection_hash = hash } - - it "establishes a connection with it" do - expect(::ActiveRecord::Base).to receive(:establish_connection).with(hash) - expect(subject.connection_class).to eq ::ActiveRecord::Base - end - end - end - end - end -end diff --git a/adapters/database_cleaner-active_record/spec/database_cleaner/active_record/transaction_spec.rb b/adapters/database_cleaner-active_record/spec/database_cleaner/active_record/transaction_spec.rb deleted file mode 100644 index c6fbdb10..00000000 --- a/adapters/database_cleaner-active_record/spec/database_cleaner/active_record/transaction_spec.rb +++ /dev/null @@ -1,155 +0,0 @@ -require 'database_cleaner/active_record/transaction' -require 'active_record' - -module DatabaseCleaner - module ActiveRecord - - RSpec.describe Transaction do - let(:connection) { double("connection") } - let(:connection_2) { double("connection_2") } - let(:connection_pool) { double("connection_pool") } - - before do - allow(::ActiveRecord::Base).to receive(:connection_pool).and_return(connection_pool) - allow(connection_pool).to receive(:connections).and_return([connection]) - allow(::ActiveRecord::Base).to receive(:connection).and_return(connection) - end - - describe "#start" do - [:begin_transaction, :begin_db_transaction].each do |begin_transaction_method| - context "using #{begin_transaction_method}" do - before do - allow(connection).to receive(:transaction) - allow(connection).to receive(begin_transaction_method) - end - - it "should increment open transactions if possible" do - expect(connection).to receive(:increment_open_transactions) - subject.start - end - - it "should tell ActiveRecord to increment connection if its not possible to increment current connection" do - expect(::ActiveRecord::Base).to receive(:increment_open_transactions) - subject.start - end - - it "should start a transaction" do - allow(connection).to receive(:increment_open_transactions) - expect(connection).to receive(begin_transaction_method) - expect(connection).to receive(:transaction) - subject.start - end - end - end - end - - describe "#clean" do - context "manual accounting of transaction count" do - it "should start a transaction" do - expect(connection).to receive(:open_transactions).and_return(1) - - allow(connection).to receive(:decrement_open_transactions) - - expect(connection).to receive(:rollback_db_transaction) - subject.clean - end - - it "should decrement open transactions if possible" do - expect(connection).to receive(:open_transactions).and_return(1) - - allow(connection).to receive(:rollback_db_transaction) - - expect(connection).to receive(:decrement_open_transactions) - subject.clean - end - - it "should not try to decrement or rollback if open_transactions is 0 for whatever reason" do - expect(connection).to receive(:open_transactions).and_return(0) - - subject.clean - end - - it "should decrement connection via ActiveRecord::Base if connection won't" do - expect(connection).to receive(:open_transactions).and_return(1) - allow(connection).to receive(:rollback_db_transaction) - - expect(::ActiveRecord::Base).to receive(:decrement_open_transactions) - subject.clean - end - - it "should rollback open transactions in all connections" do - allow(connection_pool).to receive(:connections).and_return([connection, connection_2]) - - expect(connection).to receive(:open_transactions).and_return(1) - allow(connection).to receive(:rollback_db_transaction) - - expect(connection_2).to receive(:open_transactions).and_return(1) - allow(connection_2).to receive(:rollback_db_transaction) - - expect(::ActiveRecord::Base).to receive(:decrement_open_transactions).twice - subject.clean - end - - it "should rollback open transactions in all connections with an open transaction" do - allow(connection_pool).to receive(:connections).and_return([connection, connection_2]) - - expect(connection).to receive(:open_transactions).and_return(1) - allow(connection).to receive(:rollback_db_transaction) - - expect(connection_2).to receive(:open_transactions).and_return(0) - - expect(::ActiveRecord::Base).to receive(:decrement_open_transactions).exactly(1).times - subject.clean - end - end - - context "automatic accounting of transaction count (AR 4)" do - before { stub_const("ActiveRecord::VERSION::MAJOR", 4) } - - it "should start a transaction" do - allow(connection).to receive(:rollback_db_transaction) - expect(connection).to receive(:open_transactions).and_return(1) - - expect(connection).not_to receive(:decrement_open_transactions) - expect(connection).to receive(:rollback_transaction) - subject.clean - end - - it "should decrement open transactions if possible" do - allow(connection).to receive(:rollback_transaction) - expect(connection).to receive(:open_transactions).and_return(1) - - expect(connection).not_to receive(:decrement_open_transactions) - subject.clean - end - - it "should not try to decrement or rollback if open_transactions is 0 for whatever reason" do - expect(connection).to receive(:open_transactions).and_return(0) - - subject.clean - end - - it "should decrement connection via ActiveRecord::Base if connection won't" do - expect(connection).to receive(:open_transactions).and_return(1) - allow(connection).to receive(:rollback_transaction) - - expect(::ActiveRecord::Base).not_to receive(:decrement_open_transactions) - subject.clean - end - end - end - - describe "#connection_maintains_transaction_count?" do - it "should return true if the major active record version is < 4" do - stub_const("ActiveRecord::VERSION::MAJOR", 3) - expect(subject.connection_maintains_transaction_count?).to be_truthy - end - - it "should return false if the major active record version is > 3" do - stub_const("ActiveRecord::VERSION::MAJOR", 4) - expect(subject.connection_maintains_transaction_count?).to be_falsey - end - end - end - end -end diff --git a/adapters/database_cleaner-active_record/spec/database_cleaner/active_record/truncation_spec.rb b/adapters/database_cleaner-active_record/spec/database_cleaner/active_record/truncation_spec.rb deleted file mode 100644 index fff56b53..00000000 --- a/adapters/database_cleaner-active_record/spec/database_cleaner/active_record/truncation_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'support/active_record_helper' -require 'database_cleaner/active_record/truncation' - -RSpec.describe DatabaseCleaner::ActiveRecord::Truncation do - ActiveRecordHelper.with_all_dbs do |helper| - context "using a #{helper.db} connection" do - around do |example| - helper.setup - example.run - helper.teardown - end - - let(:connection) { helper.connection } - - before do - allow(connection).to receive(:disable_referential_integrity).and_yield - allow(connection).to receive(:database_cleaner_view_cache).and_return([]) - end - - describe '#clean' do - context "with records" do - before do - 2.times { User.create! } - 2.times { Agent.create! } - end - - it "should truncate all tables" do - expect { subject.clean } - .to change { [User.count, Agent.count] } - .from([2,2]) - .to([0,0]) - end - - it "should reset AUTO_INCREMENT index of table" do - subject.clean - expect(User.create.id).to eq 1 - end - - xit "should not reset AUTO_INCREMENT index of table if :reset_ids is false" do - described_class.new(reset_ids: false).clean - expect(User.create.id).to eq 3 - end - - it "should truncate all tables except for schema_migrations" do - subject.clean - count = connection.select_value("select count(*) from schema_migrations;").to_i - expect(count).to eq 2 - end - - it "should only truncate the tables specified in the :only option when provided" do - expect { described_class.new(only: ['agents']).clean } - .to change { [User.count, Agent.count] } - .from([2,2]) - .to([2,0]) - end - - it "should not truncate the tables specified in the :except option" do - expect { described_class.new(except: ['users']).clean } - .to change { [User.count, Agent.count] } - .from([2,2]) - .to([2,0]) - end - - it "should raise an error when :only and :except options are used" do - expect { - described_class.new(except: ['widgets'], only: ['widgets']) - }.to raise_error(ArgumentError) - end - - it "should raise an error when invalid options are provided" do - expect { described_class.new(foo: 'bar') }.to raise_error(ArgumentError) - end - - it "should not truncate views" do - allow(connection).to receive(:database_cleaner_table_cache).and_return(%w[widgets dogs]) - allow(connection).to receive(:database_cleaner_view_cache).and_return(["widgets"]) - - expect(connection).to receive(:truncate_tables).with(['dogs']) - - subject.clean - end - end - - describe "with pre_count optimization option" do - subject { described_class.new(pre_count: true) } - - it "only truncates non-empty tables" do - pending if helper.db == :sqlite3 - pending if helper.db == :postgres - - User.create! - - expect(connection).to receive(:truncate_tables).with(['users']) - subject.clean - end - end - - context 'when :cache_tables is set to true' do - it 'caches the list of tables to be truncated' do - expect(connection).to receive(:database_cleaner_table_cache).and_return([]) - expect(connection).not_to receive(:tables) - - allow(connection).to receive(:truncate_tables) - described_class.new(cache_tables: true).clean - end - end - - context 'when :cache_tables is set to false' do - it 'does not cache the list of tables to be truncated' do - expect(connection).not_to receive(:database_cleaner_table_cache) - expect(connection).to receive(:tables).and_return([]) - - allow(connection).to receive(:truncate_tables) - described_class.new(cache_tables: false).clean - end - end - end - end - end -end diff --git a/adapters/database_cleaner-active_record/spec/spec_helper.rb b/adapters/database_cleaner-active_record/spec/spec_helper.rb deleted file mode 100644 index b58e50e3..00000000 --- a/adapters/database_cleaner-active_record/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "bundler/setup" -require 'database_cleaner' - -RSpec.configure do |config| - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true - - config.disable_monkey_patching! -end - diff --git a/adapters/database_cleaner-active_record/spec/support/active_record_helper.rb b/adapters/database_cleaner-active_record/spec/support/active_record_helper.rb deleted file mode 100644 index 5041e974..00000000 --- a/adapters/database_cleaner-active_record/spec/support/active_record_helper.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'active_record' -require 'database_cleaner/spec/database_helper' - -class ActiveRecordHelper < DatabaseCleaner::Spec::DatabaseHelper - def setup - patch_mysql_adapters - - Kernel.const_set "User", Class.new(ActiveRecord::Base) - Kernel.const_set "Agent", Class.new(ActiveRecord::Base) - - super - - connection.execute "CREATE TABLE IF NOT EXISTS schema_migrations (version VARCHAR(255));" - connection.execute "INSERT INTO schema_migrations VALUES (1), (2);" - end - - def teardown - connection.execute "DROP TABLE schema_migrations;" - - super - - Kernel.send :remove_const, "User" if defined?(User) - Kernel.send :remove_const, "Agent" if defined?(Agent) - end - - private - - def establish_connection(config = default_config) - ActiveRecord::Base.establish_connection(config) - @connection = ActiveRecord::Base.connection - end - - def patch_mysql_adapters - # remove DEFAULT NULL from column definition, which is an error on primary keys in MySQL 5.7.3+ - primary_key_sql = "int(11) auto_increment PRIMARY KEY" - ActiveRecord::ConnectionAdapters::MysqlAdapter::NATIVE_DATABASE_TYPES[:primary_key] = primary_key_sql - ActiveRecord::ConnectionAdapters::Mysql2Adapter::NATIVE_DATABASE_TYPES[:primary_key] = primary_key_sql - end -end - diff --git a/adapters/database_cleaner-active_record/spec/support/example.database.yml b/adapters/database_cleaner-active_record/spec/support/example.database.yml deleted file mode 100644 index bddb4dc2..00000000 --- a/adapters/database_cleaner-active_record/spec/support/example.database.yml +++ /dev/null @@ -1,3 +0,0 @@ -my_db: - database: <%= "ONE".downcase %> - diff --git a/adapters/database_cleaner-active_record/spec/support/sample.config.yml b/adapters/database_cleaner-active_record/spec/support/sample.config.yml deleted file mode 100644 index 90132c0d..00000000 --- a/adapters/database_cleaner-active_record/spec/support/sample.config.yml +++ /dev/null @@ -1,34 +0,0 @@ -mysql: - adapter: mysql - database: database_cleaner_test - username: root - password: - host: 127.0.0.1 - port: 3306 - encoding: utf8 - -mysql2: - adapter: mysql2 - database: database_cleaner_test - username: root - password: - host: 127.0.0.1 - port: 3306 - encoding: utf8 - -postgres: - adapter: postgresql - database: database_cleaner_test - username: postgres - password: - host: 127.0.0.1 - encoding: unicode - template: template0 - -sqlite3: - adapter: sqlite3 - database: tmp/database_cleaner_test.sqlite3 - pool: 5 - timeout: 5000 - encoding: utf8 - diff --git a/adapters/database_cleaner-active_record/tmp/.keep b/adapters/database_cleaner-active_record/tmp/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/adapters/database_cleaner-couch_potato/.gitignore b/adapters/database_cleaner-couch_potato/.gitignore deleted file mode 100644 index b04a8c84..00000000 --- a/adapters/database_cleaner-couch_potato/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/tmp/ - -# rspec failure tracking -.rspec_status diff --git a/adapters/database_cleaner-couch_potato/.rspec b/adapters/database_cleaner-couch_potato/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/adapters/database_cleaner-couch_potato/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/adapters/database_cleaner-couch_potato/.travis.yml b/adapters/database_cleaner-couch_potato/.travis.yml deleted file mode 100644 index 9912d68f..00000000 --- a/adapters/database_cleaner-couch_potato/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -rvm: - - 2.2.9 -before_install: gem install bundler -v 1.17.2 diff --git a/adapters/database_cleaner-couch_potato/Gemfile b/adapters/database_cleaner-couch_potato/Gemfile deleted file mode 100644 index c426b92d..00000000 --- a/adapters/database_cleaner-couch_potato/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -# Specify your gem's dependencies in database_cleaner-couch_potato.gemspec -gemspec - -gem "database_cleaner", path: "../.." diff --git a/adapters/database_cleaner-couch_potato/Gemfile.lock b/adapters/database_cleaner-couch_potato/Gemfile.lock deleted file mode 100644 index 7ab3bb5a..00000000 --- a/adapters/database_cleaner-couch_potato/Gemfile.lock +++ /dev/null @@ -1,80 +0,0 @@ -PATH - remote: ../.. - specs: - database_cleaner (1.8.2) - -PATH - remote: . - specs: - database_cleaner-couch_potato (1.8.0) - couch_potato - database_cleaner (~> 1.8.0) - -GEM - remote: https://rubygems.org/ - specs: - activemodel (5.2.4.1) - activesupport (= 5.2.4.1) - activesupport (5.2.4.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - concurrent-ruby (1.1.5) - couch_potato (1.3.0) - activemodel - couchrest (~> 1.2.0) - json (~> 1.6) - couchrest (1.2.1) - mime-types (>= 1.15) - multi_json (~> 1.7, ~> 1.0) - rest-client (~> 1.8.0) - diff-lcs (1.3) - domain_name (0.5.20180417) - unf (>= 0.0.5, < 1.0.0) - http-cookie (1.0.3) - domain_name (~> 0.5) - i18n (1.5.1) - concurrent-ruby (~> 1.0) - json (1.8.6) - mime-types (2.99.3) - minitest (5.14.0) - multi_json (1.14.1) - netrc (0.11.0) - rake (10.4.2) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - thread_safe (0.3.6) - tzinfo (1.2.6) - thread_safe (~> 0.1) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.5) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.16) - database_cleaner! - database_cleaner-couch_potato! - rake (~> 10.0) - rspec (~> 3.0) - -BUNDLED WITH - 1.17.3 diff --git a/adapters/database_cleaner-couch_potato/LICENSE.txt b/adapters/database_cleaner-couch_potato/LICENSE.txt deleted file mode 100644 index 392bc0d3..00000000 --- a/adapters/database_cleaner-couch_potato/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2009 Ben Mabey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/adapters/database_cleaner-couch_potato/README.md b/adapters/database_cleaner-couch_potato/README.md deleted file mode 100644 index a7626257..00000000 --- a/adapters/database_cleaner-couch_potato/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# Database Cleaner Adapter for CouchPotato - -[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-couch_potato.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-couch_potato) -[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-couch_potato/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-couch_potato) - -Clean your CouchPotato databases with Database Cleaner. - -See https://github.com/DatabaseCleaner/database_cleaner for more information. - -## Installation - -```ruby -# Gemfile -group :test do - gem 'database_cleaner-couch_potato' -end -``` - -## Supported Strategies - -Here is an overview of the supported strategies: - - - - - - - - - - - - - - -
TruncationTransactionDeletion
Yes No No
- -(Default strategy is denoted in bold) - -## Configuration options - - - - - - - - - - - - - - -
ORMHow to accessNotes
Couch Potato DatabaseCleaner[:couch_potato] Multiple connections not yet supported
- -## COPYRIGHT - -See [LICENSE] for details. diff --git a/adapters/database_cleaner-couch_potato/Rakefile b/adapters/database_cleaner-couch_potato/Rakefile deleted file mode 100644 index b7e9ed54..00000000 --- a/adapters/database_cleaner-couch_potato/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/adapters/database_cleaner-couch_potato/bin/console b/adapters/database_cleaner-couch_potato/bin/console deleted file mode 100755 index 5f181adb..00000000 --- a/adapters/database_cleaner-couch_potato/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "database_cleaner/couch_potato" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/adapters/database_cleaner-couch_potato/bin/setup b/adapters/database_cleaner-couch_potato/bin/setup deleted file mode 100755 index 3b72cbcc..00000000 --- a/adapters/database_cleaner-couch_potato/bin/setup +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle check || bundle install diff --git a/adapters/database_cleaner-couch_potato/database_cleaner-couch_potato.gemspec b/adapters/database_cleaner-couch_potato/database_cleaner-couch_potato.gemspec deleted file mode 100644 index 1b2f1324..00000000 --- a/adapters/database_cleaner-couch_potato/database_cleaner-couch_potato.gemspec +++ /dev/null @@ -1,30 +0,0 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/couch_potato/version" - -Gem::Specification.new do |spec| - spec.name = "database_cleaner-couch_potato" - spec.version = DatabaseCleaner::CouchPotato::VERSION - spec.authors = ["Ernesto Tagwerker"] - spec.email = ["ernesto@ombulabs.com"] - - spec.summary = "Strategies for cleaning databases using CouchPotato. Can be used to ensure a clean state for testing." - spec.description = "Strategies for cleaning databases using CouchPotato. Can be used to ensure a clean state for testing." - spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-couch_potato" - spec.license = "MIT" - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency "database_cleaner", "~> 1.8.0" - spec.add_dependency "couch_potato" - - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "bundler", "~> 1.16" - spec.add_development_dependency "rspec", "~> 3.0" -end diff --git a/adapters/database_cleaner-couch_potato/lib/database_cleaner-couch_potato.rb b/adapters/database_cleaner-couch_potato/lib/database_cleaner-couch_potato.rb deleted file mode 100644 index c407d569..00000000 --- a/adapters/database_cleaner-couch_potato/lib/database_cleaner-couch_potato.rb +++ /dev/null @@ -1 +0,0 @@ -require "database_cleaner/couch_potato" diff --git a/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato.rb b/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato.rb deleted file mode 100644 index 21e6fa3e..00000000 --- a/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "database_cleaner/couch_potato/version" -require "database_cleaner" -require "database_cleaner/couch_potato/base" -require "database_cleaner/couch_potato/truncation" - -module DatabaseCleaner::CouchPotato - def self.default_strategy - :truncation - end -end - diff --git a/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/base.rb b/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/base.rb deleted file mode 100644 index b53a52af..00000000 --- a/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/base.rb +++ /dev/null @@ -1,7 +0,0 @@ -module DatabaseCleaner - module CouchPotato - def self.available_strategies - %w[truncation] - end - end -end diff --git a/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/truncation.rb b/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/truncation.rb deleted file mode 100644 index 5a163aa4..00000000 --- a/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/truncation.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'database_cleaner/generic/truncation' - -module DatabaseCleaner - module CouchPotato - class Truncation - include ::DatabaseCleaner::Generic::Truncation - - def initialize(options = {}) - if options.has_key?(:only) || options.has_key?(:except) - raise ArgumentError, "The :only and :except options are not available for use with CouchPotato/CouchDB." - elsif !options.empty? - raise ArgumentError, "Unsupported option. You specified #{options.keys.join(',')}." - end - super - end - - def clean - database.recreate! - end - - private - - def database - ::CouchPotato.couchrest_database - end - end - end -end diff --git a/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/version.rb b/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/version.rb deleted file mode 100644 index 03a54d83..00000000 --- a/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DatabaseCleaner - module CouchPotato - VERSION = "1.8.0" - end -end diff --git a/adapters/database_cleaner-couch_potato/spec/database_cleaner/couch_potato/base_spec.rb b/adapters/database_cleaner-couch_potato/spec/database_cleaner/couch_potato/base_spec.rb deleted file mode 100644 index 734ebb85..00000000 --- a/adapters/database_cleaner-couch_potato/spec/database_cleaner/couch_potato/base_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'database_cleaner/couch_potato' - -RSpec.describe DatabaseCleaner::CouchPotato do - it "has a default_strategy of truncation" do - expect(described_class.default_strategy).to eq(:truncation) - end -end - diff --git a/adapters/database_cleaner-couch_potato/spec/database_cleaner/couch_potato/truncation_spec.rb b/adapters/database_cleaner-couch_potato/spec/database_cleaner/couch_potato/truncation_spec.rb deleted file mode 100644 index 8f4360a4..00000000 --- a/adapters/database_cleaner-couch_potato/spec/database_cleaner/couch_potato/truncation_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'database_cleaner/couch_potato/truncation' -require 'couch_potato' - -module DatabaseCleaner - module CouchPotato - - RSpec.describe Truncation do - let(:database) { double('database') } - - before(:each) do - allow(::CouchPotato).to receive(:couchrest_database).and_return(database) - end - - it "should re-create the database" do - expect(database).to receive(:recreate!) - - Truncation.new.clean - end - - it "should raise an error when the :only option is used" do - expect { - Truncation.new(:only => ['document-type']) - }.to raise_error(ArgumentError) - end - - it "should raise an error when the :except option is used" do - expect { - Truncation.new(:except => ['document-type']) - }.to raise_error(ArgumentError) - end - - it "should raise an error when invalid options are provided" do - expect { - Truncation.new(:foo => 'bar') - }.to raise_error(ArgumentError) - end - end - - end -end diff --git a/adapters/database_cleaner-couch_potato/spec/spec_helper.rb b/adapters/database_cleaner-couch_potato/spec/spec_helper.rb deleted file mode 100644 index 1cd4ded2..00000000 --- a/adapters/database_cleaner-couch_potato/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "bundler/setup" -require "database_cleaner/couch_potato" - -RSpec.configure do |config| - # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" - - # Disable RSpec exposing methods globally on `Module` and `main` - config.disable_monkey_patching! - - config.expect_with :rspec do |c| - c.syntax = :expect - end -end diff --git a/adapters/database_cleaner-data_mapper/.gitignore b/adapters/database_cleaner-data_mapper/.gitignore deleted file mode 100644 index a2164d5d..00000000 --- a/adapters/database_cleaner-data_mapper/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/spec/support/config.yml -/tmp/ -!/tmp/.keep - -# rspec failure tracking -.rspec_status diff --git a/adapters/database_cleaner-data_mapper/.rspec b/adapters/database_cleaner-data_mapper/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/adapters/database_cleaner-data_mapper/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/adapters/database_cleaner-data_mapper/.travis.yml b/adapters/database_cleaner-data_mapper/.travis.yml deleted file mode 100644 index 9912d68f..00000000 --- a/adapters/database_cleaner-data_mapper/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -rvm: - - 2.2.9 -before_install: gem install bundler -v 1.17.2 diff --git a/adapters/database_cleaner-data_mapper/Gemfile b/adapters/database_cleaner-data_mapper/Gemfile deleted file mode 100644 index 10d5f586..00000000 --- a/adapters/database_cleaner-data_mapper/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -# Specify your gem's dependencies in database_cleaner-data_mapper.gemspec -gemspec - -gem "database_cleaner", path: "../.." diff --git a/adapters/database_cleaner-data_mapper/Gemfile.lock b/adapters/database_cleaner-data_mapper/Gemfile.lock deleted file mode 100644 index fe492c97..00000000 --- a/adapters/database_cleaner-data_mapper/Gemfile.lock +++ /dev/null @@ -1,103 +0,0 @@ -PATH - remote: ../.. - specs: - database_cleaner (1.8.2) - -PATH - remote: . - specs: - database_cleaner-data_mapper (1.8.0) - database_cleaner (~> 1.8.0) - datamapper - dm-transactions - -GEM - remote: https://rubygems.org/ - specs: - addressable (2.3.6) - bcrypt (3.1.13) - bcrypt-ruby (3.1.5) - bcrypt (>= 3.1.3) - data_objects (0.10.14) - addressable (~> 2.1) - datamapper (1.2.0) - dm-aggregates (~> 1.2.0) - dm-constraints (~> 1.2.0) - dm-core (~> 1.2.0) - dm-migrations (~> 1.2.0) - dm-serializer (~> 1.2.0) - dm-timestamps (~> 1.2.0) - dm-transactions (~> 1.2.0) - dm-types (~> 1.2.0) - dm-validations (~> 1.2.0) - diff-lcs (1.3) - dm-aggregates (1.2.0) - dm-core (~> 1.2.0) - dm-constraints (1.2.0) - dm-core (~> 1.2.0) - dm-core (1.2.1) - addressable (~> 2.3) - dm-do-adapter (1.2.0) - data_objects (~> 0.10.6) - dm-core (~> 1.2.0) - dm-migrations (1.2.0) - dm-core (~> 1.2.0) - dm-serializer (1.2.2) - dm-core (~> 1.2.0) - fastercsv (~> 1.5) - json (~> 1.6) - json_pure (~> 1.6) - multi_json (~> 1.0) - dm-sqlite-adapter (1.2.0) - dm-do-adapter (~> 1.2.0) - do_sqlite3 (~> 0.10.6) - dm-timestamps (1.2.0) - dm-core (~> 1.2.0) - dm-transactions (1.2.0) - dm-core (~> 1.2.0) - dm-types (1.2.2) - bcrypt-ruby (~> 3.0) - dm-core (~> 1.2.0) - fastercsv (~> 1.5) - json (~> 1.6) - multi_json (~> 1.0) - stringex (~> 1.4) - uuidtools (~> 2.1) - dm-validations (1.2.0) - dm-core (~> 1.2.0) - do_sqlite3 (0.10.14) - data_objects (= 0.10.14) - fastercsv (1.5.5) - json (1.8.6) - json_pure (1.8.6) - multi_json (1.14.1) - rake (10.4.2) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - stringex (1.5.1) - uuidtools (2.1.5) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.16) - database_cleaner! - database_cleaner-data_mapper! - dm-sqlite-adapter - rake (~> 10.0) - rspec (~> 3.0) - -BUNDLED WITH - 1.17.3 diff --git a/adapters/database_cleaner-data_mapper/LICENSE.txt b/adapters/database_cleaner-data_mapper/LICENSE.txt deleted file mode 100644 index 392bc0d3..00000000 --- a/adapters/database_cleaner-data_mapper/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2009 Ben Mabey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/adapters/database_cleaner-data_mapper/README.md b/adapters/database_cleaner-data_mapper/README.md deleted file mode 100644 index fde8bc9e..00000000 --- a/adapters/database_cleaner-data_mapper/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# Database Cleaner Adapter for DataMapper - -[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-data_mapper.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-data_mapper) -[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-data_mapper/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-data_mapper) - -Clean your DataMapper databases with Database Cleaner. - -See https://github.com/DatabaseCleaner/database_cleaner for more information. - -## Installation - -```ruby -# Gemfile -group :test do - gem 'database_cleaner-data_mapper' -end -``` - -## Supported Strategies - -Here is an overview of the supported strategies: - - - - - - - - - - - - - - -
TruncationTransactionDeletion
Yes Yes No
- -(Default strategy is denoted in bold) - -## Configuration options - - - - - - - - - - - - - - -
ORMHow to accessNotes
Data Mapper DatabaseCleaner[:data_mapper] Connection specified as :symbol keys, loaded via Datamapper repositories
- -## COPYRIGHT - -See [LICENSE] for details. diff --git a/adapters/database_cleaner-data_mapper/Rakefile b/adapters/database_cleaner-data_mapper/Rakefile deleted file mode 100644 index b7e9ed54..00000000 --- a/adapters/database_cleaner-data_mapper/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/adapters/database_cleaner-data_mapper/bin/console b/adapters/database_cleaner-data_mapper/bin/console deleted file mode 100755 index 66190aaa..00000000 --- a/adapters/database_cleaner-data_mapper/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "database_cleaner/data_mapper" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/adapters/database_cleaner-data_mapper/bin/setup b/adapters/database_cleaner-data_mapper/bin/setup deleted file mode 100755 index 268b1b43..00000000 --- a/adapters/database_cleaner-data_mapper/bin/setup +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle check || bundle install -cp spec/support/sample.config.yml spec/support/config.yml - diff --git a/adapters/database_cleaner-data_mapper/database_cleaner-data_mapper.gemspec b/adapters/database_cleaner-data_mapper/database_cleaner-data_mapper.gemspec deleted file mode 100644 index 39e24d22..00000000 --- a/adapters/database_cleaner-data_mapper/database_cleaner-data_mapper.gemspec +++ /dev/null @@ -1,34 +0,0 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/data_mapper/version" - -Gem::Specification.new do |spec| - spec.name = "database_cleaner-data_mapper" - spec.version = DatabaseCleaner::DataMapper::VERSION - spec.authors = ["Ernesto Tagwerker"] - spec.email = ["ernesto@ombulabs.com"] - - spec.summary = "Strategies for cleaning databases using DataMapper. Can be used to ensure a clean state for testing." - spec.description = "Strategies for cleaning databases using DataMapper. Can be used to ensure a clean state for testing." - spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-data_mapper" - spec.license = "MIT" - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency "database_cleaner", "~> 1.8.0" - spec.add_dependency "datamapper" - spec.add_dependency "dm-transactions" - - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "bundler", "~> 1.16" - spec.add_development_dependency "rspec", "~> 3.0" - - spec.add_development_dependency "dm-sqlite-adapter" - # spec.add_development_dependency "dm-migrations" -end diff --git a/adapters/database_cleaner-data_mapper/lib/database_cleaner-data_mapper.rb b/adapters/database_cleaner-data_mapper/lib/database_cleaner-data_mapper.rb deleted file mode 100644 index 0be5186d..00000000 --- a/adapters/database_cleaner-data_mapper/lib/database_cleaner-data_mapper.rb +++ /dev/null @@ -1 +0,0 @@ -require "database_cleaner/data_mapper" diff --git a/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper.rb b/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper.rb deleted file mode 100644 index 26af40e6..00000000 --- a/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "database_cleaner/data_mapper/version" -require "database_cleaner" -require "database_cleaner/data_mapper/transaction" -require "database_cleaner/data_mapper/truncation" diff --git a/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/base.rb b/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/base.rb deleted file mode 100644 index 29aa7027..00000000 --- a/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/base.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'database_cleaner/generic/base' -module DatabaseCleaner - module DataMapper - def self.available_strategies - %w[truncation transaction] - end - - def self.default_strategy - :transaction - end - - module Base - include ::DatabaseCleaner::Generic::Base - - def db=(desired_db) - @db = desired_db - end - - def db - @db ||= :default - end - - end - end -end diff --git a/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb b/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb deleted file mode 100644 index 31b3287b..00000000 --- a/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'database_cleaner/data_mapper/base' -require 'database_cleaner/generic/transaction' - -module DatabaseCleaner::DataMapper - class Transaction - include ::DatabaseCleaner::DataMapper::Base - include ::DatabaseCleaner::Generic::Transaction - - def start(repository = self.db) - ::DataMapper.repository(repository) do |r| - transaction = DataMapper::Transaction.new(r) - transaction.begin - r.adapter.push_transaction(transaction) - end - end - - def clean(repository = self.db) - ::DataMapper.repository(repository) do |r| - adapter = r.adapter - while adapter.current_transaction - adapter.current_transaction.rollback - adapter.pop_transaction - end - end - end - - end -end diff --git a/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/truncation.rb b/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/truncation.rb deleted file mode 100644 index f1dfe4b3..00000000 --- a/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/truncation.rb +++ /dev/null @@ -1,173 +0,0 @@ -require "database_cleaner/generic/truncation" -require 'database_cleaner/data_mapper/base' -require 'data_mapper' - -module DataMapper - module Adapters - - class DataObjectsAdapter - - def storage_names(repository = :default) - raise NotImplementedError - end - - def truncate_tables(table_names) - table_names.each do |table_name| - truncate_table table_name - end - end - - end - - class MysqlAdapter < DataObjectsAdapter - - # taken from https://github.com/godfat/dm-mapping/tree/master - def storage_names(repository = :default) - select 'SHOW TABLES' - end - - def truncate_table(table_name) - execute("TRUNCATE TABLE #{quote_name(table_name)};") - end - - # copied from activerecord - def disable_referential_integrity - old = select("SELECT @@FOREIGN_KEY_CHECKS;") - begin - execute("SET FOREIGN_KEY_CHECKS = 0;") - yield - ensure - execute("SET FOREIGN_KEY_CHECKS = ?", *old) - end - end - - end - - module SqliteAdapterMethods - - # taken from https://github.com/godfat/dm-mapping/tree/master - def storage_names(repository = :default) - # activerecord-2.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb: 177 - sql = <<-SQL - SELECT name - FROM sqlite_master - WHERE type = 'table' AND NOT name = 'sqlite_sequence' - SQL - # activerecord-2.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb: 181 - select(sql) - end - - def truncate_table(table_name) - execute("DELETE FROM #{quote_name(table_name)};") - if uses_sequence? - execute("DELETE FROM sqlite_sequence where name = '#{table_name}';") - end - end - - # this is a no-op copied from activerecord - # i didn't find out if/how this is possible - # activerecord also doesn't do more here - def disable_referential_integrity - yield - end - - private - - # Returns a boolean indicating if the SQLite database is using the sqlite_sequence table. - def uses_sequence? - sql = <<-SQL - SELECT name FROM sqlite_master - WHERE type='table' AND name='sqlite_sequence' - SQL - select(sql).first - end - end - - class SqliteAdapter; include SqliteAdapterMethods; end - class Sqlite3Adapter; include SqliteAdapterMethods; end - - # FIXME - # i don't know if this works - # i basically just copied activerecord code to get a rough idea what they do. - # i don't have postgres available, so i won't be the one to write this. - # maybe codes below gets some postgres/datamapper user going, though. - class PostgresAdapter < DataObjectsAdapter - - # taken from https://github.com/godfat/dm-mapping/tree/master - def storage_names(repository = :default) - sql = <<-SQL - SELECT table_name FROM "information_schema"."tables" - WHERE table_schema = current_schema() and table_type = 'BASE TABLE' - SQL - select(sql) - end - - def truncate_table(table_name) - execute("TRUNCATE TABLE #{quote_name(table_name)} RESTART IDENTITY CASCADE;") - end - - # override to use a single statement - def truncate_tables(table_names) - quoted_names = table_names.collect { |n| quote_name(n) }.join(', ') - execute("TRUNCATE TABLE #{quoted_names} RESTART IDENTITY;") - end - - # FIXME - # copied from activerecord - def supports_disable_referential_integrity? - version = select("SHOW server_version")[0][0].split('.') - (version[0].to_i >= 8 && version[1].to_i >= 1) ? true : false - rescue - return false - end - - # FIXME - # copied unchanged from activerecord - def disable_referential_integrity(repository = :default) - if supports_disable_referential_integrity? then - execute(storage_names(repository).collect do |name| - "ALTER TABLE #{quote_name(name)} DISABLE TRIGGER ALL" - end.join(";")) - end - yield - ensure - if supports_disable_referential_integrity? then - execute(storage_names(repository).collect do |name| - "ALTER TABLE #{quote_name(name)} ENABLE TRIGGER ALL" - end.join(";")) - end - end - - end - - end -end - - -module DatabaseCleaner - module DataMapper - class Truncation - include ::DatabaseCleaner::DataMapper::Base - include ::DatabaseCleaner::Generic::Truncation - - def clean(repository = self.db) - adapter = ::DataMapper.repository(repository).adapter - adapter.disable_referential_integrity do - adapter.truncate_tables(tables_to_truncate(repository)) - end - end - - private - - def tables_to_truncate(repository = self.db) - (@only || ::DataMapper.repository(repository).adapter.storage_names(repository)) - @tables_to_exclude - end - - # overwritten - def migration_storage_names - %w[migration_info] - end - - end - end -end diff --git a/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/version.rb b/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/version.rb deleted file mode 100644 index 222e161b..00000000 --- a/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DatabaseCleaner - module DataMapper - VERSION = "1.8.0" - end -end diff --git a/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/base_spec.rb b/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/base_spec.rb deleted file mode 100644 index 6ac42110..00000000 --- a/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/base_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'database_cleaner/data_mapper/base' -require 'database_cleaner/spec' - -module DatabaseCleaner - RSpec.describe DataMapper do - it { is_expected.to respond_to(:available_strategies) } - - it "has a default_strategy of transaction" do - expect(described_class.default_strategy).to eq(:transaction) - end - end - - module DataMapper - class ExampleStrategy - include ::DatabaseCleaner::DataMapper::Base - end - - RSpec.describe ExampleStrategy do - it_should_behave_like "a generic strategy" - it { is_expected.to respond_to(:db) } - it { is_expected.to respond_to(:db=) } - - it "should store my desired db" do - subject.db = :my_db - expect(subject.db).to eq :my_db - end - - it "should default to :default" do - expect(subject.db).to eq :default - end - end - end -end diff --git a/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/transaction_spec.rb b/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/transaction_spec.rb deleted file mode 100644 index 61e04318..00000000 --- a/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/transaction_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'database_cleaner/data_mapper/transaction' -require 'database_cleaner/spec' -#require 'data_mapper' - -module DatabaseCleaner - module DataMapper - - RSpec.describe Transaction do - it_should_behave_like "a generic strategy" - it_should_behave_like "a generic transaction strategy" - - describe "start" do - it "should start a transaction" - end - - describe "clean" do - it "should finish a transaction" - end - end - - end -end diff --git a/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/truncation/sqlite3_spec.rb b/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/truncation/sqlite3_spec.rb deleted file mode 100644 index 49975ffa..00000000 --- a/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/truncation/sqlite3_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'database_cleaner/data_mapper/truncation' - -RSpec.describe DatabaseCleaner::DataMapper::Truncation do - let(:helper) { DataMapperHelper.new(:sqlite3) } - - let(:connection) { helper.connection } - - around do |example| - helper.setup - example.run - helper.teardown - end - - describe "DM connection adapter monkeypatches" do - before { 2.times { User.create } } - - describe "#truncate_table" do - it "truncates the table and resets AUTO_INCREMENT index of table" do - connection.truncate_table(User.storage_names[:default]) - expect(User.count).to eq 0 - expect(User.create.id).to eq 1 - end - end - end -end diff --git a/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/truncation_spec.rb b/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/truncation_spec.rb deleted file mode 100644 index b879b901..00000000 --- a/adapters/database_cleaner-data_mapper/spec/database_cleaner/data_mapper/truncation_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'database_cleaner/data_mapper/truncation' -require 'database_cleaner/spec' - -module DatabaseCleaner - module DataMapper - RSpec.describe Truncation do - it_should_behave_like "a generic strategy" - it_should_behave_like "a generic truncation strategy" - end - end -end diff --git a/adapters/database_cleaner-data_mapper/spec/spec_helper.rb b/adapters/database_cleaner-data_mapper/spec/spec_helper.rb deleted file mode 100644 index 4ea635d0..00000000 --- a/adapters/database_cleaner-data_mapper/spec/spec_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "bundler/setup" -require 'support/data_mapper_helper' -require "database_cleaner/data_mapper" - -RSpec.configure do |config| - # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" - - # Disable RSpec exposing methods globally on `Module` and `main` - config.disable_monkey_patching! - - config.expect_with :rspec do |c| - c.syntax = :expect - end -end diff --git a/adapters/database_cleaner-data_mapper/spec/support/data_mapper_helper.rb b/adapters/database_cleaner-data_mapper/spec/support/data_mapper_helper.rb deleted file mode 100644 index 37348286..00000000 --- a/adapters/database_cleaner-data_mapper/spec/support/data_mapper_helper.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'database_cleaner/spec/database_helper' -require "data_mapper" -require "dm-sqlite-adapter" - -class DataMapperHelper < DatabaseCleaner::Spec::DatabaseHelper - def setup - super - - Kernel.const_set "User", Class.new - User.instance_eval do - include DataMapper::Resource - - storage_names[:default] = 'users' - - property :id, User::Serial - property :name, String - end - end - - def teardown - Kernel.send :remove_const, "User" if defined?(User) - - super - end - - def connection - DataMapper.repository.adapter - end - - private - - def establish_connection(config = default_config) - DataMapper.setup(:default, config) - end -end - diff --git a/adapters/database_cleaner-data_mapper/spec/support/sample.config.yml b/adapters/database_cleaner-data_mapper/spec/support/sample.config.yml deleted file mode 100644 index 90132c0d..00000000 --- a/adapters/database_cleaner-data_mapper/spec/support/sample.config.yml +++ /dev/null @@ -1,34 +0,0 @@ -mysql: - adapter: mysql - database: database_cleaner_test - username: root - password: - host: 127.0.0.1 - port: 3306 - encoding: utf8 - -mysql2: - adapter: mysql2 - database: database_cleaner_test - username: root - password: - host: 127.0.0.1 - port: 3306 - encoding: utf8 - -postgres: - adapter: postgresql - database: database_cleaner_test - username: postgres - password: - host: 127.0.0.1 - encoding: unicode - template: template0 - -sqlite3: - adapter: sqlite3 - database: tmp/database_cleaner_test.sqlite3 - pool: 5 - timeout: 5000 - encoding: utf8 - diff --git a/adapters/database_cleaner-data_mapper/tmp/.keep b/adapters/database_cleaner-data_mapper/tmp/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/adapters/database_cleaner-mongo/.gitignore b/adapters/database_cleaner-mongo/.gitignore deleted file mode 100644 index b04a8c84..00000000 --- a/adapters/database_cleaner-mongo/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/tmp/ - -# rspec failure tracking -.rspec_status diff --git a/adapters/database_cleaner-mongo/.rspec b/adapters/database_cleaner-mongo/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/adapters/database_cleaner-mongo/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/adapters/database_cleaner-mongo/.travis.yml b/adapters/database_cleaner-mongo/.travis.yml deleted file mode 100644 index 9912d68f..00000000 --- a/adapters/database_cleaner-mongo/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -rvm: - - 2.2.9 -before_install: gem install bundler -v 1.17.2 diff --git a/adapters/database_cleaner-mongo/Gemfile b/adapters/database_cleaner-mongo/Gemfile deleted file mode 100644 index 8d40bd01..00000000 --- a/adapters/database_cleaner-mongo/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -# Specify your gem's dependencies in database_cleaner-mongo.gemspec -gemspec - -gem "database_cleaner", path: "../.." diff --git a/adapters/database_cleaner-mongo/Gemfile.lock b/adapters/database_cleaner-mongo/Gemfile.lock deleted file mode 100644 index f542f873..00000000 --- a/adapters/database_cleaner-mongo/Gemfile.lock +++ /dev/null @@ -1,46 +0,0 @@ -PATH - remote: ../.. - specs: - database_cleaner (1.8.2) - -PATH - remote: . - specs: - database_cleaner-mongo (1.8.0) - database_cleaner (~> 1.8.0) - mongo - -GEM - remote: https://rubygems.org/ - specs: - bson (1.12.5) - diff-lcs (1.3) - mongo (1.12.5) - bson (= 1.12.5) - rake (10.4.2) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.16) - database_cleaner! - database_cleaner-mongo! - rake (~> 10.0) - rspec (~> 3.0) - -BUNDLED WITH - 1.17.3 diff --git a/adapters/database_cleaner-mongo/LICENSE.txt b/adapters/database_cleaner-mongo/LICENSE.txt deleted file mode 100644 index 392bc0d3..00000000 --- a/adapters/database_cleaner-mongo/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2009 Ben Mabey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/adapters/database_cleaner-mongo/README.md b/adapters/database_cleaner-mongo/README.md deleted file mode 100644 index 2928f684..00000000 --- a/adapters/database_cleaner-mongo/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# Database Cleaner Adapter for Mongo - -[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-mongo.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-mongo) -[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-mongo/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-mongo) - -Clean your Mongo databases with Database Cleaner. - -See https://github.com/DatabaseCleaner/database_cleaner for more information. - -## Installation - -```ruby -# Gemfile -group :test do - gem 'database_cleaner-mongo' -end -``` - -## Supported Strategies - - - - - - - - - - - - - - -
TruncationTransactionDeletion
Yes No No
- -(Default strategy is denoted in bold) - -## Configuration options - - - - - - - - - - - - - - -
ORMHow to accessNotes
Mongo DatabaseCleaner[:mongo]
- -## COPYRIGHT - -See [LICENSE] for details. diff --git a/adapters/database_cleaner-mongo/Rakefile b/adapters/database_cleaner-mongo/Rakefile deleted file mode 100644 index b7e9ed54..00000000 --- a/adapters/database_cleaner-mongo/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/adapters/database_cleaner-mongo/bin/console b/adapters/database_cleaner-mongo/bin/console deleted file mode 100755 index e35b53f9..00000000 --- a/adapters/database_cleaner-mongo/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "database_cleaner/mongo" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/adapters/database_cleaner-mongo/bin/setup b/adapters/database_cleaner-mongo/bin/setup deleted file mode 100755 index 3b72cbcc..00000000 --- a/adapters/database_cleaner-mongo/bin/setup +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle check || bundle install diff --git a/adapters/database_cleaner-mongo/database_cleaner-mongo.gemspec b/adapters/database_cleaner-mongo/database_cleaner-mongo.gemspec deleted file mode 100644 index a370c7bd..00000000 --- a/adapters/database_cleaner-mongo/database_cleaner-mongo.gemspec +++ /dev/null @@ -1,30 +0,0 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/mongo/version" - -Gem::Specification.new do |spec| - spec.name = "database_cleaner-mongo" - spec.version = DatabaseCleaner::Mongo::VERSION - spec.authors = ["Ernesto Tagwerker"] - spec.email = ["ernesto@ombulabs.com"] - - spec.summary = "Strategies for cleaning databases using Mongo. Can be used to ensure a clean state for testing." - spec.description = "Strategies for cleaning databases using Mongo. Can be used to ensure a clean state for testing." - spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-mongo" - spec.license = "MIT" - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency "database_cleaner", "~> 1.8.0" - spec.add_dependency "mongo" - - spec.add_development_dependency "bundler", "~> 1.16" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" -end diff --git a/adapters/database_cleaner-mongo/lib/database_cleaner-mongo.rb b/adapters/database_cleaner-mongo/lib/database_cleaner-mongo.rb deleted file mode 100644 index 3dde9b24..00000000 --- a/adapters/database_cleaner-mongo/lib/database_cleaner-mongo.rb +++ /dev/null @@ -1 +0,0 @@ -require "database_cleaner/mongo" diff --git a/adapters/database_cleaner-mongo/lib/database_cleaner/mongo.rb b/adapters/database_cleaner-mongo/lib/database_cleaner/mongo.rb deleted file mode 100644 index da7c8745..00000000 --- a/adapters/database_cleaner-mongo/lib/database_cleaner/mongo.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'database_cleaner/mongo/version' -require 'database_cleaner' -require 'database_cleaner/mongo/truncation' - -module DatabaseCleaner::Mongo - def self.default_strategy - :truncation - end -end - diff --git a/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/base.rb b/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/base.rb deleted file mode 100644 index 809a6e2c..00000000 --- a/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/base.rb +++ /dev/null @@ -1,16 +0,0 @@ -module DatabaseCleaner - module Mongo - def self.available_strategies - %w[truncation] - end - module Base - def db=(desired_db) - @db = desired_db - end - - def db - @db || raise("You have not specified a database. (see Mongo::Database)") - end - end - end -end diff --git a/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation.rb b/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation.rb deleted file mode 100644 index a09d1ff9..00000000 --- a/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'database_cleaner/mongo/base' -require 'database_cleaner/generic/truncation' -require 'database_cleaner/mongo/truncation_mixin' -module DatabaseCleaner - module Mongo - class Truncation - include ::DatabaseCleaner::Generic::Truncation - include TruncationMixin - include Base - private - - def database - db - end - - def collections_cache - @@collections_cache ||= {} - end - - def mongoid_collection_names - @@mongoid_collection_names ||= Hash.new{|h,k| h[k]=[]}.tap do |names| - ObjectSpace.each_object(Class) do |klass| - (names[klass.db.name] << klass.collection_name) if valid_collection_name?(klass) - end - end - end - - def not_caching(db_name, list) - @@not_caching ||= {} - - unless @@not_caching.has_key?(db_name) - @@not_caching[db_name] = true - - puts "Not caching collection names for db #{db_name}. Missing these from models: #{list}" - end - end - - def collections - return collections_cache[database.name] if collections_cache.has_key?(database.name) - db_collections = database.collections.select { |c| c.name !~ /^system\./ } - - missing_collections = mongoid_collection_names[database.name] - db_collections.map(&:name) - - if missing_collections.empty? - collections_cache[database.name] = db_collections - else - not_caching(database.name, missing_collections) - end - - db_collections - end - - private - - def valid_collection_name?(klass) - klass.ancestors.map(&:to_s).include?('Mongoid::Document') && - !klass.embedded && - !klass.collection_name.empty? - end - end - end -end diff --git a/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation_mixin.rb b/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation_mixin.rb deleted file mode 100644 index 755b3df2..00000000 --- a/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation_mixin.rb +++ /dev/null @@ -1,26 +0,0 @@ -module DatabaseCleaner - module Mongo - module TruncationMixin - - def clean - if @only - collections.each { |c| c.send(truncate_method_name) if @only.include?(c.name) } - else - collections.each { |c| c.send(truncate_method_name) unless @tables_to_exclude.include?(c.name) } - end - true - end - - private - - def collections - database.collections.select { |c| c.name !~ /^system\./ } - end - - def truncate_method_name - # This constant only exists in the 2.x series. - defined?(::Mongo::VERSION) ? :delete_many : :remove - end - end - end -end diff --git a/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/version.rb b/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/version.rb deleted file mode 100644 index 3c7596ee..00000000 --- a/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DatabaseCleaner - module Mongo - VERSION = "1.8.0" - end -end diff --git a/adapters/database_cleaner-mongo/spec/database_cleaner/mongo/base_spec.rb b/adapters/database_cleaner-mongo/spec/database_cleaner/mongo/base_spec.rb deleted file mode 100644 index 73d9d63a..00000000 --- a/adapters/database_cleaner-mongo/spec/database_cleaner/mongo/base_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'database_cleaner/mongo' - -RSpec.describe DatabaseCleaner::Mongo do - it "has a default_strategy of truncation" do - expect(described_class.default_strategy).to eq(:truncation) - end -end - diff --git a/adapters/database_cleaner-mongo/spec/database_cleaner/mongo/mongo_examples.rb b/adapters/database_cleaner-mongo/spec/database_cleaner/mongo/mongo_examples.rb deleted file mode 100644 index 03602948..00000000 --- a/adapters/database_cleaner-mongo/spec/database_cleaner/mongo/mongo_examples.rb +++ /dev/null @@ -1,26 +0,0 @@ -module MongoTest - class Base - def self.collection - @connection ||= Mongo::Connection.new('127.0.0.1') - @db ||= @connection.db('database_cleaner_specs') - @collection ||= @db.collection(name) || @db.create_collection(name) - end - - def self.count - @collection.count - end - - def initialize(attrs={}) - @attrs = attrs - end - - def save! - self.class.collection.insert(@attrs) - end - end - - class Widget < Base - end - class Gadget < Base - end -end diff --git a/adapters/database_cleaner-mongo/spec/database_cleaner/mongo/truncation_spec.rb b/adapters/database_cleaner-mongo/spec/database_cleaner/mongo/truncation_spec.rb deleted file mode 100644 index 9cf1dffd..00000000 --- a/adapters/database_cleaner-mongo/spec/database_cleaner/mongo/truncation_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'mongo' -require 'database_cleaner/mongo/truncation' -require File.dirname(__FILE__) + '/mongo_examples' - -RSpec.describe DatabaseCleaner::Mongo::Truncation do - around do |example| - connection = Mongo::Connection.new('127.0.0.1') - db_name = 'database_cleaner_specs' - db = connection.db(db_name) - subject.db = db - - example.run - - connection.drop_database(db_name) - end - - before do - MongoTest::Widget.new(name: 'some widget').save! - MongoTest::Gadget.new(name: 'some gadget').save! - end - - context "by default" do - it "truncates all collections" do - expect { subject.clean }.to change { - [MongoTest::Widget.count, MongoTest::Gadget.count] - }.from([1,1]).to([0,0]) - end - end - - context "when collections are provided to the :only option" do - subject { described_class.new(only: ['MongoTest::Widget']) } - - it "only truncates the specified collections" do - expect { subject.clean }.to change { - [MongoTest::Widget.count, MongoTest::Gadget.count] - }.from([1,1]).to([0,1]) - end - end - - context "when collections are provided to the :except option" do - subject { described_class.new(except: ['MongoTest::Widget']) } - - it "truncates all but the specified collections" do - expect { subject.clean }.to change { - [MongoTest::Widget.count, MongoTest::Gadget.count] - }.from([1,1]).to([1,0]) - end - end -end - diff --git a/adapters/database_cleaner-mongo/spec/spec_helper.rb b/adapters/database_cleaner-mongo/spec/spec_helper.rb deleted file mode 100644 index 5797f97f..00000000 --- a/adapters/database_cleaner-mongo/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "bundler/setup" -require "database_cleaner/mongo" - -RSpec.configure do |config| - # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" - - # Disable RSpec exposing methods globally on `Module` and `main` - config.disable_monkey_patching! - - config.expect_with :rspec do |c| - c.syntax = :expect - end -end diff --git a/adapters/database_cleaner-mongo_mapper/.gitignore b/adapters/database_cleaner-mongo_mapper/.gitignore deleted file mode 100644 index b04a8c84..00000000 --- a/adapters/database_cleaner-mongo_mapper/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/tmp/ - -# rspec failure tracking -.rspec_status diff --git a/adapters/database_cleaner-mongo_mapper/.rspec b/adapters/database_cleaner-mongo_mapper/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/adapters/database_cleaner-mongo_mapper/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/adapters/database_cleaner-mongo_mapper/.travis.yml b/adapters/database_cleaner-mongo_mapper/.travis.yml deleted file mode 100644 index 9912d68f..00000000 --- a/adapters/database_cleaner-mongo_mapper/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -rvm: - - 2.2.9 -before_install: gem install bundler -v 1.17.2 diff --git a/adapters/database_cleaner-mongo_mapper/Gemfile b/adapters/database_cleaner-mongo_mapper/Gemfile deleted file mode 100644 index dea1d87b..00000000 --- a/adapters/database_cleaner-mongo_mapper/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -# Specify your gem's dependencies in database_cleaner-mongo_mapper.gemspec -gemspec - -gem "database_cleaner", path: "../.." diff --git a/adapters/database_cleaner-mongo_mapper/Gemfile.lock b/adapters/database_cleaner-mongo_mapper/Gemfile.lock deleted file mode 100644 index 0eb287a9..00000000 --- a/adapters/database_cleaner-mongo_mapper/Gemfile.lock +++ /dev/null @@ -1,59 +0,0 @@ -PATH - remote: ../.. - specs: - database_cleaner (1.8.2) - -PATH - remote: . - specs: - database_cleaner-mongo_mapper (1.8.1) - database_cleaner (~> 1.8.0) - mongo_mapper - -GEM - remote: https://rubygems.org/ - specs: - activemodel (3.0.20) - activesupport (= 3.0.20) - builder (~> 2.1.2) - i18n (~> 0.5.0) - activesupport (3.0.20) - bson (1.12.5) - builder (2.1.2) - diff-lcs (1.3) - i18n (0.5.4) - mongo (1.12.5) - bson (= 1.12.5) - mongo_mapper (0.12.0) - activemodel (~> 3.0) - activesupport (~> 3.0) - plucky (~> 0.5.2) - plucky (0.5.2) - mongo (~> 1.5) - rake (10.4.2) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.16) - database_cleaner! - database_cleaner-mongo_mapper! - rake (~> 10.0) - rspec (~> 3.0) - -BUNDLED WITH - 1.17.3 diff --git a/adapters/database_cleaner-mongo_mapper/LICENSE.txt b/adapters/database_cleaner-mongo_mapper/LICENSE.txt deleted file mode 100644 index 392bc0d3..00000000 --- a/adapters/database_cleaner-mongo_mapper/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2009 Ben Mabey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/adapters/database_cleaner-mongo_mapper/README.md b/adapters/database_cleaner-mongo_mapper/README.md deleted file mode 100644 index 768edc74..00000000 --- a/adapters/database_cleaner-mongo_mapper/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# Database Cleaner Adapter for MongoMapper - -[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-mongo_mapper.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-mongo_mapper) -[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-mongo_mapper/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-mongo_mapper) - -Clean your MongoMapper databases with Database Cleaner. - -See https://github.com/DatabaseCleaner/database_cleaner for more information. - -## Installation - -```ruby -# Gemfile -group :test do - gem 'database_cleaner-mongo_mapper' -end -``` - -## Supported Strategies - - - - - - - - - - - - - - -
TruncationTransactionDeletion
Yes No No
- -(Default strategy is denoted in bold) - -## Configuration options - - - - - - - - - - - - - - -
ORMHow to accessNotes
Mongo Mapper DatabaseCleaner[:mongo_mapper] Multiple connections not yet supported
- -## COPYRIGHT - -See [LICENSE] for details. diff --git a/adapters/database_cleaner-mongo_mapper/Rakefile b/adapters/database_cleaner-mongo_mapper/Rakefile deleted file mode 100644 index b7e9ed54..00000000 --- a/adapters/database_cleaner-mongo_mapper/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/adapters/database_cleaner-mongo_mapper/bin/console b/adapters/database_cleaner-mongo_mapper/bin/console deleted file mode 100755 index 47256a75..00000000 --- a/adapters/database_cleaner-mongo_mapper/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "database_cleaner/mongo_mapper" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/adapters/database_cleaner-mongo_mapper/bin/setup b/adapters/database_cleaner-mongo_mapper/bin/setup deleted file mode 100755 index 3fc33879..00000000 --- a/adapters/database_cleaner-mongo_mapper/bin/setup +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle check || bundle install - diff --git a/adapters/database_cleaner-mongo_mapper/database_cleaner-mongo_mapper.gemspec b/adapters/database_cleaner-mongo_mapper/database_cleaner-mongo_mapper.gemspec deleted file mode 100644 index 9b64fa73..00000000 --- a/adapters/database_cleaner-mongo_mapper/database_cleaner-mongo_mapper.gemspec +++ /dev/null @@ -1,30 +0,0 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/mongo_mapper/version" - -Gem::Specification.new do |spec| - spec.name = "database_cleaner-mongo_mapper" - spec.version = DatabaseCleaner::MongoMapper::VERSION - spec.authors = ["Ernesto Tagwerker"] - spec.email = ["ernesto@ombulabs.com"] - - spec.summary = "Strategies for cleaning databases using MongoMapper. Can be used to ensure a clean state for testing." - spec.description = "Strategies for cleaning databases using MongoMapper. Can be used to ensure a clean state for testing." - spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-mongo_mapper" - spec.license = "MIT" - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency "database_cleaner", "~> 1.8.0" - spec.add_dependency "mongo_mapper" - - spec.add_development_dependency "bundler", "~> 1.16" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" -end diff --git a/adapters/database_cleaner-mongo_mapper/lib/database_cleaner-mongo_mapper.rb b/adapters/database_cleaner-mongo_mapper/lib/database_cleaner-mongo_mapper.rb deleted file mode 100644 index fd4856f0..00000000 --- a/adapters/database_cleaner-mongo_mapper/lib/database_cleaner-mongo_mapper.rb +++ /dev/null @@ -1 +0,0 @@ -require "database_cleaner/mongo_mapper" diff --git a/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper.rb b/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper.rb deleted file mode 100644 index 17ee7f45..00000000 --- a/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "database_cleaner/mongo_mapper/version" -require "database_cleaner" -require "database_cleaner/mongo_mapper/truncation" - diff --git a/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/base.rb b/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/base.rb deleted file mode 100644 index 7cac7dfb..00000000 --- a/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/base.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'database_cleaner/generic/base' -module DatabaseCleaner - module MongoMapper - def self.available_strategies - %w[truncation] - end - - def self.default_strategy - :truncation - end - - module Base - include ::DatabaseCleaner::Generic::Base - - def db=(desired_db) - @db = desired_db - end - - def db - @db ||= :default - end - end - end -end diff --git a/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/truncation.rb b/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/truncation.rb deleted file mode 100644 index b11a1e3c..00000000 --- a/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/truncation.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'database_cleaner/mongo_mapper/base' -require 'database_cleaner/generic/truncation' - -module DatabaseCleaner - module MongoMapper - class Truncation - include ::DatabaseCleaner::MongoMapper::Base - include ::DatabaseCleaner::Generic::Truncation - - def clean - if @only - collections.each { |c| c.send(truncate_method_name) if @only.include?(c.name) } - else - collections.each { |c| c.send(truncate_method_name) unless @tables_to_exclude.include?(c.name) } - end - true - end - - private - - def collections - database.collections.select { |c| c.name !~ /^system\./ } - end - - def truncate_method_name - # This constant only exists in the 2.x series. - defined?(::Mongo::VERSION) ? :delete_many : :remove - end - - def database - ::MongoMapper.database - end - end - end -end diff --git a/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/version.rb b/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/version.rb deleted file mode 100644 index 9ab43f3d..00000000 --- a/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DatabaseCleaner - module MongoMapper - VERSION = "1.8.1" - end -end diff --git a/adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/base_spec.rb b/adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/base_spec.rb deleted file mode 100644 index 6f6d3953..00000000 --- a/adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/base_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'database_cleaner/mongo_mapper/base' -require 'database_cleaner/spec' - -module DatabaseCleaner - RSpec.describe MongoMapper do - it { is_expected.to respond_to(:available_strategies) } - - it "has a default_strategy of truncation" do - expect(described_class.default_strategy).to eq(:truncation) - end - end - - module MongoMapper - class ExampleStrategy - include ::DatabaseCleaner::MongoMapper::Base - end - - RSpec.describe ExampleStrategy do - - it_should_behave_like "a generic strategy" - - describe "db" do - it { is_expected.to respond_to(:db=) } - - it "should store my desired db" do - subject.db = :my_db - expect(subject.db).to eq :my_db - end - - it "should default to :default" do - expect(subject.db).to eq :default - end - end - end - end -end diff --git a/adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/mongo_examples.rb b/adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/mongo_examples.rb deleted file mode 100644 index f0b8a731..00000000 --- a/adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/mongo_examples.rb +++ /dev/null @@ -1,10 +0,0 @@ -module MongoMapperTest - class Widget - include ::MongoMapper::Document - key :name, String - end - class Gadget - include ::MongoMapper::Document - key :name, String - end -end diff --git a/adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/truncation_spec.rb b/adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/truncation_spec.rb deleted file mode 100644 index ce0a3f6d..00000000 --- a/adapters/database_cleaner-mongo_mapper/spec/database_cleaner/mongo_mapper/truncation_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'mongo_mapper' -require 'database_cleaner/mongo_mapper/truncation' -require File.dirname(__FILE__) + '/mongo_examples' - -RSpec.describe DatabaseCleaner::MongoMapper::Truncation do - around do |example| - MongoMapper.connection = Mongo::Connection.new('127.0.0.1') - db_name = 'database_cleaner_specs' - MongoMapper.database = db_name - - example.run - - MongoMapper.connection.drop_database(db_name) - end - - before do - MongoMapperTest::Widget.new(name: 'some widget').save! - MongoMapperTest::Gadget.new(name: 'some gadget').save! - end - - context "by default" do - it "truncates all collections" do - expect { subject.clean }.to change { - [MongoMapperTest::Widget.count, MongoMapperTest::Gadget.count] - }.from([1,1]).to([0,0]) - end - end - - context "when collections are provided to the :only option" do - subject { described_class.new(only: ['mongo_mapper_test.widgets']) } - - it "only truncates the specified collections" do - expect { subject.clean }.to change { - [MongoMapperTest::Widget.count, MongoMapperTest::Gadget.count] - }.from([1,1]).to([0,1]) - end - end - - context "when collections are provided to the :except option" do - subject { described_class.new(except: ['mongo_mapper_test.widgets']) } - - it "truncates all but the specified collections" do - expect { subject.clean }.to change { - [MongoMapperTest::Widget.count, MongoMapperTest::Gadget.count] - }.from([1,1]).to([1,0]) - end - end -end - diff --git a/adapters/database_cleaner-mongo_mapper/spec/spec_helper.rb b/adapters/database_cleaner-mongo_mapper/spec/spec_helper.rb deleted file mode 100644 index 4c410889..00000000 --- a/adapters/database_cleaner-mongo_mapper/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "bundler/setup" -require "database_cleaner/mongo_mapper" - -RSpec.configure do |config| - # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" - - # Disable RSpec exposing methods globally on `Module` and `main` - config.disable_monkey_patching! - - config.expect_with :rspec do |c| - c.syntax = :expect - end -end diff --git a/adapters/database_cleaner-mongoid/.gitignore b/adapters/database_cleaner-mongoid/.gitignore deleted file mode 100644 index b04a8c84..00000000 --- a/adapters/database_cleaner-mongoid/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/tmp/ - -# rspec failure tracking -.rspec_status diff --git a/adapters/database_cleaner-mongoid/.rspec b/adapters/database_cleaner-mongoid/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/adapters/database_cleaner-mongoid/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/adapters/database_cleaner-mongoid/.travis.yml b/adapters/database_cleaner-mongoid/.travis.yml deleted file mode 100644 index 251041f3..00000000 --- a/adapters/database_cleaner-mongoid/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ - -language: ruby -rvm: - - 2.2.9 -before_install: gem install bundler -v 1.17.2 diff --git a/adapters/database_cleaner-mongoid/Gemfile b/adapters/database_cleaner-mongoid/Gemfile deleted file mode 100644 index 0e454ce0..00000000 --- a/adapters/database_cleaner-mongoid/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -# Specify your gem's dependencies in database_cleaner-mongoid.gemspec -gemspec - -gem "database_cleaner", path: "../.." -gem "database_cleaner-mongo", path: ".." diff --git a/adapters/database_cleaner-mongoid/Gemfile.lock b/adapters/database_cleaner-mongoid/Gemfile.lock deleted file mode 100644 index 088bfea7..00000000 --- a/adapters/database_cleaner-mongoid/Gemfile.lock +++ /dev/null @@ -1,72 +0,0 @@ -PATH - remote: ../.. - specs: - database_cleaner (1.8.2) - -PATH - remote: .. - specs: - database_cleaner-mongo (1.8.0) - database_cleaner (~> 1.8.0) - mongo - -PATH - remote: . - specs: - database_cleaner-mongoid (1.8.1) - database_cleaner (~> 1.8.0) - database_cleaner-mongo (~> 1.8.0) - mongoid - -GEM - remote: https://rubygems.org/ - specs: - activemodel (5.2.4.1) - activesupport (= 5.2.4.1) - activesupport (5.2.4.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - bson (4.5.0) - concurrent-ruby (1.1.5) - diff-lcs (1.3) - i18n (1.5.1) - concurrent-ruby (~> 1.0) - minitest (5.14.0) - mongo (2.10.2) - bson (>= 4.4.2, < 5.0.0) - mongoid (7.0.5) - activemodel (>= 5.1, < 6.1) - mongo (>= 2.5.1, < 3.0.0) - rake (10.4.2) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - thread_safe (0.3.6) - tzinfo (1.2.6) - thread_safe (~> 0.1) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.16) - database_cleaner! - database_cleaner-mongo! - database_cleaner-mongoid! - rake (~> 10.0) - rspec (~> 3.0) - -BUNDLED WITH - 1.17.3 diff --git a/adapters/database_cleaner-mongoid/LICENSE.txt b/adapters/database_cleaner-mongoid/LICENSE.txt deleted file mode 100644 index 392bc0d3..00000000 --- a/adapters/database_cleaner-mongoid/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2009 Ben Mabey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/adapters/database_cleaner-mongoid/README.md b/adapters/database_cleaner-mongoid/README.md deleted file mode 100644 index 0937dfcd..00000000 --- a/adapters/database_cleaner-mongoid/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# Database Cleaner Adapter for Mongoid - -[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-mongoid.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-mongoid) -[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-mongoid/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-mongoid) - -Clean your Mongoid databases with Database Cleaner. - -See https://github.com/DatabaseCleaner/database_cleaner for more information. - -## Installation - -```ruby -# Gemfile -group :test do - gem 'database_cleaner-mongoid' -end -``` - -## Supported Strategies - - - - - - - - - - - - - - -
TruncationTransactionDeletion
Yes No No
- -(Default strategy is denoted in bold) - -## Configuration options - - - - - - - - - - - - - - -
ORMHow to accessNotes
Mongoid DatabaseCleaner[:mongoid] Multiple databases supported for Mongoid 3. Specify DatabaseCleaner[:mongoid, {:connection => :db_name}]
- -## COPYRIGHT - -See [LICENSE] for details. diff --git a/adapters/database_cleaner-mongoid/Rakefile b/adapters/database_cleaner-mongoid/Rakefile deleted file mode 100644 index b7e9ed54..00000000 --- a/adapters/database_cleaner-mongoid/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/adapters/database_cleaner-mongoid/bin/console b/adapters/database_cleaner-mongoid/bin/console deleted file mode 100755 index ac55de40..00000000 --- a/adapters/database_cleaner-mongoid/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "database_cleaner/mongoid" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/adapters/database_cleaner-mongoid/bin/setup b/adapters/database_cleaner-mongoid/bin/setup deleted file mode 100755 index 3fc33879..00000000 --- a/adapters/database_cleaner-mongoid/bin/setup +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle check || bundle install - diff --git a/adapters/database_cleaner-mongoid/database_cleaner-mongoid.gemspec b/adapters/database_cleaner-mongoid/database_cleaner-mongoid.gemspec deleted file mode 100644 index ea6ace34..00000000 --- a/adapters/database_cleaner-mongoid/database_cleaner-mongoid.gemspec +++ /dev/null @@ -1,31 +0,0 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/mongoid/version" - -Gem::Specification.new do |spec| - spec.name = "database_cleaner-mongoid" - spec.version = DatabaseCleaner::Mongoid::VERSION - spec.authors = ["Ernesto Tagwerker"] - spec.email = ["ernesto@ombulabs.com"] - - spec.summary = "Strategies for cleaning databases using Mongoid. Can be used to ensure a clean state for testing." - spec.description = "Strategies for cleaning databases using Mongoid. Can be used to ensure a clean state for testing." - spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-mongoid" - spec.license = "MIT" - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency "database_cleaner", "~> 1.8.0" - spec.add_dependency "database_cleaner-mongo", "~> 1.8.0" - spec.add_dependency "mongoid" - - spec.add_development_dependency "bundler", "~> 1.16" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" -end diff --git a/adapters/database_cleaner-mongoid/lib/database_cleaner-mongoid.rb b/adapters/database_cleaner-mongoid/lib/database_cleaner-mongoid.rb deleted file mode 100644 index 536edc91..00000000 --- a/adapters/database_cleaner-mongoid/lib/database_cleaner-mongoid.rb +++ /dev/null @@ -1 +0,0 @@ -require "database_cleaner/mongoid" diff --git a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid.rb b/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid.rb deleted file mode 100644 index bd58a7d8..00000000 --- a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "database_cleaner/mongoid/version" -require "database_cleaner" -require "database_cleaner/mongoid/truncation" - -module DatabaseCleaner::Mongoid - def self.default_strategy - :truncation - end -end - diff --git a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/base.rb b/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/base.rb deleted file mode 100644 index 417d4665..00000000 --- a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/base.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'database_cleaner/generic/base' -module DatabaseCleaner - module Mongoid - def self.available_strategies - %w[truncation] - end - - module Base - include ::DatabaseCleaner::Generic::Base - - def db=(desired_db) - @db = desired_db - end - - def db - @db || :default - end - end - end -end diff --git a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo1_truncation_mixin.rb b/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo1_truncation_mixin.rb deleted file mode 100644 index fd29d9c8..00000000 --- a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo1_truncation_mixin.rb +++ /dev/null @@ -1,26 +0,0 @@ -module DatabaseCleaner - module Mongoid - module Mongo1TruncationMixin - def clean - if @only - collections.each { |c| c.send(truncate_method_name) if @only.include?(c.name) } - else - collections.each { |c| c.send(truncate_method_name) unless @tables_to_exclude.include?(c.name) } - end - true - end - - private - - def collections - database.collections.select { |c| c.name !~ /^system\./ } - end - - def truncate_method_name - # This constant only exists in the 2.x series. - defined?(::Mongo::VERSION) ? :delete_many : :remove - end - end - end -end - diff --git a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo2_truncation_mixin.rb b/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo2_truncation_mixin.rb deleted file mode 100644 index 459ed3db..00000000 --- a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo2_truncation_mixin.rb +++ /dev/null @@ -1,38 +0,0 @@ -module DatabaseCleaner - module Mongoid - module Mongo2TruncationMixin - def clean - if @only - collections.each { |c| database[c].find.delete_many if @only.include?(c) } - else - collections.each { |c| database[c].find.delete_many unless @tables_to_exclude.include?(c) } - end - true - end - - private - - def database - if @db.nil? || @db == :default - ::Mongoid::Clients.default - else - ::Mongoid::Clients.with_name(@db) - end - end - - def collections - if db != :default - database.use(db) - end - - database.collections.collect { |c| c.namespace.split('.',2)[1] } - - # database['system.namespaces'].find(:name => { '$not' => /\.system\.|\$/ }).to_a.map do |collection| - # _, name = collection['name'].split('.', 2) - # name - # end - end - end - end -end - diff --git a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongoid_truncation_mixin.rb b/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongoid_truncation_mixin.rb deleted file mode 100644 index 3e1e1640..00000000 --- a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongoid_truncation_mixin.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'database_cleaner/generic/base' -require 'database_cleaner/generic/truncation' - -module DatabaseCleaner - module Mongoid - module MongoidTruncationMixin - include ::DatabaseCleaner::Generic::Base - include ::DatabaseCleaner::Generic::Truncation - - def db=(desired_db) - @db = desired_db - end - - def db - @db ||= :default - end - - def host_port=(desired_host) - @host = desired_host - end - - def host - @host ||= '127.0.0.1:27017' - end - - def db_version - @db_version ||= session.command('buildinfo' => 1)['version'] - end - - def clean - if @only - collections.each { |c| session[c].find.remove_all if @only.include?(c) } - else - collections.each { |c| session[c].find.remove_all unless @tables_to_exclude.include?(c) } - end - wait_for_removals_to_finish - true - end - - private - - def collections - if db != :default - session.use(db) - end - - if db_version.split('.').first.to_i >= 3 - session.command(listCollections: 1, filter: { 'name' => { '$not' => /.?system\.|\$/ } })['cursor']['firstBatch'].map do |collection| - collection['name'] - end - else - session['system.namespaces'].find(name: { '$not' => /\.system\.|\$/ }).to_a.map do |collection| - _, name = collection['name'].split('.', 2) - name - end - end - end - - def wait_for_removals_to_finish - session.command(getlasterror: 1) - end - end - end -end - diff --git a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/truncation.rb b/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/truncation.rb deleted file mode 100644 index 0131930e..00000000 --- a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/truncation.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'database_cleaner/mongoid/base' -require 'database_cleaner/generic/truncation' -require 'database_cleaner/mongoid/mongo1_truncation_mixin' -require 'database_cleaner/mongoid/mongo2_truncation_mixin' -require 'database_cleaner/mongoid/mongoid_truncation_mixin' -require 'mongoid/version' - -module DatabaseCleaner - module Mongoid - class Truncation - include ::DatabaseCleaner::Mongoid::Base - include ::DatabaseCleaner::Generic::Truncation - - if ::Mongoid::VERSION < '3' - - include ::DatabaseCleaner::Mongoid::Mongo1TruncationMixin - - private - - def database - ::Mongoid.database - end - - elsif ::Mongoid::VERSION < '5' - - include ::DatabaseCleaner::Mongoid::MongoidTruncationMixin - - private - - def session - ::Mongoid::VERSION > "5.0.0" ? ::Mongoid.default_client : ::Mongoid.default_session - end - - def database - if not(@db.nil? or @db == :default) - ::Mongoid.databases[@db] - else - ::Mongoid.database - end - end - - else - - include ::DatabaseCleaner::Mongoid::Mongo2TruncationMixin - - end - end - end -end diff --git a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/version.rb b/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/version.rb deleted file mode 100644 index ebf37220..00000000 --- a/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DatabaseCleaner - module Mongoid - VERSION = "1.8.1" - end -end diff --git a/adapters/database_cleaner-mongoid/spec/database_cleaner/mongoid/base_spec.rb b/adapters/database_cleaner-mongoid/spec/database_cleaner/mongoid/base_spec.rb deleted file mode 100644 index eab25b1d..00000000 --- a/adapters/database_cleaner-mongoid/spec/database_cleaner/mongoid/base_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'database_cleaner/mongoid' - -RSpec.describe DatabaseCleaner::Mongoid do - it "has a default_strategy of truncation" do - expect(described_class.default_strategy).to eq(:truncation) - end -end - diff --git a/adapters/database_cleaner-mongoid/spec/spec_helper.rb b/adapters/database_cleaner-mongoid/spec/spec_helper.rb deleted file mode 100644 index f582c407..00000000 --- a/adapters/database_cleaner-mongoid/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "bundler/setup" -require "database_cleaner/mongoid" - -RSpec.configure do |config| - # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" - - # Disable RSpec exposing methods globally on `Module` and `main` - config.disable_monkey_patching! - - config.expect_with :rspec do |c| - c.syntax = :expect - end -end diff --git a/adapters/database_cleaner-moped/.gitignore b/adapters/database_cleaner-moped/.gitignore deleted file mode 100644 index b04a8c84..00000000 --- a/adapters/database_cleaner-moped/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/tmp/ - -# rspec failure tracking -.rspec_status diff --git a/adapters/database_cleaner-moped/.rspec b/adapters/database_cleaner-moped/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/adapters/database_cleaner-moped/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/adapters/database_cleaner-moped/.travis.yml b/adapters/database_cleaner-moped/.travis.yml deleted file mode 100644 index 9912d68f..00000000 --- a/adapters/database_cleaner-moped/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -rvm: - - 2.2.9 -before_install: gem install bundler -v 1.17.2 diff --git a/adapters/database_cleaner-moped/Gemfile b/adapters/database_cleaner-moped/Gemfile deleted file mode 100644 index 18b6f2b0..00000000 --- a/adapters/database_cleaner-moped/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -# Specify your gem's dependencies in database_cleaner-moped.gemspec -gemspec - -gem "database_cleaner", path: "../.." diff --git a/adapters/database_cleaner-moped/Gemfile.lock b/adapters/database_cleaner-moped/Gemfile.lock deleted file mode 100644 index 49a5afa0..00000000 --- a/adapters/database_cleaner-moped/Gemfile.lock +++ /dev/null @@ -1,50 +0,0 @@ -PATH - remote: ../.. - specs: - database_cleaner (1.8.2) - -PATH - remote: . - specs: - database_cleaner-moped (1.8.0) - database_cleaner (~> 1.8.0) - moped - -GEM - remote: https://rubygems.org/ - specs: - bson (3.2.7) - connection_pool (2.2.2) - diff-lcs (1.3) - moped (2.0.7) - bson (~> 3.0) - connection_pool (~> 2.0) - optionable (~> 0.2.0) - optionable (0.2.0) - rake (10.4.2) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.16) - database_cleaner! - database_cleaner-moped! - rake (~> 10.0) - rspec (~> 3.0) - -BUNDLED WITH - 1.17.3 diff --git a/adapters/database_cleaner-moped/LICENSE.txt b/adapters/database_cleaner-moped/LICENSE.txt deleted file mode 100644 index 392bc0d3..00000000 --- a/adapters/database_cleaner-moped/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2009 Ben Mabey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/adapters/database_cleaner-moped/README.md b/adapters/database_cleaner-moped/README.md deleted file mode 100644 index a6fcdba9..00000000 --- a/adapters/database_cleaner-moped/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# Database Cleaner Adapter for Moped - -[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-moped.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-moped) -[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-moped/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-moped) - -Clean your Moped databases with Database Cleaner. - -See https://github.com/DatabaseCleaner/database_cleaner for more information. - -## Installation - -```ruby -# Gemfile -group :test do - gem 'database_cleaner-moped' -end -``` - -## Supported Strategies - - - - - - - - - - - - - - -
TruncationTransactionDeletion
Yes No No
- -(Default strategy is denoted in bold) - -## Configuration options - - - - - - - - - - - - - - -
ORMHow to accessNotes
Moped DatabaseCleaner[:moped] It is necessary to configure database name with DatabaseCleaner[:moped].db = db_name otherwise name `default` will be used.
- -## COPYRIGHT - -See [LICENSE] for details. diff --git a/adapters/database_cleaner-moped/Rakefile b/adapters/database_cleaner-moped/Rakefile deleted file mode 100644 index b7e9ed54..00000000 --- a/adapters/database_cleaner-moped/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/adapters/database_cleaner-moped/bin/console b/adapters/database_cleaner-moped/bin/console deleted file mode 100755 index 3b3f45f1..00000000 --- a/adapters/database_cleaner-moped/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "database_cleaner/moped" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/adapters/database_cleaner-moped/bin/setup b/adapters/database_cleaner-moped/bin/setup deleted file mode 100755 index 3fc33879..00000000 --- a/adapters/database_cleaner-moped/bin/setup +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle check || bundle install - diff --git a/adapters/database_cleaner-moped/database_cleaner-moped.gemspec b/adapters/database_cleaner-moped/database_cleaner-moped.gemspec deleted file mode 100644 index bc0b628e..00000000 --- a/adapters/database_cleaner-moped/database_cleaner-moped.gemspec +++ /dev/null @@ -1,30 +0,0 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/moped/version" - -Gem::Specification.new do |spec| - spec.name = "database_cleaner-moped" - spec.version = DatabaseCleaner::Moped::VERSION - spec.authors = ["Ernesto Tagwerker"] - spec.email = ["ernesto@ombulabs.com"] - - spec.summary = "Strategies for cleaning databases using Moped. Can be used to ensure a clean state for testing." - spec.description = "Strategies for cleaning databases using Moped. Can be used to ensure a clean state for testing." - spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-moped" - spec.license = "MIT" - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency "database_cleaner", "~> 1.8.0" - spec.add_dependency "moped" - - spec.add_development_dependency "bundler", "~> 1.16" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" -end diff --git a/adapters/database_cleaner-moped/lib/database_cleaner-moped.rb b/adapters/database_cleaner-moped/lib/database_cleaner-moped.rb deleted file mode 100644 index a3190f2a..00000000 --- a/adapters/database_cleaner-moped/lib/database_cleaner-moped.rb +++ /dev/null @@ -1 +0,0 @@ -require "database_cleaner/moped" diff --git a/adapters/database_cleaner-moped/lib/database_cleaner/moped.rb b/adapters/database_cleaner-moped/lib/database_cleaner/moped.rb deleted file mode 100644 index 6039ba71..00000000 --- a/adapters/database_cleaner-moped/lib/database_cleaner/moped.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "database_cleaner/moped/version" -require "database_cleaner" -require "database_cleaner/moped/truncation" - -module DatabaseCleaner::Moped - def self.default_strategy - :truncation - end -end - diff --git a/adapters/database_cleaner-moped/lib/database_cleaner/moped/base.rb b/adapters/database_cleaner-moped/lib/database_cleaner/moped/base.rb deleted file mode 100644 index 51b7a261..00000000 --- a/adapters/database_cleaner-moped/lib/database_cleaner/moped/base.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'database_cleaner/generic/base' - -module DatabaseCleaner - module Moped - def self.available_strategies - %w[truncation] - end - - module Base - include ::DatabaseCleaner::Generic::Base - - def db=(desired_db) - @db = desired_db - end - - def db - @db ||= :default - end - - def host_port=(desired_host) - @host = desired_host - end - - def host - @host ||= '127.0.0.1:27017' - end - - def db_version - @db_version ||= session.command('buildinfo' => 1)['version'] - end - - private - - def session - @session ||= ::Moped::Session.new([host], database: db) - end - end - end -end diff --git a/adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation.rb b/adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation.rb deleted file mode 100644 index 3be33495..00000000 --- a/adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'database_cleaner/moped/truncation_base' - -module DatabaseCleaner - module Moped - class Truncation - include ::DatabaseCleaner::Moped::TruncationBase - end - end -end diff --git a/adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation_base.rb b/adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation_base.rb deleted file mode 100644 index 06ce53c3..00000000 --- a/adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation_base.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'database_cleaner/moped/base' -require 'database_cleaner/generic/truncation' - -module DatabaseCleaner - module Moped - module TruncationBase - include ::DatabaseCleaner::Moped::Base - include ::DatabaseCleaner::Generic::Truncation - - def clean - if @only - collections.each { |c| session[c].find.remove_all if @only.include?(c) } - else - collections.each { |c| session[c].find.remove_all unless @tables_to_exclude.include?(c) } - end - wait_for_removals_to_finish - true - end - - private - - def collections - if db != :default - session.use(db) - end - - if db_version.split('.').first.to_i >= 3 - session.command(listCollections: 1, filter: { 'name' => { '$not' => /.?system\.|\$/ } })['cursor']['firstBatch'].map do |collection| - collection['name'] - end - else - session['system.namespaces'].find(name: { '$not' => /\.system\.|\$/ }).to_a.map do |collection| - _, name = collection['name'].split('.', 2) - name - end - end - end - - def wait_for_removals_to_finish - session.command(getlasterror: 1) - end - end - end -end diff --git a/adapters/database_cleaner-moped/lib/database_cleaner/moped/version.rb b/adapters/database_cleaner-moped/lib/database_cleaner/moped/version.rb deleted file mode 100644 index 63c44035..00000000 --- a/adapters/database_cleaner-moped/lib/database_cleaner/moped/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DatabaseCleaner - module Moped - VERSION = "1.8.0" - end -end diff --git a/adapters/database_cleaner-moped/spec/database_cleaner/moped/base_spec.rb b/adapters/database_cleaner-moped/spec/database_cleaner/moped/base_spec.rb deleted file mode 100644 index 1594cdca..00000000 --- a/adapters/database_cleaner-moped/spec/database_cleaner/moped/base_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'database_cleaner/moped' - -RSpec.describe DatabaseCleaner::Moped do - it "has a default_strategy of truncation" do - expect(described_class.default_strategy).to eq(:truncation) - end -end - diff --git a/adapters/database_cleaner-moped/spec/database_cleaner/moped/moped_examples.rb b/adapters/database_cleaner-moped/spec/database_cleaner/moped/moped_examples.rb deleted file mode 100644 index a1448504..00000000 --- a/adapters/database_cleaner-moped/spec/database_cleaner/moped/moped_examples.rb +++ /dev/null @@ -1,32 +0,0 @@ -module MopedTest - class Base - def self.collection - @db ||= 'database_cleaner_specs' - @session ||= ::Moped::Session.new(['127.0.0.1:27017'], database: @db) - @collection ||= @session[name] - end - - def self.count - @collection.find.count - end - - def initialize(attrs={}) - @attrs = attrs - end - - def save! - self.class.collection.insert(@attrs) - end - end - - class Widget < Base - end - class Gadget < Base - end - class System < Base - def self.collection - super - @collection = @session['system_logs'] - end - end -end diff --git a/adapters/database_cleaner-moped/spec/database_cleaner/moped/truncation_spec.rb b/adapters/database_cleaner-moped/spec/database_cleaner/moped/truncation_spec.rb deleted file mode 100644 index 758dcff5..00000000 --- a/adapters/database_cleaner-moped/spec/database_cleaner/moped/truncation_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'moped' -require 'database_cleaner/moped/truncation' -require File.dirname(__FILE__) + '/moped_examples' - -RSpec.describe DatabaseCleaner::Moped::Truncation do - around do |example| - db_name = 'database_cleaner_specs' - session = ::Moped::Session.new(['127.0.0.1:27017'], database: db_name) - subject.db = db_name - - example.run - - session.drop - session.command(getlasterror: 1) - end - - before do - MopedTest::Widget.new(name: 'some widget').save! - MopedTest::Gadget.new(name: 'some gadget').save! - MopedTest::System.new(name: 'some system').save! - end - - context "by default" do - it "truncates all collections" do - expect { subject.clean }.to change { - [MopedTest::Widget.count, MopedTest::Gadget.count, MopedTest::System.count] - }.from([1,1,1]).to([0,0,0]) - end - end - - context "when collections are provided to the :only option" do - subject { described_class.new(only: ['MopedTest::Widget']) } - - it "only truncates the specified collections" do - expect { subject.clean }.to change { - [MopedTest::Widget.count, MopedTest::Gadget.count, MopedTest::System.count] - }.from([1,1,1]).to([0,1,1]) - end - end - - context "when collections are provided to the :except option" do - subject { described_class.new(except: ['MopedTest::Widget']) } - - it "truncates all but the specified collections" do - expect { subject.clean }.to change { - [MopedTest::Widget.count, MopedTest::Gadget.count, MopedTest::System.count] - }.from([1,1,1]).to([1,0,0]) - end - end -end - diff --git a/adapters/database_cleaner-moped/spec/spec_helper.rb b/adapters/database_cleaner-moped/spec/spec_helper.rb deleted file mode 100644 index 00ccabe1..00000000 --- a/adapters/database_cleaner-moped/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "bundler/setup" -require "database_cleaner/moped" - -RSpec.configure do |config| - # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" - - # Disable RSpec exposing methods globally on `Module` and `main` - config.disable_monkey_patching! - - config.expect_with :rspec do |c| - c.syntax = :expect - end -end diff --git a/adapters/database_cleaner-neo4j/.gitignore b/adapters/database_cleaner-neo4j/.gitignore deleted file mode 100644 index b04a8c84..00000000 --- a/adapters/database_cleaner-neo4j/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/tmp/ - -# rspec failure tracking -.rspec_status diff --git a/adapters/database_cleaner-neo4j/.rspec b/adapters/database_cleaner-neo4j/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/adapters/database_cleaner-neo4j/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/adapters/database_cleaner-neo4j/.travis.yml b/adapters/database_cleaner-neo4j/.travis.yml deleted file mode 100644 index 9912d68f..00000000 --- a/adapters/database_cleaner-neo4j/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -rvm: - - 2.2.9 -before_install: gem install bundler -v 1.17.2 diff --git a/adapters/database_cleaner-neo4j/Gemfile b/adapters/database_cleaner-neo4j/Gemfile deleted file mode 100644 index 75c909b9..00000000 --- a/adapters/database_cleaner-neo4j/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -# Specify your gem's dependencies in database_cleaner-neo4j.gemspec -gemspec - -gem "database_cleaner", path: "../.." diff --git a/adapters/database_cleaner-neo4j/Gemfile.lock b/adapters/database_cleaner-neo4j/Gemfile.lock deleted file mode 100644 index 28267098..00000000 --- a/adapters/database_cleaner-neo4j/Gemfile.lock +++ /dev/null @@ -1,81 +0,0 @@ -PATH - remote: ../.. - specs: - database_cleaner (1.8.2) - -PATH - remote: . - specs: - database_cleaner-neo4j (1.8.0) - database_cleaner (~> 1.8.0) - neo4j-core - -GEM - remote: https://rubygems.org/ - specs: - activesupport (5.2.4.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - concurrent-ruby (1.1.5) - diff-lcs (1.3) - faraday (0.9.0) - multipart-post (>= 1.2, < 3) - faraday_middleware (0.9.1) - faraday (>= 0.7.4, < 0.10) - httparty (0.13.3) - json (~> 1.8) - multi_xml (>= 0.5.2) - httpclient (2.5.3.3) - i18n (1.5.1) - concurrent-ruby (~> 1.0) - json (1.8.6) - minitest (5.14.0) - multi_xml (0.5.5) - multipart-post (2.0.0) - neo4j-community (2.1.5) - neo4j-core (3.0.8) - activesupport - faraday (~> 0.9.0) - faraday_middleware (~> 0.9.1) - httparty - httpclient - json - neo4j-community (~> 2.1.1) - net-http-persistent - os - zip - net-http-persistent (2.9.4) - os (0.9.6) - rake (10.4.2) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - thread_safe (0.3.6) - tzinfo (1.2.6) - thread_safe (~> 0.1) - zip (2.0.2) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.16) - database_cleaner! - database_cleaner-neo4j! - rake (~> 10.0) - rspec (~> 3.0) - -BUNDLED WITH - 1.17.3 diff --git a/adapters/database_cleaner-neo4j/LICENSE.txt b/adapters/database_cleaner-neo4j/LICENSE.txt deleted file mode 100644 index 392bc0d3..00000000 --- a/adapters/database_cleaner-neo4j/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2009 Ben Mabey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/adapters/database_cleaner-neo4j/README.md b/adapters/database_cleaner-neo4j/README.md deleted file mode 100644 index eeb0eb00..00000000 --- a/adapters/database_cleaner-neo4j/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Database Cleaner Adapter for Neo4j - -[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-neo4j.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-neo4j) -[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-neo4j/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-neo4j) - -Clean your Neo4j databases with Database Cleaner. - -See https://github.com/DatabaseCleaner/database_cleaner for more information. - -## Installation - -```ruby -# Gemfile -group :test do - gem 'database_cleaner-neo4j' -end -``` - -## Supported Strategies - - - - - - - - - - - - - - -
TruncationTransactionDeletion
Yes Yes Yes
- -(Default strategy is denoted in bold) - -## Configuration options - - - - - - - - - - - - - - -
ORMHow to accessNotes
Neo4jDatabaseCleaner[:neo4j]Database type and path(URI) DatabaseCleaner[:neo4j, connection: {type: :server_db, path: 'http://localhost:7475'}].
- -Note that Truncation and Deletion strategies for Neo4j will just delete all nodes and relationships from the database. - -## Common Errors - -### Model fails to load with Neo4j using transactions - -When you are using [neo4j](https://github.com/neo4jrb/neo4j) gem it creates schema and reads indexes upon loading models. These operations can't be done during a transaction. You have to preload your models before DatabaseCleaner starts a transaction. - -Add to your rails_helper or spec_helper after requiring database_cleaner-neo4j: - -```ruby -require 'database_cleaner/neo4j' - -Dir["#{Rails.root}/app/models/**/*.rb"].each do |model| - load model -end -``` - -## COPYRIGHT - -See [LICENSE] for details. diff --git a/adapters/database_cleaner-neo4j/Rakefile b/adapters/database_cleaner-neo4j/Rakefile deleted file mode 100644 index b7e9ed54..00000000 --- a/adapters/database_cleaner-neo4j/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/adapters/database_cleaner-neo4j/bin/console b/adapters/database_cleaner-neo4j/bin/console deleted file mode 100755 index 5cf2dcf1..00000000 --- a/adapters/database_cleaner-neo4j/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "database_cleaner/neo4j" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/adapters/database_cleaner-neo4j/bin/setup b/adapters/database_cleaner-neo4j/bin/setup deleted file mode 100755 index 3fc33879..00000000 --- a/adapters/database_cleaner-neo4j/bin/setup +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle check || bundle install - diff --git a/adapters/database_cleaner-neo4j/database_cleaner-neo4j.gemspec b/adapters/database_cleaner-neo4j/database_cleaner-neo4j.gemspec deleted file mode 100644 index a39b6524..00000000 --- a/adapters/database_cleaner-neo4j/database_cleaner-neo4j.gemspec +++ /dev/null @@ -1,30 +0,0 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/neo4j/version" - -Gem::Specification.new do |spec| - spec.name = "database_cleaner-neo4j" - spec.version = DatabaseCleaner::Neo4j::VERSION - spec.authors = ["Ernesto Tagwerker"] - spec.email = ["ernesto@ombulabs.com"] - - spec.summary = "Strategies for cleaning databases using Neo4j. Can be used to ensure a clean state for testing." - spec.description = "Strategies for cleaning databases using Neo4j. Can be used to ensure a clean state for testing." - spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-neo4j" - spec.license = "MIT" - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency "database_cleaner", "~> 1.8.0" - spec.add_dependency "neo4j-core" - - spec.add_development_dependency "bundler", "~> 1.16" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" -end diff --git a/adapters/database_cleaner-neo4j/lib/database_cleaner-neo4j.rb b/adapters/database_cleaner-neo4j/lib/database_cleaner-neo4j.rb deleted file mode 100644 index 8ea3f62a..00000000 --- a/adapters/database_cleaner-neo4j/lib/database_cleaner-neo4j.rb +++ /dev/null @@ -1 +0,0 @@ -require "database_cleaner/neo4j" diff --git a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j.rb b/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j.rb deleted file mode 100644 index ad87e33b..00000000 --- a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "database_cleaner/neo4j/version" -require "database_cleaner" -require "database_cleaner/neo4j/transaction" -require "database_cleaner/neo4j/truncation" -require "database_cleaner/neo4j/deletion" - diff --git a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/base.rb b/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/base.rb deleted file mode 100644 index 727ae10a..00000000 --- a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/base.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'database_cleaner/generic/base' -module DatabaseCleaner - module Neo4j - def self.available_strategies - %w[transaction truncation deletion] - end - - def self.default_strategy - :transaction - end - - module Base - include ::DatabaseCleaner::Generic::Base - - def db=(desired_db) - @db = desired_db == :default ? nil : desired_db - end - - def db - @db ||= nil - end - - def start - if db_type == :embedded_db and not session.running? - session.start - else - session - end - end - - def database - db && default_db.merge(db) || default_db - end - - private - - def default_db - {:type => default_db_type, :path => default_db_path} - end - - def default_db_type - :server_db - end - - def default_db_path(type = default_db_type) - type == :server_db ? 'http://localhost:7475/' : './db/test' - end - - def db_type - database[:type] - end - - def db_path - database[:path] - end - - def db_params - database.reject!{|key, value| [:type, :path].include? key } - end - - def session - @session ||= ::Neo4j::Session.open(db_type, db_path, db_params) - end - end - end -end diff --git a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/deletion.rb b/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/deletion.rb deleted file mode 100644 index c6166ef0..00000000 --- a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/deletion.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'database_cleaner/neo4j/base' -require 'neo4j-core' - -module DatabaseCleaner - module Neo4j - class Deletion - include ::DatabaseCleaner::Neo4j::Base - - def clean - ::Neo4j::Transaction.run do - session._query('MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r') - end - end - end - end -end diff --git a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/transaction.rb b/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/transaction.rb deleted file mode 100644 index b3e0dd9b..00000000 --- a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/transaction.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'database_cleaner/neo4j/base' -require 'database_cleaner/generic/transaction' -require 'neo4j-core' - -module DatabaseCleaner - module Neo4j - class Transaction - include ::DatabaseCleaner::Generic::Transaction - include ::DatabaseCleaner::Neo4j::Base - - attr_accessor :tx - - def start - super - rollback - self.tx = ::Neo4j::Transaction.new - end - - def clean - rollback - end - - private - - def rollback - if tx - tx.failure - tx.close - end - ensure - self.tx = nil - end - end - end -end diff --git a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/truncation.rb b/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/truncation.rb deleted file mode 100644 index 6d92e1ce..00000000 --- a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/truncation.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'database_cleaner/neo4j/base' -require 'database_cleaner/neo4j/deletion' - -module DatabaseCleaner - module Neo4j - class Truncation < DatabaseCleaner::Neo4j::Deletion - end - end -end diff --git a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/version.rb b/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/version.rb deleted file mode 100644 index 0a436766..00000000 --- a/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DatabaseCleaner - module Neo4j - VERSION = "1.8.0" - end -end diff --git a/adapters/database_cleaner-neo4j/spec/database_cleaner/neo4j/base_spec.rb b/adapters/database_cleaner-neo4j/spec/database_cleaner/neo4j/base_spec.rb deleted file mode 100644 index 467cd455..00000000 --- a/adapters/database_cleaner-neo4j/spec/database_cleaner/neo4j/base_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'database_cleaner/neo4j/base' -require 'database_cleaner/spec' - -module DatabaseCleaner - RSpec.describe Neo4j do - it { is_expected.to respond_to(:available_strategies) } - - it "has a default_strategy of transaction" do - expect(described_class.default_strategy).to eq(:transaction) - end - end - - module Neo4j - class ExampleStrategy - include ::DatabaseCleaner::Neo4j::Base - end - - RSpec.describe ExampleStrategy do - - it_should_behave_like "a generic strategy" - it { is_expected.to respond_to(:db) } - it { is_expected.to respond_to(:db=) } - - it "should store my describe db" do - db_conf = {:connection => {:type => :server_db, :path => 'http://localhost:7474'}} - subject.db = db_conf - expect(subject.db).to eq db_conf - end - - it "should respect additional connection parameters" do - db_conf = {:type => :server_db, :path => 'http://localhost:7474', basic_auth: {username: 'user', password: 'pass'}} - subject.db = db_conf - expect(stub_const("Neo4j::Session", double())).to receive(:open).with(:server_db, 'http://localhost:7474', {basic_auth: {username: 'user', password: 'pass'}}) { true } - subject.start - end - - it "should default to nil" do - expect(subject.db).to be_nil - end - - it "should return default configuration" do - expect(subject.database).to eq(:type => :server_db, :path => 'http://localhost:7475/') - end - end - end -end diff --git a/adapters/database_cleaner-neo4j/spec/database_cleaner/neo4j/transaction_spec.rb b/adapters/database_cleaner-neo4j/spec/database_cleaner/neo4j/transaction_spec.rb deleted file mode 100644 index 1a130a9f..00000000 --- a/adapters/database_cleaner-neo4j/spec/database_cleaner/neo4j/transaction_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'neo4j-core' -require 'database_cleaner/neo4j/transaction' -require 'database_cleaner/spec' - -module DatabaseCleaner - module Neo4j - - RSpec.describe Transaction do - before(:all) do - DatabaseCleaner[:neo4j, :connection => {:type => :server_db, :path => 'http://localhost:7474'}] - end - - it_should_behave_like "a generic strategy" - it_should_behave_like "a generic transaction strategy" - - describe "start" do - it "should start a transaction" - end - - describe "clean" do - it "should finish a transaction" - end - end - end -end diff --git a/adapters/database_cleaner-neo4j/spec/spec_helper.rb b/adapters/database_cleaner-neo4j/spec/spec_helper.rb deleted file mode 100644 index 59a87b7b..00000000 --- a/adapters/database_cleaner-neo4j/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "bundler/setup" -require "database_cleaner/neo4j" - -RSpec.configure do |config| - # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" - - # Disable RSpec exposing methods globally on `Module` and `main` - config.disable_monkey_patching! - - config.expect_with :rspec do |c| - c.syntax = :expect - end -end diff --git a/adapters/database_cleaner-ohm/.gitignore b/adapters/database_cleaner-ohm/.gitignore deleted file mode 100644 index b04a8c84..00000000 --- a/adapters/database_cleaner-ohm/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/tmp/ - -# rspec failure tracking -.rspec_status diff --git a/adapters/database_cleaner-ohm/.rspec b/adapters/database_cleaner-ohm/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/adapters/database_cleaner-ohm/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/adapters/database_cleaner-ohm/.travis.yml b/adapters/database_cleaner-ohm/.travis.yml deleted file mode 100644 index 9912d68f..00000000 --- a/adapters/database_cleaner-ohm/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -rvm: - - 2.2.9 -before_install: gem install bundler -v 1.17.2 diff --git a/adapters/database_cleaner-ohm/Gemfile b/adapters/database_cleaner-ohm/Gemfile deleted file mode 100644 index 45f8ad4c..00000000 --- a/adapters/database_cleaner-ohm/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -# Specify your gem's dependencies in database_cleaner-ohm.gemspec -gemspec - -gem "database_cleaner", path: "../.." -gem "database_cleaner-redis", path: ".." diff --git a/adapters/database_cleaner-ohm/Gemfile.lock b/adapters/database_cleaner-ohm/Gemfile.lock deleted file mode 100644 index afc19be0..00000000 --- a/adapters/database_cleaner-ohm/Gemfile.lock +++ /dev/null @@ -1,64 +0,0 @@ -PATH - remote: ../.. - specs: - database_cleaner (1.8.2) - -PATH - remote: .. - specs: - database_cleaner-redis (1.8.0) - database_cleaner (~> 1.8.0) - redis - -PATH - remote: . - specs: - database_cleaner-ohm (1.8.1) - database_cleaner (~> 1.8.0) - database_cleaner-redis (~> 1.8.0) - ohm - -GEM - remote: https://rubygems.org/ - specs: - diff-lcs (1.3) - hiredis (0.6.3) - nest (3.2.0) - redic - ohm (3.1.1) - nest (~> 3) - redic (~> 1.5.0) - stal - rake (10.4.2) - redic (1.5.3) - hiredis - redis (4.1.1) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - stal (0.3.0) - redic (~> 1.5) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.16) - database_cleaner! - database_cleaner-ohm! - database_cleaner-redis! - rake (~> 10.0) - rspec (~> 3.0) - -BUNDLED WITH - 1.17.3 diff --git a/adapters/database_cleaner-ohm/LICENSE.txt b/adapters/database_cleaner-ohm/LICENSE.txt deleted file mode 100644 index 392bc0d3..00000000 --- a/adapters/database_cleaner-ohm/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2009 Ben Mabey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/adapters/database_cleaner-ohm/README.md b/adapters/database_cleaner-ohm/README.md deleted file mode 100644 index 3a832a00..00000000 --- a/adapters/database_cleaner-ohm/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# Database Cleaner Adapter for Ohm - -[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-ohm.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-ohm) -[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-ohm/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-ohm) - -Clean your Ohm databases with Database Cleaner. - -See https://github.com/DatabaseCleaner/database_cleaner for more information. - -## Installation - -```ruby -# Gemfile -group :test do - gem 'database_cleaner-ohm' -end -``` - -## Supported Strategies - - - - - - - - - - - - - - -
TruncationTransactionDeletion
Yes No No
- -(Default strategy is denoted in bold) - -## Configuration options - -`:only` and `:except` take a list of strings to be passed to [`keys`](https://redis.io/commands/keys)). - - - - - - - - - - - - - - -
ORMHow to accessNotes
OhmDatabaseCleaner[:ohm]Connection specified as Redis URI
- -## COPYRIGHT - -See [LICENSE] for details. diff --git a/adapters/database_cleaner-ohm/Rakefile b/adapters/database_cleaner-ohm/Rakefile deleted file mode 100644 index b7e9ed54..00000000 --- a/adapters/database_cleaner-ohm/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/adapters/database_cleaner-ohm/bin/console b/adapters/database_cleaner-ohm/bin/console deleted file mode 100755 index fc6cccb2..00000000 --- a/adapters/database_cleaner-ohm/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "database_cleaner/ohm" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/adapters/database_cleaner-ohm/bin/setup b/adapters/database_cleaner-ohm/bin/setup deleted file mode 100755 index 3fc33879..00000000 --- a/adapters/database_cleaner-ohm/bin/setup +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle check || bundle install - diff --git a/adapters/database_cleaner-ohm/database_cleaner-ohm.gemspec b/adapters/database_cleaner-ohm/database_cleaner-ohm.gemspec deleted file mode 100644 index ad32c728..00000000 --- a/adapters/database_cleaner-ohm/database_cleaner-ohm.gemspec +++ /dev/null @@ -1,31 +0,0 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/ohm/version" - -Gem::Specification.new do |spec| - spec.name = "database_cleaner-ohm" - spec.version = DatabaseCleaner::Ohm::VERSION - spec.authors = ["Ernesto Tagwerker"] - spec.email = ["ernesto@ombulabs.com"] - - spec.summary = "Strategies for cleaning databases using Ohm. Can be used to ensure a clean state for testing." - spec.description = "Strategies for cleaning databases using Ohm. Can be used to ensure a clean state for testing." - spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-ohm" - spec.license = "MIT" - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency "database_cleaner", "~> 1.8.0" - spec.add_dependency "database_cleaner-redis", "~> 1.8.0" - spec.add_dependency "ohm" - - spec.add_development_dependency "bundler", "~> 1.16" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" -end diff --git a/adapters/database_cleaner-ohm/lib/database_cleaner-ohm.rb b/adapters/database_cleaner-ohm/lib/database_cleaner-ohm.rb deleted file mode 100644 index 59abca27..00000000 --- a/adapters/database_cleaner-ohm/lib/database_cleaner-ohm.rb +++ /dev/null @@ -1 +0,0 @@ -require "database_cleaner/ohm" diff --git a/adapters/database_cleaner-ohm/lib/database_cleaner/ohm.rb b/adapters/database_cleaner-ohm/lib/database_cleaner/ohm.rb deleted file mode 100644 index 4ad0600a..00000000 --- a/adapters/database_cleaner-ohm/lib/database_cleaner/ohm.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "database_cleaner/ohm/version" -require "database_cleaner" -require "database_cleaner/ohm/truncation" - -DatabaseCleaner.deprecate "The Ohm adapter for DatabaseCleaner is deprecated, and will be removed in v2.0. Please use the Redis adapter instead." - -module DatabaseCleaner::Ohm - def self.default_strategy - :truncation - end -end - diff --git a/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/truncation.rb b/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/truncation.rb deleted file mode 100644 index 792e94af..00000000 --- a/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/truncation.rb +++ /dev/null @@ -1,24 +0,0 @@ -begin # when database_cleaner-ohm is loaded as a gem - require 'database_cleaner/redis/truncation' -rescue LoadError # when database_cleaner is loaded as a gem - $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../../../../../adapters/database_cleaner-redis/lib") - require 'database_cleaner/redis/truncation' -end - -module DatabaseCleaner - module Ohm - def self.available_strategies - %w(truncation) - end - - class Truncation < ::DatabaseCleaner::Redis::Truncation - - private - - def default_redis - ::Ohm.redis - end - - end - end -end diff --git a/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/version.rb b/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/version.rb deleted file mode 100644 index 7bb9c726..00000000 --- a/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DatabaseCleaner - module Ohm - VERSION = "1.8.1" - end -end diff --git a/adapters/database_cleaner-ohm/spec/database_cleaner/ohm/base_spec.rb b/adapters/database_cleaner-ohm/spec/database_cleaner/ohm/base_spec.rb deleted file mode 100644 index 0662e815..00000000 --- a/adapters/database_cleaner-ohm/spec/database_cleaner/ohm/base_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'database_cleaner/ohm' - -RSpec.describe DatabaseCleaner::Ohm do - it "has a default_strategy of truncation" do - expect(described_class.default_strategy).to eq(:truncation) - end -end - diff --git a/adapters/database_cleaner-ohm/spec/database_cleaner/ohm/truncation_spec.rb b/adapters/database_cleaner-ohm/spec/database_cleaner/ohm/truncation_spec.rb deleted file mode 100644 index a09f7f69..00000000 --- a/adapters/database_cleaner-ohm/spec/database_cleaner/ohm/truncation_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'ohm' -require 'database_cleaner/ohm/truncation' -require 'yaml' - -module OhmTests - class Widget < ::Ohm::Model - attribute :name - end - - class Gadget < ::Ohm::Model - attribute :name - end -end - -RSpec.describe DatabaseCleaner::Ohm::Truncation do - around do |example| - config = YAML::load(File.open("spec/support/redis.yml")) - Ohm.connect url: config['test']['url'] - @redis = Ohm.redis - - example.run - - @redis.flushdb - end - - before do - OhmTests::Widget.new(name: 'some widget').save - OhmTests::Gadget.new(name: 'some gadget').save - end - - context "by default" do - it "truncates all keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(6).to(0) - end - end - - context "when keys are provided to the :only option" do - subject { described_class.new(only: ['*Widget*']) } - - it "only truncates the specified keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(6).to(3) - expect(@redis.get('OhmTests::Gadget:id')).to eq '1' - end - end - - context "when keys are provided to the :except option" do - subject { described_class.new(except: ['*Widget*']) } - - it "truncates all but the specified keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(6).to(3) - expect(@redis.get('OhmTests::Widget:id')).to eq '1' - end - end -end - diff --git a/adapters/database_cleaner-ohm/spec/spec_helper.rb b/adapters/database_cleaner-ohm/spec/spec_helper.rb deleted file mode 100644 index d5af979f..00000000 --- a/adapters/database_cleaner-ohm/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "bundler/setup" -require "database_cleaner/ohm" - -RSpec.configure do |config| - # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" - - # Disable RSpec exposing methods globally on `Module` and `main` - config.disable_monkey_patching! - - config.expect_with :rspec do |c| - c.syntax = :expect - end -end diff --git a/adapters/database_cleaner-ohm/spec/support/redis.yml b/adapters/database_cleaner-ohm/spec/support/redis.yml deleted file mode 100644 index a3b6cba0..00000000 --- a/adapters/database_cleaner-ohm/spec/support/redis.yml +++ /dev/null @@ -1,8 +0,0 @@ -test: - url: 'redis://localhost:6379/0' - -one: - url: 'redis://localhost:6379/1' - -two: - url: 'redis://localhost:6379/2' diff --git a/adapters/database_cleaner-redis/.gitignore b/adapters/database_cleaner-redis/.gitignore deleted file mode 100644 index b04a8c84..00000000 --- a/adapters/database_cleaner-redis/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/tmp/ - -# rspec failure tracking -.rspec_status diff --git a/adapters/database_cleaner-redis/.rspec b/adapters/database_cleaner-redis/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/adapters/database_cleaner-redis/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/adapters/database_cleaner-redis/.travis.yml b/adapters/database_cleaner-redis/.travis.yml deleted file mode 100644 index 9912d68f..00000000 --- a/adapters/database_cleaner-redis/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -rvm: - - 2.2.9 -before_install: gem install bundler -v 1.17.2 diff --git a/adapters/database_cleaner-redis/Gemfile b/adapters/database_cleaner-redis/Gemfile deleted file mode 100644 index 6520bbc6..00000000 --- a/adapters/database_cleaner-redis/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -# Specify your gem's dependencies in database_cleaner-redis.gemspec -gemspec - -gem "database_cleaner", path: "../.." diff --git a/adapters/database_cleaner-redis/Gemfile.lock b/adapters/database_cleaner-redis/Gemfile.lock deleted file mode 100644 index 2e223d4e..00000000 --- a/adapters/database_cleaner-redis/Gemfile.lock +++ /dev/null @@ -1,44 +0,0 @@ -PATH - remote: ../.. - specs: - database_cleaner (1.8.2) - -PATH - remote: . - specs: - database_cleaner-redis (1.8.0) - database_cleaner (~> 1.8.0) - redis - -GEM - remote: https://rubygems.org/ - specs: - diff-lcs (1.3) - rake (10.4.2) - redis (4.1.1) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.16) - database_cleaner! - database_cleaner-redis! - rake (~> 10.0) - rspec (~> 3.0) - -BUNDLED WITH - 1.17.3 diff --git a/adapters/database_cleaner-redis/LICENSE.txt b/adapters/database_cleaner-redis/LICENSE.txt deleted file mode 100644 index 392bc0d3..00000000 --- a/adapters/database_cleaner-redis/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2009 Ben Mabey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/adapters/database_cleaner-redis/README.md b/adapters/database_cleaner-redis/README.md deleted file mode 100644 index 742d2a27..00000000 --- a/adapters/database_cleaner-redis/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# Database Cleaner Adapter for Redis - -[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-redis.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-redis) -[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-redis/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-redis) - -Clean your Redis databases with Database Cleaner. - -See https://github.com/DatabaseCleaner/database_cleaner for more information. - -## Installation - -```ruby -# Gemfile -group :test do - gem 'database_cleaner-redis' -end -``` - -## Supported Strategies - - - - - - - - - - - - - - -
TruncationTransactionDeletion
Yes No No
- -(Default strategy is denoted in bold) - -## Configuration options - -`:only` and `:except` take a list of strings to be passed to [`keys`](https://redis.io/commands/keys)). - - - - - - - - - - - - - - -
ORMHow to accessNotes
RedisDatabaseCleaner[:redis]Connection specified as Redis URI
- -## COPYRIGHT - -See [LICENSE] for details. diff --git a/adapters/database_cleaner-redis/Rakefile b/adapters/database_cleaner-redis/Rakefile deleted file mode 100644 index b7e9ed54..00000000 --- a/adapters/database_cleaner-redis/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/adapters/database_cleaner-redis/bin/console b/adapters/database_cleaner-redis/bin/console deleted file mode 100755 index 9f71d2bc..00000000 --- a/adapters/database_cleaner-redis/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "database_cleaner/redis" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/adapters/database_cleaner-redis/bin/setup b/adapters/database_cleaner-redis/bin/setup deleted file mode 100755 index 3fc33879..00000000 --- a/adapters/database_cleaner-redis/bin/setup +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle check || bundle install - diff --git a/adapters/database_cleaner-redis/database_cleaner-redis.gemspec b/adapters/database_cleaner-redis/database_cleaner-redis.gemspec deleted file mode 100644 index 3afd8e4e..00000000 --- a/adapters/database_cleaner-redis/database_cleaner-redis.gemspec +++ /dev/null @@ -1,30 +0,0 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/redis/version" - -Gem::Specification.new do |spec| - spec.name = "database_cleaner-redis" - spec.version = DatabaseCleaner::Redis::VERSION - spec.authors = ["Ernesto Tagwerker"] - spec.email = ["ernesto@ombulabs.com"] - - spec.summary = "Strategies for cleaning databases using Redis. Can be used to ensure a clean state for testing." - spec.description = "Strategies for cleaning databases using Redis. Can be used to ensure a clean state for testing." - spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-redis" - spec.license = "MIT" - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency "database_cleaner", "~> 1.8.0" - spec.add_dependency "redis" - - spec.add_development_dependency "bundler", "~> 1.16" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" -end diff --git a/adapters/database_cleaner-redis/lib/database_cleaner-redis.rb b/adapters/database_cleaner-redis/lib/database_cleaner-redis.rb deleted file mode 100644 index 63b1d4af..00000000 --- a/adapters/database_cleaner-redis/lib/database_cleaner-redis.rb +++ /dev/null @@ -1 +0,0 @@ -require "database_cleaner/redis" diff --git a/adapters/database_cleaner-redis/lib/database_cleaner/redis.rb b/adapters/database_cleaner-redis/lib/database_cleaner/redis.rb deleted file mode 100644 index de1c042a..00000000 --- a/adapters/database_cleaner-redis/lib/database_cleaner/redis.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "database_cleaner/redis/version" -require "database_cleaner" -require "database_cleaner/redis/truncation" - diff --git a/adapters/database_cleaner-redis/lib/database_cleaner/redis/base.rb b/adapters/database_cleaner-redis/lib/database_cleaner/redis/base.rb deleted file mode 100644 index 1d904798..00000000 --- a/adapters/database_cleaner-redis/lib/database_cleaner/redis/base.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'database_cleaner/generic/base' - -module DatabaseCleaner - module Redis - def self.available_strategies - %w{truncation} - end - - def self.default_strategy - :truncation - end - - module Base - include ::DatabaseCleaner::Generic::Base - - def db=(desired_db) - @db = desired_db - end - - def db - @db ||= :default - end - - alias url db - - private - - def connection - @connection ||= begin - if url == :default - ::Redis.new - elsif db.is_a?(::Redis) # pass directly the connection - db - else - ::Redis.new(:url => url) - end - end - end - end - end -end diff --git a/adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb b/adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb deleted file mode 100644 index 32badcc4..00000000 --- a/adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'database_cleaner/redis/base' -require 'database_cleaner/generic/truncation' - -module DatabaseCleaner - module Redis - class Truncation - include ::DatabaseCleaner::Redis::Base - include ::DatabaseCleaner::Generic::Truncation - - def clean - if @only - @only.each do |term| - connection.keys(term).each { |k| connection.del k } - end - elsif @tables_to_exclude - keys_except = [] - @tables_to_exclude.each { |term| keys_except += connection.keys(term) } - connection.keys.each { |k| connection.del(k) unless keys_except.include?(k) } - else - connection.flushdb - end - connection.quit unless url == :default - end - end - end -end diff --git a/adapters/database_cleaner-redis/lib/database_cleaner/redis/version.rb b/adapters/database_cleaner-redis/lib/database_cleaner/redis/version.rb deleted file mode 100644 index acfd5f84..00000000 --- a/adapters/database_cleaner-redis/lib/database_cleaner/redis/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DatabaseCleaner - module Redis - VERSION = "1.8.0" - end -end diff --git a/adapters/database_cleaner-redis/spec/database_cleaner/redis/base_spec.rb b/adapters/database_cleaner-redis/spec/database_cleaner/redis/base_spec.rb deleted file mode 100644 index c1ecb9c5..00000000 --- a/adapters/database_cleaner-redis/spec/database_cleaner/redis/base_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'redis' -require 'database_cleaner/redis/base' -require 'database_cleaner/spec' - -module DatabaseCleaner - RSpec.describe Redis do - it { is_expected.to respond_to(:available_strategies) } - - it "has a default_strategy of truncation" do - expect(described_class.default_strategy).to eq(:truncation) - end - end - - module Redis - class ExampleStrategy - include ::DatabaseCleaner::Redis::Base - end - - RSpec.describe ExampleStrategy do - - it_should_behave_like "a generic strategy" - it { is_expected.to respond_to(:db) } - it { is_expected.to respond_to(:db=) } - - context "when passing url" do - it "should store my describe db" do - url = 'redis://localhost:6379/2' - subject.db = 'redis://localhost:6379/2' - expect(subject.db).to eq url - end - end - - context "when passing connection" do - it "should store my describe db" do - connection = ::Redis.new :url => 'redis://localhost:6379/2' - subject.db = connection - expect(subject.db).to eq connection - end - end - - it "should default to :default" do - expect(subject.db).to eq :default - end - end - end -end diff --git a/adapters/database_cleaner-redis/spec/database_cleaner/redis/truncation_spec.rb b/adapters/database_cleaner-redis/spec/database_cleaner/redis/truncation_spec.rb deleted file mode 100644 index e3960c8c..00000000 --- a/adapters/database_cleaner-redis/spec/database_cleaner/redis/truncation_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'redis' -require 'database_cleaner/redis/truncation' -require 'yaml' - -RSpec.describe DatabaseCleaner::Redis::Truncation do - around do |example| - config = YAML::load(File.open("spec/support/redis.yml")) - @redis = ::Redis.new :url => config['test']['url'] - - example.run - - @redis.flushdb - end - - before do - @redis.set 'Widget', 1 - @redis.set 'Gadget', 1 - end - - context "by default" do - it "truncates all keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(2).to(0) - end - end - - context "when keys are provided to the :only option" do - subject { described_class.new(only: ['Widge*']) } - - it "only truncates the specified keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(2).to(1) - expect(@redis.get('Gadget')).to eq '1' - end - end - - context "when keys are provided to the :except option" do - subject { described_class.new(except: ['Widg*']) } - - it "truncates all but the specified keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(2).to(1) - expect(@redis.get('Widget')).to eq '1' - end - end -end - diff --git a/adapters/database_cleaner-redis/spec/spec_helper.rb b/adapters/database_cleaner-redis/spec/spec_helper.rb deleted file mode 100644 index 6ac3571a..00000000 --- a/adapters/database_cleaner-redis/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "bundler/setup" -require "database_cleaner/redis" - -RSpec.configure do |config| - # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" - - # Disable RSpec exposing methods globally on `Module` and `main` - config.disable_monkey_patching! - - config.expect_with :rspec do |c| - c.syntax = :expect - end -end diff --git a/adapters/database_cleaner-redis/spec/support/redis.yml b/adapters/database_cleaner-redis/spec/support/redis.yml deleted file mode 100644 index a3b6cba0..00000000 --- a/adapters/database_cleaner-redis/spec/support/redis.yml +++ /dev/null @@ -1,8 +0,0 @@ -test: - url: 'redis://localhost:6379/0' - -one: - url: 'redis://localhost:6379/1' - -two: - url: 'redis://localhost:6379/2' diff --git a/adapters/database_cleaner-sequel/.gitignore b/adapters/database_cleaner-sequel/.gitignore deleted file mode 100644 index a2164d5d..00000000 --- a/adapters/database_cleaner-sequel/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/spec/support/config.yml -/tmp/ -!/tmp/.keep - -# rspec failure tracking -.rspec_status diff --git a/adapters/database_cleaner-sequel/.rspec b/adapters/database_cleaner-sequel/.rspec deleted file mode 100644 index 34c5164d..00000000 --- a/adapters/database_cleaner-sequel/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/adapters/database_cleaner-sequel/.travis.yml b/adapters/database_cleaner-sequel/.travis.yml deleted file mode 100644 index 9912d68f..00000000 --- a/adapters/database_cleaner-sequel/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -rvm: - - 2.2.9 -before_install: gem install bundler -v 1.17.2 diff --git a/adapters/database_cleaner-sequel/Gemfile b/adapters/database_cleaner-sequel/Gemfile deleted file mode 100644 index c9ca10da..00000000 --- a/adapters/database_cleaner-sequel/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -# Specify your gem's dependencies in database_cleaner-sequel.gemspec -gemspec - -gem "database_cleaner", path: "../.." diff --git a/adapters/database_cleaner-sequel/Gemfile.lock b/adapters/database_cleaner-sequel/Gemfile.lock deleted file mode 100644 index fd2f4fac..00000000 --- a/adapters/database_cleaner-sequel/Gemfile.lock +++ /dev/null @@ -1,52 +0,0 @@ -PATH - remote: ../.. - specs: - database_cleaner (1.8.2) - -PATH - remote: . - specs: - database_cleaner-sequel (1.8.0) - database_cleaner (~> 1.8.0) - sequel - -GEM - remote: https://rubygems.org/ - specs: - diff-lcs (1.3) - mysql (2.9.1) - mysql2 (0.3.18) - pg (0.18.2) - rake (10.4.2) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - sequel (5.28.0) - sqlite3 (1.3.10) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.16) - database_cleaner! - database_cleaner-sequel! - mysql (~> 2.9.1) - mysql2 - pg - rake (~> 10.0) - rspec (~> 3.0) - sqlite3 - -BUNDLED WITH - 1.17.3 diff --git a/adapters/database_cleaner-sequel/LICENSE.txt b/adapters/database_cleaner-sequel/LICENSE.txt deleted file mode 100644 index 392bc0d3..00000000 --- a/adapters/database_cleaner-sequel/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2009 Ben Mabey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/adapters/database_cleaner-sequel/README.md b/adapters/database_cleaner-sequel/README.md deleted file mode 100644 index 3d2a5f28..00000000 --- a/adapters/database_cleaner-sequel/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# Database Cleaner Adapter for Sequel - -[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-sequel.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-sequel) -[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-sequel/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-sequel) - -Clean your Sequel databases with Database Cleaner. - -See https://github.com/DatabaseCleaner/database_cleaner for more information. - -## Installation - -```ruby -# Gemfile -group :test do - gem 'database_cleaner-sequel' -end -``` - -## Supported Strategies - -Here is an overview of the supported strategies: - - - - - - - - - - - - - - -
TruncationTransactionDeletion
Yes Yes Yes
- -(Default strategy is denoted in bold) - -## Configuration options - - - - - - - - - - - - - - -
ORMHow to accessNotes
Sequel DatabaseCleaner[:sequel] Multiple databases supported; specify DatabaseCleaner[:sequel, {:connection => Sequel.connect(uri)}]
- -## Common Errors - -### Nothing happens in JRuby with Sequel using transactions - -Due to an inconsistency in JRuby's implementation of Fibers, Sequel gives a different connection to `DatabaseCleaner.start` than is used for tests run between `.start` and `.clean`. This can be worked around by running your tests in a block like `DatabaseCleaner.cleaning { run_my_tests }` instead, which does not use Fibers. - -## COPYRIGHT - -See [LICENSE] for details. diff --git a/adapters/database_cleaner-sequel/Rakefile b/adapters/database_cleaner-sequel/Rakefile deleted file mode 100644 index b7e9ed54..00000000 --- a/adapters/database_cleaner-sequel/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/adapters/database_cleaner-sequel/bin/console b/adapters/database_cleaner-sequel/bin/console deleted file mode 100755 index 5dca81cf..00000000 --- a/adapters/database_cleaner-sequel/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "database_cleaner/sequel" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/adapters/database_cleaner-sequel/bin/setup b/adapters/database_cleaner-sequel/bin/setup deleted file mode 100755 index 268b1b43..00000000 --- a/adapters/database_cleaner-sequel/bin/setup +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle check || bundle install -cp spec/support/sample.config.yml spec/support/config.yml - diff --git a/adapters/database_cleaner-sequel/database_cleaner-sequel.gemspec b/adapters/database_cleaner-sequel/database_cleaner-sequel.gemspec deleted file mode 100644 index c4ba6fc4..00000000 --- a/adapters/database_cleaner-sequel/database_cleaner-sequel.gemspec +++ /dev/null @@ -1,35 +0,0 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/sequel/version" - -Gem::Specification.new do |spec| - spec.name = "database_cleaner-sequel" - spec.version = DatabaseCleaner::Sequel::VERSION - spec.authors = ["Ernesto Tagwerker"] - spec.email = ["ernesto@ombulabs.com"] - - spec.summary = "Strategies for cleaning databases using Sequel. Can be used to ensure a clean state for testing." - spec.description = "Strategies for cleaning databases using Sequel. Can be used to ensure a clean state for testing." - spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-sequel" - spec.license = "MIT" - - spec.add_dependency "database_cleaner", "~> 1.8.0" - spec.add_dependency "sequel" - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_development_dependency "bundler", "~> 1.16" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" - - spec.add_development_dependency 'mysql', '~> 2.9.1' - spec.add_development_dependency 'mysql2' - spec.add_development_dependency 'pg' - spec.add_development_dependency "sqlite3" -end diff --git a/adapters/database_cleaner-sequel/lib/database_cleaner-sequel.rb b/adapters/database_cleaner-sequel/lib/database_cleaner-sequel.rb deleted file mode 100644 index 4648ad69..00000000 --- a/adapters/database_cleaner-sequel/lib/database_cleaner-sequel.rb +++ /dev/null @@ -1 +0,0 @@ -require "database_cleaner/sequel" diff --git a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel.rb b/adapters/database_cleaner-sequel/lib/database_cleaner/sequel.rb deleted file mode 100644 index df26e45c..00000000 --- a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "database_cleaner/sequel/version" -require "database_cleaner" -require "database_cleaner/sequel/truncation" -require "database_cleaner/sequel/transaction" -require "database_cleaner/sequel/deletion" - diff --git a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/base.rb b/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/base.rb deleted file mode 100644 index 37a8d4a2..00000000 --- a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/base.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'database_cleaner/generic/base' -module DatabaseCleaner - module Sequel - def self.available_strategies - %w(truncation transaction deletion) - end - - def self.default_strategy - :transaction - end - - module Base - include ::DatabaseCleaner::Generic::Base - - def db=(desired_db) - @db = desired_db - end - - def db - return @db if @db && @db != :default - raise "As you have more than one active sequel database you have to specify the one to use manually!" if ::Sequel::DATABASES.count > 1 - ::Sequel::DATABASES.first || :default - end - end - end -end diff --git a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/deletion.rb b/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/deletion.rb deleted file mode 100644 index 58e240d7..00000000 --- a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/deletion.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'database_cleaner/sequel/base' -require 'database_cleaner/generic/truncation' -require 'database_cleaner/sequel/truncation' - -module DatabaseCleaner::Sequel - class Deletion < Truncation - def disable_referential_integrity(tables) - case db.database_type - when :postgres - db.run('SET CONSTRAINTS ALL DEFERRED') - tables_to_truncate(db).each do |table| - db.run("ALTER TABLE \"#{table}\" DISABLE TRIGGER ALL") - end - when :mysql - old = db.fetch('SELECT @@FOREIGN_KEY_CHECKS').first[:@@FOREIGN_KEY_CHECKS] - db.run('SET FOREIGN_KEY_CHECKS = 0') - end - yield - ensure - case db.database_type - when :postgres - tables.each do |table| - db.run("ALTER TABLE \"#{table}\" ENABLE TRIGGER ALL") - end - when :mysql - db.run("SET FOREIGN_KEY_CHECKS = #{old}") - end - end - - def delete_tables(db, tables) - tables.each do |table| - db[table.to_sym].delete - end - end - - def clean - return unless dirty? - - tables = tables_to_truncate(db) - db.transaction do - disable_referential_integrity(tables) do - delete_tables(db, tables) - end - end - end - end -end diff --git a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/transaction.rb b/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/transaction.rb deleted file mode 100644 index 03e1a6d5..00000000 --- a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/transaction.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'database_cleaner/sequel/base' -module DatabaseCleaner - module Sequel - class Transaction - include ::DatabaseCleaner::Sequel::Base - - def self.check_fiber_brokenness - if !@checked_fiber_brokenness && Fiber.new { Thread.current }.resume != Thread.current - raise RuntimeError, "This ruby engine's Fibers are not compatible with Sequel's connection pool. " + - "To work around this, please use DatabaseCleaner.cleaning with a block instead of " + - "DatabaseCleaner.start and DatabaseCleaner.clean" - end - @checked_fiber_brokenness = true - end - - def start - self.class.check_fiber_brokenness - - @fibers ||= [] - db = self.db - f = Fiber.new do - db.transaction(:rollback => :always, :savepoint => true) do - Fiber.yield - end - end - f.resume - @fibers << f - end - - def clean - f = @fibers.pop - f.resume - end - - def cleaning - self.db.transaction(:rollback => :always, :savepoint => true) { yield } - end - end - end -end diff --git a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/truncation.rb b/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/truncation.rb deleted file mode 100644 index 397be891..00000000 --- a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/truncation.rb +++ /dev/null @@ -1,79 +0,0 @@ -require 'database_cleaner/generic/truncation' -require 'database_cleaner/sequel/base' - -module DatabaseCleaner - module Sequel - class Truncation - include ::DatabaseCleaner::Sequel::Base - include ::DatabaseCleaner::Generic::Truncation - - def start - @last_txid = txid - end - - def clean - return unless dirty? - - tables = tables_to_truncate(db) - - # Count rows before truncating - if pre_count? - tables = pre_count_tables(tables) - end - - case db.database_type - when :postgres - # PostgreSQL requires all tables with FKs to be truncates in the same command, or have the CASCADE keyword - # appended. Bulk truncation without CASCADE is: - # * Safer. Tables outside of tables_to_truncate won't be affected. - # * Faster. Less roundtrips to the db. - unless tables.empty? - tables_sql = tables.map { |t| %("#{t}") }.join(',') - db.run "TRUNCATE TABLE #{tables_sql} RESTART IDENTITY;" - end - else - truncate_tables(db, tables) - end - end - - private - - def pre_count_tables tables - tables.reject { |table| db[table.to_sym].count == 0 } - end - - def truncate_tables(db, tables) - tables.each do |table| - db[table.to_sym].truncate - if db.database_type == :sqlite && db.table_exists?(:sqlite_sequence) - db[:sqlite_sequence].where(name: table).delete - end - end - end - - def dirty? - @last_txid != txid || @last_txid.nil? - end - - def txid - case db.database_type - when :postgres - db.fetch('SELECT txid_snapshot_xmax(txid_current_snapshot()) AS txid').first[:txid] - end - end - - def tables_to_truncate(db) - (@only || db.tables.map(&:to_s)) - @tables_to_exclude - end - - # overwritten - def migration_storage_names - %w(schema_info schema_migrations) - end - - def pre_count? - @pre_count == true - end - end - end -end diff --git a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/version.rb b/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/version.rb deleted file mode 100644 index a482d600..00000000 --- a/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DatabaseCleaner - module Sequel - VERSION = "1.8.0" - end -end diff --git a/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/base_spec.rb b/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/base_spec.rb deleted file mode 100644 index 10b46b31..00000000 --- a/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/base_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'database_cleaner/sequel/base' -require 'database_cleaner/spec' -require 'sequel' - -module DatabaseCleaner - RSpec.describe Sequel do - it { is_expected.to respond_to(:available_strategies) } - - it "has a default_strategy of transaction" do - expect(described_class.default_strategy).to eq(:transaction) - end - end - - module Sequel - class ExampleStrategy - include ::DatabaseCleaner::Sequel::Base - end - - RSpec.describe ExampleStrategy do - it_should_behave_like "a generic strategy" - it { is_expected.to respond_to(:db) } - it { is_expected.to respond_to(:db=) } - - it "should store my desired db" do - subject.db = :my_db - expect(subject.db).to eq :my_db - end - - pending "I figure out how to use Sequel and write some real tests for it..." - end - end -end diff --git a/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/deletion_spec.rb b/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/deletion_spec.rb deleted file mode 100644 index 289c86ef..00000000 --- a/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/deletion_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'database_cleaner/sequel/deletion' -require 'database_cleaner/spec' -require 'support/sequel_helper' - -module DatabaseCleaner - module Sequel - RSpec.describe Deletion do - it_should_behave_like "a generic strategy" - - SequelHelper.with_all_dbs do |helper| - context "using a #{helper.db} connection" do - around do |example| - helper.setup - example.run - helper.teardown - end - - let(:connection) { helper.connection } - - before { subject.db = connection } - - context 'when several tables have data' do - before do - connection[:users].insert - connection[:agents].insert - end - - context 'by default' do - it 'deletes all the tables' do - subject.clean - - expect(connection[:users]).to be_empty - expect(connection[:agents]).to be_empty - end - end - end - end - end - end - end -end diff --git a/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/transaction_spec.rb b/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/transaction_spec.rb deleted file mode 100644 index 3141d046..00000000 --- a/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/transaction_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'database_cleaner/sequel/transaction' -require 'database_cleaner/spec' -require 'support/sequel_helper' - -module DatabaseCleaner - module Sequel - RSpec.describe Transaction do - it_should_behave_like "a generic strategy" - it_should_behave_like "a generic transaction strategy" - - describe "start" do - it "should start a transaction" - end - - describe "clean" do - it "should finish a transaction" - end - end - end -end diff --git a/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/truncation_spec.rb b/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/truncation_spec.rb deleted file mode 100644 index 52166cb3..00000000 --- a/adapters/database_cleaner-sequel/spec/database_cleaner/sequel/truncation_spec.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'database_cleaner/sequel/truncation' -require 'database_cleaner/spec' -require 'support/sequel_helper' - -module DatabaseCleaner - module Sequel - RSpec.describe Truncation do - it_should_behave_like "a generic strategy" - it_should_behave_like "a generic truncation strategy" - - SequelHelper.with_all_dbs do |helper| - context "using a #{helper.db} connection" do - around do |example| - helper.setup - example.run - helper.teardown - end - - let(:connection) { helper.connection } - - before { subject.db = connection } - - context 'when several tables have data' do - before do - connection[:users].insert - connection[:agents].insert - end - - context 'by default' do - it 'truncates all the tables' do - subject.clean - - expect(connection[:users]).to be_empty - expect(connection[:agents]).to be_empty - end - end - - context 'restricted to "only: [...]" some tables' do - subject { described_class.new(only: ['users']) } - - it 'truncates only the mentioned tables (and leaves the rest alone)' do - subject.clean - - expect(connection[:users]).to be_empty - expect(connection[:agents].count).to eq(1) - end - end - - context 'restricted to "except: [...]" some tables' do - subject { described_class.new(except: ['users']) } # XXX: Strings only, symbols are ignored - - it 'leaves the mentioned tables alone (and truncates the rest)' do - subject.clean - - expect(connection[:users].count).to eq(1) - expect(connection[:agents]).to be_empty - end - end - end - - describe 'auto increment sequences' do - it "resets AUTO_INCREMENT primary key seqeunce" do - table = connection[:users] - 2.times { table.insert } - - subject.clean - - id_after_clean = table.insert - expect(id_after_clean).to eq 1 - end - end - - describe "with pre_count optimization option" do - subject { described_class.new(pre_count: true) } - - before { connection[:users].insert } - - it "only truncates non-empty tables" do - sql = case helper.db - when :sqlite3 then ["DELETE FROM `users`", anything] - when :postgres then ['TRUNCATE TABLE "users" RESTART IDENTITY;', anything] - else ["TRUNCATE TABLE `users`", anything] - end - expect(subject.db).to receive(:execute_ddl).once.with(*sql) - subject.clean - end - end - end - end - end - end -end diff --git a/adapters/database_cleaner-sequel/spec/spec_helper.rb b/adapters/database_cleaner-sequel/spec/spec_helper.rb deleted file mode 100644 index 57b06b57..00000000 --- a/adapters/database_cleaner-sequel/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "bundler/setup" -require "database_cleaner/sequel" - -RSpec.configure do |config| - # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" - - # Disable RSpec exposing methods globally on `Module` and `main` - config.disable_monkey_patching! - - config.expect_with :rspec do |c| - c.syntax = :expect - end -end diff --git a/adapters/database_cleaner-sequel/spec/support/sample.config.yml b/adapters/database_cleaner-sequel/spec/support/sample.config.yml deleted file mode 100644 index 90132c0d..00000000 --- a/adapters/database_cleaner-sequel/spec/support/sample.config.yml +++ /dev/null @@ -1,34 +0,0 @@ -mysql: - adapter: mysql - database: database_cleaner_test - username: root - password: - host: 127.0.0.1 - port: 3306 - encoding: utf8 - -mysql2: - adapter: mysql2 - database: database_cleaner_test - username: root - password: - host: 127.0.0.1 - port: 3306 - encoding: utf8 - -postgres: - adapter: postgresql - database: database_cleaner_test - username: postgres - password: - host: 127.0.0.1 - encoding: unicode - template: template0 - -sqlite3: - adapter: sqlite3 - database: tmp/database_cleaner_test.sqlite3 - pool: 5 - timeout: 5000 - encoding: utf8 - diff --git a/adapters/database_cleaner-sequel/spec/support/sequel_helper.rb b/adapters/database_cleaner-sequel/spec/support/sequel_helper.rb deleted file mode 100644 index d62020f1..00000000 --- a/adapters/database_cleaner-sequel/spec/support/sequel_helper.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'sequel' -require 'database_cleaner/spec/database_helper' - -class SequelHelper < DatabaseCleaner::Spec::DatabaseHelper - private - - def establish_connection(config = default_config) - url = "#{db}:///" - url = "sqlite:///" if db == :sqlite3 - @connection = ::Sequel.connect(url, config) - end -end diff --git a/adapters/database_cleaner-sequel/tmp/.keep b/adapters/database_cleaner-sequel/tmp/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/bin/setup b/bin/setup index d852b976..268b1b43 100755 --- a/bin/setup +++ b/bin/setup @@ -6,7 +6,3 @@ set -vx bundle check || bundle install cp spec/support/sample.config.yml spec/support/config.yml -for adapter in adapters/*; do - (cd $adapter && bin/setup) -done - diff --git a/spec/database_cleaner/active_record/base_spec.rb b/spec/database_cleaner/active_record/base_spec.rb deleted file mode 100644 index 48f2eb34..00000000 --- a/spec/database_cleaner/active_record/base_spec.rb +++ /dev/null @@ -1,166 +0,0 @@ -require 'active_record' -require 'database_cleaner/active_record/base' -require 'database_cleaner/spec' - -class FakeModel - def self.connection - :fake_connection - end -end - -RSpec.describe DatabaseCleaner::ActiveRecord do - it { is_expected.to respond_to(:available_strategies) } - - describe "config_file_location" do - after do - # prevent global state leakage - DatabaseCleaner::ActiveRecord.config_file_location=nil - DatabaseCleaner.app_root = nil - end - - it "should default to \#{DatabaseCleaner.app_root}/config/database.yml" do - DatabaseCleaner::ActiveRecord.config_file_location = nil - DatabaseCleaner.app_root = "/path/to" - expect(DatabaseCleaner::ActiveRecord.config_file_location).to eq '/path/to/config/database.yml' - end - end -end - -module DatabaseCleaner - module ActiveRecord - class ExampleStrategy - include DatabaseCleaner::ActiveRecord::Base - end - - RSpec.describe ExampleStrategy do - let(:config_location) { '/path/to/config/database.yml' } - - around do |example| - DatabaseCleaner::ActiveRecord.config_file_location = config_location - example.run - DatabaseCleaner::ActiveRecord.config_file_location = nil - end - - it_should_behave_like "a generic strategy" - - describe "db" do - it "should store my desired db" do - subject.db = :my_db - expect(subject.db).to eq :my_db - end - - it "should default to :default" do - expect(subject.db).to eq :default - end - end - - describe "db=" do - let(:config_location) { "spec/support/example.database.yml" } - - it "should process erb in the config" do - subject.db = :my_db - expect(subject.connection_hash).to eq({ "database" => "one" }) - end - - context 'when config file differs from established ActiveRecord configuration' do - before do - allow(::ActiveRecord::Base).to receive(:configurations).and_return({ "my_db" => { "database" => "two"} }) - end - - it 'uses the ActiveRecord configuration' do - subject.db = :my_db - expect(subject.connection_hash).to eq({ "database" => "two"}) - end - end - - context 'when config file agrees with ActiveRecord configuration' do - before do - allow(::ActiveRecord::Base).to receive(:configurations).and_return({ "my_db" => { "database" => "one"} }) - end - - it 'uses the config file' do - subject.db = :my_db - expect(subject.connection_hash).to eq({ "database" => "one"}) - end - end - - context 'when ::ActiveRecord::Base.configurations nil' do - before do - allow(::ActiveRecord::Base).to receive(:configurations).and_return(nil) - end - - it 'uses the config file' do - subject.db = :my_db - expect(subject.connection_hash).to eq({ "database" => "one"}) - end - end - - context 'when ::ActiveRecord::Base.configurations empty' do - before do - allow(::ActiveRecord::Base).to receive(:configurations).and_return({}) - end - - it 'uses the config file' do - subject.db = :my_db - expect(subject.connection_hash).to eq({ "database" => "one"}) - end - end - - context 'when config file is not available' do - before do - allow(File).to receive(:file?).with(config_location).and_return(false) - end - - it "should skip config" do - subject.db = :my_db - expect(subject.connection_hash).not_to be - end - end - - it "skips the file when the model is set" do - subject.db = FakeModel - expect(subject.connection_hash).not_to be - end - - it "skips the file when the db is set to :default" do - # to avoid https://github.com/bmabey/database_cleaner/issues/72 - subject.db = :default - expect(subject.connection_hash).not_to be - end - end - - describe "connection_class" do - it "should default to ActiveRecord::Base" do - expect(subject.connection_class).to eq ::ActiveRecord::Base - end - - context "with database models" do - context "connection_hash is set" do - it "reuses the model's connection" do - subject.connection_hash = {} - subject.db = FakeModel - expect(subject.connection_class).to eq FakeModel - end - end - - context "connection_hash is not set" do - it "reuses the model's connection" do - subject.db = FakeModel - expect(subject.connection_class).to eq FakeModel - end - end - end - - context "when connection_hash is set" do - let(:hash) { {} } - before { subject.connection_hash = hash } - - it "establishes a connection with it" do - expect(::ActiveRecord::Base).to receive(:establish_connection).with(hash) - expect(subject.connection_class).to eq ::ActiveRecord::Base - end - end - end - end - end -end diff --git a/spec/database_cleaner/active_record/transaction_spec.rb b/spec/database_cleaner/active_record/transaction_spec.rb deleted file mode 100644 index c6fbdb10..00000000 --- a/spec/database_cleaner/active_record/transaction_spec.rb +++ /dev/null @@ -1,155 +0,0 @@ -require 'database_cleaner/active_record/transaction' -require 'active_record' - -module DatabaseCleaner - module ActiveRecord - - RSpec.describe Transaction do - let(:connection) { double("connection") } - let(:connection_2) { double("connection_2") } - let(:connection_pool) { double("connection_pool") } - - before do - allow(::ActiveRecord::Base).to receive(:connection_pool).and_return(connection_pool) - allow(connection_pool).to receive(:connections).and_return([connection]) - allow(::ActiveRecord::Base).to receive(:connection).and_return(connection) - end - - describe "#start" do - [:begin_transaction, :begin_db_transaction].each do |begin_transaction_method| - context "using #{begin_transaction_method}" do - before do - allow(connection).to receive(:transaction) - allow(connection).to receive(begin_transaction_method) - end - - it "should increment open transactions if possible" do - expect(connection).to receive(:increment_open_transactions) - subject.start - end - - it "should tell ActiveRecord to increment connection if its not possible to increment current connection" do - expect(::ActiveRecord::Base).to receive(:increment_open_transactions) - subject.start - end - - it "should start a transaction" do - allow(connection).to receive(:increment_open_transactions) - expect(connection).to receive(begin_transaction_method) - expect(connection).to receive(:transaction) - subject.start - end - end - end - end - - describe "#clean" do - context "manual accounting of transaction count" do - it "should start a transaction" do - expect(connection).to receive(:open_transactions).and_return(1) - - allow(connection).to receive(:decrement_open_transactions) - - expect(connection).to receive(:rollback_db_transaction) - subject.clean - end - - it "should decrement open transactions if possible" do - expect(connection).to receive(:open_transactions).and_return(1) - - allow(connection).to receive(:rollback_db_transaction) - - expect(connection).to receive(:decrement_open_transactions) - subject.clean - end - - it "should not try to decrement or rollback if open_transactions is 0 for whatever reason" do - expect(connection).to receive(:open_transactions).and_return(0) - - subject.clean - end - - it "should decrement connection via ActiveRecord::Base if connection won't" do - expect(connection).to receive(:open_transactions).and_return(1) - allow(connection).to receive(:rollback_db_transaction) - - expect(::ActiveRecord::Base).to receive(:decrement_open_transactions) - subject.clean - end - - it "should rollback open transactions in all connections" do - allow(connection_pool).to receive(:connections).and_return([connection, connection_2]) - - expect(connection).to receive(:open_transactions).and_return(1) - allow(connection).to receive(:rollback_db_transaction) - - expect(connection_2).to receive(:open_transactions).and_return(1) - allow(connection_2).to receive(:rollback_db_transaction) - - expect(::ActiveRecord::Base).to receive(:decrement_open_transactions).twice - subject.clean - end - - it "should rollback open transactions in all connections with an open transaction" do - allow(connection_pool).to receive(:connections).and_return([connection, connection_2]) - - expect(connection).to receive(:open_transactions).and_return(1) - allow(connection).to receive(:rollback_db_transaction) - - expect(connection_2).to receive(:open_transactions).and_return(0) - - expect(::ActiveRecord::Base).to receive(:decrement_open_transactions).exactly(1).times - subject.clean - end - end - - context "automatic accounting of transaction count (AR 4)" do - before { stub_const("ActiveRecord::VERSION::MAJOR", 4) } - - it "should start a transaction" do - allow(connection).to receive(:rollback_db_transaction) - expect(connection).to receive(:open_transactions).and_return(1) - - expect(connection).not_to receive(:decrement_open_transactions) - expect(connection).to receive(:rollback_transaction) - subject.clean - end - - it "should decrement open transactions if possible" do - allow(connection).to receive(:rollback_transaction) - expect(connection).to receive(:open_transactions).and_return(1) - - expect(connection).not_to receive(:decrement_open_transactions) - subject.clean - end - - it "should not try to decrement or rollback if open_transactions is 0 for whatever reason" do - expect(connection).to receive(:open_transactions).and_return(0) - - subject.clean - end - - it "should decrement connection via ActiveRecord::Base if connection won't" do - expect(connection).to receive(:open_transactions).and_return(1) - allow(connection).to receive(:rollback_transaction) - - expect(::ActiveRecord::Base).not_to receive(:decrement_open_transactions) - subject.clean - end - end - end - - describe "#connection_maintains_transaction_count?" do - it "should return true if the major active record version is < 4" do - stub_const("ActiveRecord::VERSION::MAJOR", 3) - expect(subject.connection_maintains_transaction_count?).to be_truthy - end - - it "should return false if the major active record version is > 3" do - stub_const("ActiveRecord::VERSION::MAJOR", 4) - expect(subject.connection_maintains_transaction_count?).to be_falsey - end - end - end - end -end diff --git a/spec/database_cleaner/active_record/truncation_spec.rb b/spec/database_cleaner/active_record/truncation_spec.rb deleted file mode 100644 index fff56b53..00000000 --- a/spec/database_cleaner/active_record/truncation_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'support/active_record_helper' -require 'database_cleaner/active_record/truncation' - -RSpec.describe DatabaseCleaner::ActiveRecord::Truncation do - ActiveRecordHelper.with_all_dbs do |helper| - context "using a #{helper.db} connection" do - around do |example| - helper.setup - example.run - helper.teardown - end - - let(:connection) { helper.connection } - - before do - allow(connection).to receive(:disable_referential_integrity).and_yield - allow(connection).to receive(:database_cleaner_view_cache).and_return([]) - end - - describe '#clean' do - context "with records" do - before do - 2.times { User.create! } - 2.times { Agent.create! } - end - - it "should truncate all tables" do - expect { subject.clean } - .to change { [User.count, Agent.count] } - .from([2,2]) - .to([0,0]) - end - - it "should reset AUTO_INCREMENT index of table" do - subject.clean - expect(User.create.id).to eq 1 - end - - xit "should not reset AUTO_INCREMENT index of table if :reset_ids is false" do - described_class.new(reset_ids: false).clean - expect(User.create.id).to eq 3 - end - - it "should truncate all tables except for schema_migrations" do - subject.clean - count = connection.select_value("select count(*) from schema_migrations;").to_i - expect(count).to eq 2 - end - - it "should only truncate the tables specified in the :only option when provided" do - expect { described_class.new(only: ['agents']).clean } - .to change { [User.count, Agent.count] } - .from([2,2]) - .to([2,0]) - end - - it "should not truncate the tables specified in the :except option" do - expect { described_class.new(except: ['users']).clean } - .to change { [User.count, Agent.count] } - .from([2,2]) - .to([2,0]) - end - - it "should raise an error when :only and :except options are used" do - expect { - described_class.new(except: ['widgets'], only: ['widgets']) - }.to raise_error(ArgumentError) - end - - it "should raise an error when invalid options are provided" do - expect { described_class.new(foo: 'bar') }.to raise_error(ArgumentError) - end - - it "should not truncate views" do - allow(connection).to receive(:database_cleaner_table_cache).and_return(%w[widgets dogs]) - allow(connection).to receive(:database_cleaner_view_cache).and_return(["widgets"]) - - expect(connection).to receive(:truncate_tables).with(['dogs']) - - subject.clean - end - end - - describe "with pre_count optimization option" do - subject { described_class.new(pre_count: true) } - - it "only truncates non-empty tables" do - pending if helper.db == :sqlite3 - pending if helper.db == :postgres - - User.create! - - expect(connection).to receive(:truncate_tables).with(['users']) - subject.clean - end - end - - context 'when :cache_tables is set to true' do - it 'caches the list of tables to be truncated' do - expect(connection).to receive(:database_cleaner_table_cache).and_return([]) - expect(connection).not_to receive(:tables) - - allow(connection).to receive(:truncate_tables) - described_class.new(cache_tables: true).clean - end - end - - context 'when :cache_tables is set to false' do - it 'does not cache the list of tables to be truncated' do - expect(connection).not_to receive(:database_cleaner_table_cache) - expect(connection).to receive(:tables).and_return([]) - - allow(connection).to receive(:truncate_tables) - described_class.new(cache_tables: false).clean - end - end - end - end - end -end diff --git a/spec/database_cleaner/couch_potato/truncation_spec.rb b/spec/database_cleaner/couch_potato/truncation_spec.rb deleted file mode 100644 index 8f4360a4..00000000 --- a/spec/database_cleaner/couch_potato/truncation_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'database_cleaner/couch_potato/truncation' -require 'couch_potato' - -module DatabaseCleaner - module CouchPotato - - RSpec.describe Truncation do - let(:database) { double('database') } - - before(:each) do - allow(::CouchPotato).to receive(:couchrest_database).and_return(database) - end - - it "should re-create the database" do - expect(database).to receive(:recreate!) - - Truncation.new.clean - end - - it "should raise an error when the :only option is used" do - expect { - Truncation.new(:only => ['document-type']) - }.to raise_error(ArgumentError) - end - - it "should raise an error when the :except option is used" do - expect { - Truncation.new(:except => ['document-type']) - }.to raise_error(ArgumentError) - end - - it "should raise an error when invalid options are provided" do - expect { - Truncation.new(:foo => 'bar') - }.to raise_error(ArgumentError) - end - end - - end -end diff --git a/spec/database_cleaner/data_mapper/base_spec.rb b/spec/database_cleaner/data_mapper/base_spec.rb deleted file mode 100644 index 9996763a..00000000 --- a/spec/database_cleaner/data_mapper/base_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'database_cleaner/data_mapper/base' -require 'database_cleaner/spec' - -module DatabaseCleaner - RSpec.describe DataMapper do - it { is_expected.to respond_to(:available_strategies) } - end - - module DataMapper - class ExampleStrategy - include ::DatabaseCleaner::DataMapper::Base - end - - RSpec.describe ExampleStrategy do - it_should_behave_like "a generic strategy" - it { is_expected.to respond_to(:db) } - it { is_expected.to respond_to(:db=) } - - it "should store my desired db" do - subject.db = :my_db - expect(subject.db).to eq :my_db - end - - it "should default to :default" do - expect(subject.db).to eq :default - end - end - end -end diff --git a/spec/database_cleaner/data_mapper/transaction_spec.rb b/spec/database_cleaner/data_mapper/transaction_spec.rb deleted file mode 100644 index 61e04318..00000000 --- a/spec/database_cleaner/data_mapper/transaction_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'database_cleaner/data_mapper/transaction' -require 'database_cleaner/spec' -#require 'data_mapper' - -module DatabaseCleaner - module DataMapper - - RSpec.describe Transaction do - it_should_behave_like "a generic strategy" - it_should_behave_like "a generic transaction strategy" - - describe "start" do - it "should start a transaction" - end - - describe "clean" do - it "should finish a transaction" - end - end - - end -end diff --git a/spec/database_cleaner/data_mapper/truncation/sqlite3_spec.rb b/spec/database_cleaner/data_mapper/truncation/sqlite3_spec.rb deleted file mode 100644 index 3a25d1ba..00000000 --- a/spec/database_cleaner/data_mapper/truncation/sqlite3_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'support/data_mapper_helper' -require 'database_cleaner/data_mapper/truncation' - -RSpec.describe DatabaseCleaner::DataMapper::Truncation do - let(:helper) { DataMapperHelper.new(:sqlite3) } - - let(:connection) { helper.connection } - - around do |example| - helper.setup - example.run - helper.teardown - end - - describe "DM connection adapter monkeypatches" do - before { 2.times { User.create } } - - describe "#truncate_table" do - it "truncates the table and resets AUTO_INCREMENT index of table" do - connection.truncate_table(User.storage_names[:default]) - expect(User.count).to eq 0 - expect(User.create.id).to eq 1 - end - end - end -end diff --git a/spec/database_cleaner/data_mapper/truncation_spec.rb b/spec/database_cleaner/data_mapper/truncation_spec.rb deleted file mode 100644 index b879b901..00000000 --- a/spec/database_cleaner/data_mapper/truncation_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'database_cleaner/data_mapper/truncation' -require 'database_cleaner/spec' - -module DatabaseCleaner - module DataMapper - RSpec.describe Truncation do - it_should_behave_like "a generic strategy" - it_should_behave_like "a generic truncation strategy" - end - end -end diff --git a/spec/database_cleaner/generic/base_spec.rb b/spec/database_cleaner/generic/base_spec.rb deleted file mode 100644 index 4f9674d4..00000000 --- a/spec/database_cleaner/generic/base_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'database_cleaner/spec' -require 'database_cleaner/generic/base' -require 'active_record' - -module ::DatabaseCleaner - module Generic - class ExampleStrategy - include ::DatabaseCleaner::Generic::Base - - def start; end - end - - RSpec.describe ExampleStrategy do - context "class methods" do - subject { ExampleStrategy } - - describe "#available_strategies" do - it "should have available strategies" do - expect(subject.available_strategies).to be_empty - end - end - end - - it_should_behave_like "a generic strategy" - - describe "#db" do - it "should be :default" do - expect(subject.db).to eql(:default) - end - end - - describe "#cleaning" do - let (:connection) { double("connection") } - let (:strategy) { ExampleStrategy.new } - before do - # DatabaseCleaner.strategy = :truncation - allow(connection).to receive(:disable_referential_integrity).and_yield - allow(connection).to receive(:database_cleaner_view_cache).and_return([]) - allow(connection).to receive(:database_cleaner_table_cache).and_return([]) - allow(::ActiveRecord::Base).to receive(:connection).and_return(connection) - end - - it "calls #clean even if there is an exception" do - expect(strategy).to receive :clean - expect do - strategy.cleaning do - raise NoMethodError - end - end.to raise_exception(NoMethodError) - end - - it "calls #clean after processing the block" do - expect(strategy).to receive :clean - strategy.cleaning {} - end - end - end - end -end diff --git a/spec/database_cleaner/generic/truncation_spec.rb b/spec/database_cleaner/generic/truncation_spec.rb deleted file mode 100644 index e28d1cd7..00000000 --- a/spec/database_cleaner/generic/truncation_spec.rb +++ /dev/null @@ -1,129 +0,0 @@ -require 'database_cleaner/generic/truncation' - -module ::DatabaseCleaner - module Generic - class TruncationExample - include ::DatabaseCleaner::Generic::Truncation - - def only - @only - end - - def except - @tables_to_exclude - end - - def reset_ids? - !!@reset_ids - end - - def pre_count? - !!@pre_count - end - end - - class TruncationExampleWithMigrations < TruncationExample - def migration_storage_names - %w[migration_storage_name] - end - end - - RSpec.describe TruncationExample do - it "will start" do - expect { subject.start }.to_not raise_error - end - - it "expects clean to be implemented later" do - expect { subject.clean }.to raise_error(NotImplementedError) - end - - context "private methods" do - it { is_expected.not_to respond_to(:tables_to_truncate) } - - it 'expects #tables_to_truncate to be implemented later' do - expect{ subject.send :tables_to_truncate }.to raise_error(NotImplementedError) - end - - it { is_expected.not_to respond_to(:migration_storage_names) } - end - - describe "initialize" do - it "should accept no options" do - described_class.new - end - - it "should accept a hash of options" do - described_class.new({}) - end - - describe ":only option" do - it "defaults to nil" do - expect(subject.only).to be_nil - end - - it "can be set to specify tables to clean" do - subject = described_class.new(only: ["something"]) - expect(subject.only).to eq ["something"] - end - end - - describe ":except option" do - it "defaults to empty array" do - expect(subject.except).to eq [] - end - - it "can be set to specify tables to skip" do - subject = described_class.new(except: ["something"]) - expect(subject.except).to eq ["something"] - end - end - - describe ":pre_count option" do - it "defaults to false" do - expect(subject.pre_count?).to eq false - end - - it "can be set" do - subject = described_class.new(pre_count: "something") - expect(subject.pre_count?).to eq true - end - end - - describe ":reset_ids option" do - it "defaults to false" do - expect(subject.reset_ids?).to eq false - end - - it "can be set" do - subject = described_class.new(reset_ids: "something") - expect(subject.reset_ids?).to eq true - end - end - - it "should raise an error when invalid options are provided" do - expect { - described_class.new(a_random_param: "should raise ArgumentError") - }.to raise_error(ArgumentError) - end - - it "should raise an error when :only and :except options are used" do - expect { - described_class.new(except: "something", only: "something else") - }.to raise_error(ArgumentError) - end - - describe TruncationExampleWithMigrations do - it { expect(subject.only).to eq nil } - it { expect(subject.except).to eq %w[migration_storage_name] } - - it "should not mutate the array of excepted tables" do - except_tables = ["something"] - subject = described_class.new(except: except_tables) - expect(subject.except).to eq ["something", "migration_storage_name"] - expect(except_tables).to eq ["something"] - end - end - end - end - end -end diff --git a/spec/database_cleaner/mongo/mongo_examples.rb b/spec/database_cleaner/mongo/mongo_examples.rb deleted file mode 100644 index 03602948..00000000 --- a/spec/database_cleaner/mongo/mongo_examples.rb +++ /dev/null @@ -1,26 +0,0 @@ -module MongoTest - class Base - def self.collection - @connection ||= Mongo::Connection.new('127.0.0.1') - @db ||= @connection.db('database_cleaner_specs') - @collection ||= @db.collection(name) || @db.create_collection(name) - end - - def self.count - @collection.count - end - - def initialize(attrs={}) - @attrs = attrs - end - - def save! - self.class.collection.insert(@attrs) - end - end - - class Widget < Base - end - class Gadget < Base - end -end diff --git a/spec/database_cleaner/mongo/truncation_spec.rb b/spec/database_cleaner/mongo/truncation_spec.rb deleted file mode 100644 index 9cf1dffd..00000000 --- a/spec/database_cleaner/mongo/truncation_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'mongo' -require 'database_cleaner/mongo/truncation' -require File.dirname(__FILE__) + '/mongo_examples' - -RSpec.describe DatabaseCleaner::Mongo::Truncation do - around do |example| - connection = Mongo::Connection.new('127.0.0.1') - db_name = 'database_cleaner_specs' - db = connection.db(db_name) - subject.db = db - - example.run - - connection.drop_database(db_name) - end - - before do - MongoTest::Widget.new(name: 'some widget').save! - MongoTest::Gadget.new(name: 'some gadget').save! - end - - context "by default" do - it "truncates all collections" do - expect { subject.clean }.to change { - [MongoTest::Widget.count, MongoTest::Gadget.count] - }.from([1,1]).to([0,0]) - end - end - - context "when collections are provided to the :only option" do - subject { described_class.new(only: ['MongoTest::Widget']) } - - it "only truncates the specified collections" do - expect { subject.clean }.to change { - [MongoTest::Widget.count, MongoTest::Gadget.count] - }.from([1,1]).to([0,1]) - end - end - - context "when collections are provided to the :except option" do - subject { described_class.new(except: ['MongoTest::Widget']) } - - it "truncates all but the specified collections" do - expect { subject.clean }.to change { - [MongoTest::Widget.count, MongoTest::Gadget.count] - }.from([1,1]).to([1,0]) - end - end -end - diff --git a/spec/database_cleaner/mongo_mapper/base_spec.rb b/spec/database_cleaner/mongo_mapper/base_spec.rb deleted file mode 100644 index e45f3451..00000000 --- a/spec/database_cleaner/mongo_mapper/base_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'database_cleaner/mongo_mapper/base' -require 'database_cleaner/spec' - -module DatabaseCleaner - RSpec.describe MongoMapper do - it { is_expected.to respond_to(:available_strategies) } - end - - module MongoMapper - class ExampleStrategy - include ::DatabaseCleaner::MongoMapper::Base - end - - RSpec.describe ExampleStrategy do - - it_should_behave_like "a generic strategy" - - describe "db" do - it { is_expected.to respond_to(:db=) } - - it "should store my desired db" do - subject.db = :my_db - expect(subject.db).to eq :my_db - end - - it "should default to :default" do - expect(subject.db).to eq :default - end - end - end - end -end diff --git a/spec/database_cleaner/mongo_mapper/mongo_examples.rb b/spec/database_cleaner/mongo_mapper/mongo_examples.rb deleted file mode 100644 index f0b8a731..00000000 --- a/spec/database_cleaner/mongo_mapper/mongo_examples.rb +++ /dev/null @@ -1,10 +0,0 @@ -module MongoMapperTest - class Widget - include ::MongoMapper::Document - key :name, String - end - class Gadget - include ::MongoMapper::Document - key :name, String - end -end diff --git a/spec/database_cleaner/mongo_mapper/truncation_spec.rb b/spec/database_cleaner/mongo_mapper/truncation_spec.rb deleted file mode 100644 index ce0a3f6d..00000000 --- a/spec/database_cleaner/mongo_mapper/truncation_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'mongo_mapper' -require 'database_cleaner/mongo_mapper/truncation' -require File.dirname(__FILE__) + '/mongo_examples' - -RSpec.describe DatabaseCleaner::MongoMapper::Truncation do - around do |example| - MongoMapper.connection = Mongo::Connection.new('127.0.0.1') - db_name = 'database_cleaner_specs' - MongoMapper.database = db_name - - example.run - - MongoMapper.connection.drop_database(db_name) - end - - before do - MongoMapperTest::Widget.new(name: 'some widget').save! - MongoMapperTest::Gadget.new(name: 'some gadget').save! - end - - context "by default" do - it "truncates all collections" do - expect { subject.clean }.to change { - [MongoMapperTest::Widget.count, MongoMapperTest::Gadget.count] - }.from([1,1]).to([0,0]) - end - end - - context "when collections are provided to the :only option" do - subject { described_class.new(only: ['mongo_mapper_test.widgets']) } - - it "only truncates the specified collections" do - expect { subject.clean }.to change { - [MongoMapperTest::Widget.count, MongoMapperTest::Gadget.count] - }.from([1,1]).to([0,1]) - end - end - - context "when collections are provided to the :except option" do - subject { described_class.new(except: ['mongo_mapper_test.widgets']) } - - it "truncates all but the specified collections" do - expect { subject.clean }.to change { - [MongoMapperTest::Widget.count, MongoMapperTest::Gadget.count] - }.from([1,1]).to([1,0]) - end - end -end - diff --git a/spec/database_cleaner/moped/moped_examples.rb b/spec/database_cleaner/moped/moped_examples.rb deleted file mode 100644 index a1448504..00000000 --- a/spec/database_cleaner/moped/moped_examples.rb +++ /dev/null @@ -1,32 +0,0 @@ -module MopedTest - class Base - def self.collection - @db ||= 'database_cleaner_specs' - @session ||= ::Moped::Session.new(['127.0.0.1:27017'], database: @db) - @collection ||= @session[name] - end - - def self.count - @collection.find.count - end - - def initialize(attrs={}) - @attrs = attrs - end - - def save! - self.class.collection.insert(@attrs) - end - end - - class Widget < Base - end - class Gadget < Base - end - class System < Base - def self.collection - super - @collection = @session['system_logs'] - end - end -end diff --git a/spec/database_cleaner/moped/truncation_spec.rb b/spec/database_cleaner/moped/truncation_spec.rb deleted file mode 100644 index 758dcff5..00000000 --- a/spec/database_cleaner/moped/truncation_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'moped' -require 'database_cleaner/moped/truncation' -require File.dirname(__FILE__) + '/moped_examples' - -RSpec.describe DatabaseCleaner::Moped::Truncation do - around do |example| - db_name = 'database_cleaner_specs' - session = ::Moped::Session.new(['127.0.0.1:27017'], database: db_name) - subject.db = db_name - - example.run - - session.drop - session.command(getlasterror: 1) - end - - before do - MopedTest::Widget.new(name: 'some widget').save! - MopedTest::Gadget.new(name: 'some gadget').save! - MopedTest::System.new(name: 'some system').save! - end - - context "by default" do - it "truncates all collections" do - expect { subject.clean }.to change { - [MopedTest::Widget.count, MopedTest::Gadget.count, MopedTest::System.count] - }.from([1,1,1]).to([0,0,0]) - end - end - - context "when collections are provided to the :only option" do - subject { described_class.new(only: ['MopedTest::Widget']) } - - it "only truncates the specified collections" do - expect { subject.clean }.to change { - [MopedTest::Widget.count, MopedTest::Gadget.count, MopedTest::System.count] - }.from([1,1,1]).to([0,1,1]) - end - end - - context "when collections are provided to the :except option" do - subject { described_class.new(except: ['MopedTest::Widget']) } - - it "truncates all but the specified collections" do - expect { subject.clean }.to change { - [MopedTest::Widget.count, MopedTest::Gadget.count, MopedTest::System.count] - }.from([1,1,1]).to([1,0,0]) - end - end -end - diff --git a/spec/database_cleaner/neo4j/base_spec.rb b/spec/database_cleaner/neo4j/base_spec.rb deleted file mode 100644 index e0a1605d..00000000 --- a/spec/database_cleaner/neo4j/base_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'database_cleaner/neo4j/base' -require 'database_cleaner/spec' - -module DatabaseCleaner - RSpec.describe Neo4j do - it { is_expected.to respond_to(:available_strategies) } - end - - module Neo4j - class ExampleStrategy - include ::DatabaseCleaner::Neo4j::Base - end - - RSpec.describe ExampleStrategy do - - it_should_behave_like "a generic strategy" - it { is_expected.to respond_to(:db) } - it { is_expected.to respond_to(:db=) } - - it "should store my describe db" do - db_conf = {:connection => {:type => :server_db, :path => 'http://localhost:7474'}} - subject.db = db_conf - expect(subject.db).to eq db_conf - end - - it "should respect additional connection parameters" do - db_conf = {:type => :server_db, :path => 'http://localhost:7474', basic_auth: {username: 'user', password: 'pass'}} - subject.db = db_conf - expect(stub_const("Neo4j::Session", double())).to receive(:open).with(:server_db, 'http://localhost:7474', {basic_auth: {username: 'user', password: 'pass'}}) { true } - subject.start - end - - it "should default to nil" do - expect(subject.db).to be_nil - end - - it "should return default configuration" do - expect(subject.database).to eq(:type => :server_db, :path => 'http://localhost:7475/') - end - end - end -end diff --git a/spec/database_cleaner/neo4j/transaction_spec.rb b/spec/database_cleaner/neo4j/transaction_spec.rb deleted file mode 100644 index 1a130a9f..00000000 --- a/spec/database_cleaner/neo4j/transaction_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'neo4j-core' -require 'database_cleaner/neo4j/transaction' -require 'database_cleaner/spec' - -module DatabaseCleaner - module Neo4j - - RSpec.describe Transaction do - before(:all) do - DatabaseCleaner[:neo4j, :connection => {:type => :server_db, :path => 'http://localhost:7474'}] - end - - it_should_behave_like "a generic strategy" - it_should_behave_like "a generic transaction strategy" - - describe "start" do - it "should start a transaction" - end - - describe "clean" do - it "should finish a transaction" - end - end - end -end diff --git a/spec/database_cleaner/ohm/truncation_spec.rb b/spec/database_cleaner/ohm/truncation_spec.rb deleted file mode 100644 index bee581e7..00000000 --- a/spec/database_cleaner/ohm/truncation_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'ohm' -require 'database_cleaner/ohm/truncation' - -module OhmTests - class Widget < ::Ohm::Model - attribute :name - end - - class Gadget < ::Ohm::Model - attribute :name - end -end - -RSpec.describe DatabaseCleaner::Ohm::Truncation do - around do |example| - config = YAML::load(File.open("#{File.dirname(__FILE__)}/../../../examples/config/redis.yml")) - Ohm.connect url: config['test']['url'] - @redis = Ohm.redis - - example.run - - @redis.flushdb - end - - before do - OhmTests::Widget.new(name: 'some widget').save - OhmTests::Gadget.new(name: 'some gadget').save - end - - context "by default" do - it "truncates all keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(6).to(0) - end - end - - context "when keys are provided to the :only option" do - subject { described_class.new(only: ['*Widget*']) } - - it "only truncates the specified keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(6).to(3) - expect(@redis.get('OhmTests::Gadget:id')).to eq '1' - end - end - - context "when keys are provided to the :except option" do - subject { described_class.new(except: ['*Widget*']) } - - it "truncates all but the specified keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(6).to(3) - expect(@redis.get('OhmTests::Widget:id')).to eq '1' - end - end -end - diff --git a/spec/database_cleaner/redis/base_spec.rb b/spec/database_cleaner/redis/base_spec.rb deleted file mode 100644 index 69314c44..00000000 --- a/spec/database_cleaner/redis/base_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'redis' -require 'database_cleaner/redis/base' -require 'database_cleaner/spec' - -module DatabaseCleaner - RSpec.describe Redis do - it { is_expected.to respond_to(:available_strategies) } - end - - module Redis - class ExampleStrategy - include ::DatabaseCleaner::Redis::Base - end - - RSpec.describe ExampleStrategy do - - it_should_behave_like "a generic strategy" - it { is_expected.to respond_to(:db) } - it { is_expected.to respond_to(:db=) } - - context "when passing url" do - it "should store my describe db" do - url = 'redis://localhost:6379/2' - subject.db = 'redis://localhost:6379/2' - expect(subject.db).to eq url - end - end - - context "when passing connection" do - it "should store my describe db" do - connection = ::Redis.new :url => 'redis://localhost:6379/2' - subject.db = connection - expect(subject.db).to eq connection - end - end - - it "should default to :default" do - expect(subject.db).to eq :default - end - end - end -end diff --git a/spec/database_cleaner/redis/truncation_spec.rb b/spec/database_cleaner/redis/truncation_spec.rb deleted file mode 100644 index 739648de..00000000 --- a/spec/database_cleaner/redis/truncation_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'redis' -require 'database_cleaner/redis/truncation' - -RSpec.describe DatabaseCleaner::Redis::Truncation do - around do |example| - config = YAML::load(File.open("#{File.dirname(__FILE__)}/../../../examples/config/redis.yml")) - @redis = ::Redis.new :url => config['test']['url'] - - example.run - - @redis.flushdb - end - - before do - @redis.set 'Widget', 1 - @redis.set 'Gadget', 1 - end - - context "by default" do - it "truncates all keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(2).to(0) - end - end - - context "when keys are provided to the :only option" do - subject { described_class.new(only: ['Widge*']) } - - it "only truncates the specified keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(2).to(1) - expect(@redis.get('Gadget')).to eq '1' - end - end - - context "when keys are provided to the :except option" do - subject { described_class.new(except: ['Widg*']) } - - it "truncates all but the specified keys" do - expect { subject.clean }.to change { @redis.keys.size }.from(2).to(1) - expect(@redis.get('Widget')).to eq '1' - end - end -end - diff --git a/spec/database_cleaner/sequel/base_spec.rb b/spec/database_cleaner/sequel/base_spec.rb deleted file mode 100644 index 0ce48695..00000000 --- a/spec/database_cleaner/sequel/base_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'database_cleaner/sequel/base' -require 'database_cleaner/spec' -require 'sequel' - -module DatabaseCleaner - RSpec.describe Sequel do - it { is_expected.to respond_to(:available_strategies) } - end - - module Sequel - class ExampleStrategy - include ::DatabaseCleaner::Sequel::Base - end - - RSpec.describe ExampleStrategy do - it_should_behave_like "a generic strategy" - it { is_expected.to respond_to(:db) } - it { is_expected.to respond_to(:db=) } - - it "should store my desired db" do - subject.db = :my_db - expect(subject.db).to eq :my_db - end - - pending "I figure out how to use Sequel and write some real tests for it..." - end - end -end diff --git a/spec/database_cleaner/sequel/deletion_spec.rb b/spec/database_cleaner/sequel/deletion_spec.rb deleted file mode 100644 index 289c86ef..00000000 --- a/spec/database_cleaner/sequel/deletion_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'database_cleaner/sequel/deletion' -require 'database_cleaner/spec' -require 'support/sequel_helper' - -module DatabaseCleaner - module Sequel - RSpec.describe Deletion do - it_should_behave_like "a generic strategy" - - SequelHelper.with_all_dbs do |helper| - context "using a #{helper.db} connection" do - around do |example| - helper.setup - example.run - helper.teardown - end - - let(:connection) { helper.connection } - - before { subject.db = connection } - - context 'when several tables have data' do - before do - connection[:users].insert - connection[:agents].insert - end - - context 'by default' do - it 'deletes all the tables' do - subject.clean - - expect(connection[:users]).to be_empty - expect(connection[:agents]).to be_empty - end - end - end - end - end - end - end -end diff --git a/spec/database_cleaner/sequel/transaction_spec.rb b/spec/database_cleaner/sequel/transaction_spec.rb deleted file mode 100644 index 3141d046..00000000 --- a/spec/database_cleaner/sequel/transaction_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'database_cleaner/sequel/transaction' -require 'database_cleaner/spec' -require 'support/sequel_helper' - -module DatabaseCleaner - module Sequel - RSpec.describe Transaction do - it_should_behave_like "a generic strategy" - it_should_behave_like "a generic transaction strategy" - - describe "start" do - it "should start a transaction" - end - - describe "clean" do - it "should finish a transaction" - end - end - end -end diff --git a/spec/database_cleaner/sequel/truncation_spec.rb b/spec/database_cleaner/sequel/truncation_spec.rb deleted file mode 100644 index 52166cb3..00000000 --- a/spec/database_cleaner/sequel/truncation_spec.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'database_cleaner/sequel/truncation' -require 'database_cleaner/spec' -require 'support/sequel_helper' - -module DatabaseCleaner - module Sequel - RSpec.describe Truncation do - it_should_behave_like "a generic strategy" - it_should_behave_like "a generic truncation strategy" - - SequelHelper.with_all_dbs do |helper| - context "using a #{helper.db} connection" do - around do |example| - helper.setup - example.run - helper.teardown - end - - let(:connection) { helper.connection } - - before { subject.db = connection } - - context 'when several tables have data' do - before do - connection[:users].insert - connection[:agents].insert - end - - context 'by default' do - it 'truncates all the tables' do - subject.clean - - expect(connection[:users]).to be_empty - expect(connection[:agents]).to be_empty - end - end - - context 'restricted to "only: [...]" some tables' do - subject { described_class.new(only: ['users']) } - - it 'truncates only the mentioned tables (and leaves the rest alone)' do - subject.clean - - expect(connection[:users]).to be_empty - expect(connection[:agents].count).to eq(1) - end - end - - context 'restricted to "except: [...]" some tables' do - subject { described_class.new(except: ['users']) } # XXX: Strings only, symbols are ignored - - it 'leaves the mentioned tables alone (and truncates the rest)' do - subject.clean - - expect(connection[:users].count).to eq(1) - expect(connection[:agents]).to be_empty - end - end - end - - describe 'auto increment sequences' do - it "resets AUTO_INCREMENT primary key seqeunce" do - table = connection[:users] - 2.times { table.insert } - - subject.clean - - id_after_clean = table.insert - expect(id_after_clean).to eq 1 - end - end - - describe "with pre_count optimization option" do - subject { described_class.new(pre_count: true) } - - before { connection[:users].insert } - - it "only truncates non-empty tables" do - sql = case helper.db - when :sqlite3 then ["DELETE FROM `users`", anything] - when :postgres then ['TRUNCATE TABLE "users" RESTART IDENTITY;', anything] - else ["TRUNCATE TABLE `users`", anything] - end - expect(subject.db).to receive(:execute_ddl).once.with(*sql) - subject.clean - end - end - end - end - end - end -end From 0cf7816aacec3e0b57e67bb0855a08f01b826a7c Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Sat, 1 Feb 2020 14:32:57 -0800 Subject: [PATCH 03/21] add byebug for debugging. --- .gitignore | 1 + Gemfile | 1 + Gemfile.lock | 2 ++ spec/spec_helper.rb | 3 ++- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bf3f73f6..e628ebe8 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ tmp/* .ruby-version .vagrant .idea/ +.byebug_history diff --git a/Gemfile b/Gemfile index 7e55a3bc..0b98f7b0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,3 @@ gemspec +gem "byebug" diff --git a/Gemfile.lock b/Gemfile.lock index ee56f508..17694b4d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,6 +32,7 @@ GEM bson_ext (1.12.5) bson (~> 1.12.5) builder (2.1.2) + byebug (10.0.2) coderay (1.1.2) couch_potato (1.3.0) activemodel @@ -244,6 +245,7 @@ DEPENDENCIES activerecord-mysql2-adapter bson_ext bundler + byebug couch_potato cucumber database_cleaner! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b58e50e3..362950c0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ require "bundler/setup" -require 'database_cleaner' +require "database_cleaner" +require "byebug" RSpec.configure do |config| # These two settings work together to allow you to limit a spec run From a5936214b761234dbbb77d551b7fca06f51518c4 Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Sat, 1 Feb 2020 14:07:00 -0800 Subject: [PATCH 04/21] remove all deprecated code and get the specs passing again. --- Gemfile.lock | 184 +------------- README.markdown | 40 +-- database_cleaner.gemspec | 30 +-- lib/database_cleaner.rb | 13 - lib/database_cleaner/base.rb | 73 +----- lib/database_cleaner/configuration.rb | 56 +---- lib/database_cleaner/orm_autodetector.rb | 40 --- spec/database_cleaner/base_spec.rb | 258 +++----------------- spec/database_cleaner/configuration_spec.rb | 21 +- 9 files changed, 49 insertions(+), 666 deletions(-) delete mode 100644 lib/database_cleaner/orm_autodetector.rb diff --git a/Gemfile.lock b/Gemfile.lock index 17694b4d..7519c50a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,109 +6,15 @@ PATH GEM remote: https://rubygems.org/ specs: - activemodel (3.0.0) - activesupport (= 3.0.0) - builder (~> 2.1.2) - i18n (~> 0.4.1) - activerecord (3.0.0) - activemodel (= 3.0.0) - activesupport (= 3.0.0) - arel (~> 1.0.0) - tzinfo (~> 0.3.23) - activerecord-mysql2-adapter (0.0.3) - mysql2 - activesupport (3.0.0) - addressable (2.3.6) - arel (1.0.1) - activesupport (~> 3.0.0) - bcrypt (3.1.7) - bcrypt (3.1.7-java) - bcrypt-ruby (3.1.5) - bcrypt (>= 3.1.3) - bcrypt-ruby (3.1.5-java) - bcrypt (>= 3.1.3) - bson (1.12.5) - bson (1.12.5-java) - bson_ext (1.12.5) - bson (~> 1.12.5) builder (2.1.2) byebug (10.0.2) coderay (1.1.2) - couch_potato (1.3.0) - activemodel - couchrest (~> 1.2.0) - json (~> 1.6) - couchrest (1.2.1) - mime-types (>= 1.15) - multi_json (~> 1.7, ~> 1.0) - rest-client (~> 1.8.0) cucumber (1.2.1) builder (>= 2.1.2) diff-lcs (>= 1.1.3) gherkin (~> 2.11.0) json (>= 1.4.6) - data_objects (0.10.14) - addressable (~> 2.1) - datamapper (1.2.0) - dm-aggregates (~> 1.2.0) - dm-constraints (~> 1.2.0) - dm-core (~> 1.2.0) - dm-migrations (~> 1.2.0) - dm-serializer (~> 1.2.0) - dm-timestamps (~> 1.2.0) - dm-transactions (~> 1.2.0) - dm-types (~> 1.2.0) - dm-validations (~> 1.2.0) diff-lcs (1.3) - dm-aggregates (1.2.0) - dm-core (~> 1.2.0) - dm-constraints (1.2.0) - dm-core (~> 1.2.0) - dm-core (1.2.1) - addressable (~> 2.3) - dm-do-adapter (1.2.0) - data_objects (~> 0.10.6) - dm-core (~> 1.2.0) - dm-migrations (1.2.0) - dm-core (~> 1.2.0) - dm-serializer (1.2.2) - dm-core (~> 1.2.0) - fastercsv (~> 1.5) - json (~> 1.6) - json_pure (~> 1.6) - multi_json (~> 1.0) - dm-sqlite-adapter (1.2.0) - dm-do-adapter (~> 1.2.0) - do_sqlite3 (~> 0.10.6) - dm-timestamps (1.2.0) - dm-core (~> 1.2.0) - dm-transactions (1.2.0) - dm-core (~> 1.2.0) - dm-types (1.2.2) - bcrypt-ruby (~> 3.0) - dm-core (~> 1.2.0) - fastercsv (~> 1.5) - json (~> 1.6) - multi_json (~> 1.0) - stringex (~> 1.4) - uuidtools (~> 2.1) - dm-validations (1.2.0) - dm-core (~> 1.2.0) - do_jdbc (0.10.14-java) - data_objects (= 0.10.14) - do_sqlite3 (0.10.14) - data_objects (= 0.10.14) - do_sqlite3 (0.10.14-java) - data_objects (= 0.10.14) - do_jdbc (= 0.10.14) - jdbc-sqlite3 (>= 3.5.8) - domain_name (0.5.20180417) - unf (>= 0.0.5, < 1.0.0) - faraday (0.9.0) - multipart-post (>= 1.2, < 3) - faraday_middleware (0.9.1) - faraday (>= 0.7.4, < 0.10) - fastercsv (1.5.5) ffi (1.9.25) ffi (1.9.25-java) formatador (0.2.5) @@ -130,68 +36,17 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - http-cookie (1.0.3) - domain_name (~> 0.5) - httparty (0.13.3) - json (~> 1.8) - multi_xml (>= 0.5.2) - httpclient (2.5.3.3) - i18n (0.4.2) - jdbc-sqlite3 (3.8.10.1) json (1.8.6) json (1.8.6-java) - json_pure (1.8.1) listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) lumberjack (1.0.13) method_source (0.9.0) - mime-types (2.99.3) - mongo (1.12.5) - bson (= 1.12.5) - mongo_ext (0.19.3) - mongo_mapper (0.12.0) - activemodel (~> 3.0) - activesupport (~> 3.0) - plucky (~> 0.5.2) - mongoid (2.2.6) - activemodel (~> 3.0.0) - mongo (~> 1.3) - tzinfo (~> 0.3.22) - mongoid-tree (0.7.0) - mongoid (~> 2.0) - moped (1.5.2) - multi_json (1.13.1) - multi_xml (0.5.5) - multipart-post (2.0.0) - mysql (2.9.1) - mysql2 (0.3.18) nenv (0.3.0) - neo4j-community (2.1.5) - neo4j-core (3.0.8) - activesupport - faraday (~> 0.9.0) - faraday_middleware (~> 0.9.1) - httparty - httpclient - json - neo4j-community (~> 2.1.1) - net-http-persistent - os - zip - nest (1.1.2) - redis - net-http-persistent (2.9.4) - netrc (0.11.0) notiffany (0.1.1) nenv (~> 0.1) shellany (~> 0.0) - ohm (0.1.5) - nest (~> 1.0) - os (0.9.6) - pg (0.18.2) - plucky (0.5.2) - mongo (~> 1.5) pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) @@ -203,11 +58,6 @@ GEM rb-fsevent (0.10.3) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) - redis (3.1.0) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) rspec (3.7.0) rspec-core (~> 3.7.0) rspec-expectations (~> 3.7.0) @@ -221,56 +71,24 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.7.0) rspec-support (3.7.1) - sequel (3.21.0) shellany (0.0.1) spoon (0.0.6) ffi - sqlite3 (1.3.10) - stringex (1.5.1) thor (0.20.0) - tzinfo (0.3.48) - unf (0.1.4) - unf_ext - unf (0.1.4-java) - unf_ext (0.0.7.5) - uuidtools (2.1.5) - zip (2.0.2) PLATFORMS java ruby DEPENDENCIES - activerecord - activerecord-mysql2-adapter - bson_ext bundler byebug - couch_potato cucumber database_cleaner! - datamapper - dm-migrations - dm-sqlite-adapter guard-rspec - json_pure - listen (~> 3.0.0) - mongo (~> 1.12.0) - mongo_ext - mongo_mapper - mongoid - mongoid-tree - moped - mysql (~> 2.9.1) - mysql2 - neo4j-core - ohm (~> 0.1.3) - pg + listen rake rspec - sequel (~> 3.21.0) - sqlite3 - tzinfo BUNDLED WITH 1.17.3 diff --git a/README.markdown b/README.markdown index 568392fe..cbed4af9 100644 --- a/README.markdown +++ b/README.markdown @@ -1,9 +1,8 @@ - +(1.8.1).](https://github.com/DatabaseCleaner/database_cleaner/blob/v1.8.1/README.markdown)** + # Database Cleaner [![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner) @@ -58,7 +57,6 @@ MongoDB Redis * [database_cleaner-redis](adapters/database_cleaner-redis) - * [database_cleaner-ohm](adapters/database_cleaner-ohm) Neo4j * [database_cleaner-neo4j](adapters/database_cleaner-neo4j) @@ -320,40 +318,6 @@ One of my motivations for writing this library was to have an easy way to turn o After copying and pasting code to do this several times I decided to package it up as a gem and save everyone a bit of time. -## Common Errors - -#### DatabaseCleaner is trying to use the wrong ORM - -DatabaseCleaner has a deprecated autodetect mechanism where if you do not explicitly define your ORM it will use the first ORM it can detect that is loaded. - -Since ActiveRecord is the most common ORM used that is the first one checked for. - -Sometimes other libraries (e.g. ActiveAdmin) will load other ORMs (e.g. ActiveRecord) even though you are using a different ORM. This will result in DatabaseCleaner trying to use the wrong ORM (e.g. ActiveRecord) unless you explicitly require the correct adapter gem: - -```ruby -# Gemfile -gem "database_cleaner-mongoid" -``` - -### STDERR is being flooded when using Postgres - -If you are using Postgres and have foreign key constraints, the truncation strategy will cause a lot of extra noise to appear on STDERR (in the form of "NOTICE truncate cascades" messages). - -To silence these warnings set the following log level in your `postgresql.conf` file: - -```ruby -client_min_messages = warning -``` - -For ActiveRecord, you add the following parameter in your database.yml file: - -
-test:
-  adapter: postgresql
-  # ...
-  min_messages: WARNING
-
- ## Safeguards DatabaseCleaner comes with safeguards against: diff --git a/database_cleaner.gemspec b/database_cleaner.gemspec index ff260532..85a3306a 100644 --- a/database_cleaner.gemspec +++ b/database_cleaner.gemspec @@ -37,36 +37,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake" spec.add_development_dependency "bundler" - spec.add_development_dependency "json_pure" - spec.add_development_dependency "activerecord-mysql2-adapter" unless RUBY_PLATFORM =~ /java/ - spec.add_development_dependency "activerecord" - spec.add_development_dependency "datamapper" - spec.add_development_dependency "dm-migrations" - spec.add_development_dependency "dm-sqlite-adapter" - spec.add_development_dependency "mongoid" - spec.add_development_dependency "tzinfo" - spec.add_development_dependency "mongoid-tree" - spec.add_development_dependency "mongo_mapper" - spec.add_development_dependency "mongo", "~> 1.12.0" - spec.add_development_dependency "moped" - spec.add_development_dependency "neo4j-core" - spec.add_development_dependency "couch_potato" - spec.add_development_dependency "sequel", "~> 3.21.0" - spec.add_development_dependency 'ohm', '~> 0.1.3' spec.add_development_dependency 'guard-rspec' - spec.add_development_dependency "listen", "~> 3.0.0" # 3.1 requires Ruby >= 2.2 + spec.add_development_dependency "listen" spec.add_development_dependency "rspec" spec.add_development_dependency "cucumber" - - unless RUBY_PLATFORM =~ /java/ - spec.add_development_dependency "mongo_ext" - spec.add_development_dependency "bson_ext" - spec.add_development_dependency 'mysql', '~> 2.9.1' - spec.add_development_dependency 'mysql2' - spec.add_development_dependency 'pg' - spec.add_development_dependency "sqlite3-ruby" if RUBY_VERSION < "1.9" - spec.add_development_dependency "sqlite3" if RUBY_VERSION >= "1.9" - else - spec.add_development_dependency "activerecord-jdbc-adapter" - end end diff --git a/lib/database_cleaner.rb b/lib/database_cleaner.rb index 90bec726..6210a7a3 100644 --- a/lib/database_cleaner.rb +++ b/lib/database_cleaner.rb @@ -21,23 +21,10 @@ class << self :clean, :clean_with, :cleaning, - - # TODO remove in 2.0 - :clean!, - :clean_with!, - :init_cleaners, - :add_cleaner, - :connections, - :remove_duplicates, ] => :configuration attr_accessor :allow_remote_database_url, :allow_production, :url_whitelist - def can_detect_orm? - DatabaseCleaner.deprecate "Calling `DatabaseCleaner.can_detect_orm?` is deprecated, and will be removed in database_cleaner 2.0 with no replacement." - DatabaseCleaner::Base.autodetect_orm - end - private def configuration diff --git a/lib/database_cleaner/base.rb b/lib/database_cleaner/base.rb index d34e9bc5..f2aba04e 100644 --- a/lib/database_cleaner/base.rb +++ b/lib/database_cleaner/base.rb @@ -1,7 +1,6 @@ require 'database_cleaner/deprecation' require 'database_cleaner/null_strategy' require 'database_cleaner/safeguard' -require 'database_cleaner/orm_autodetector' require 'forwardable' module DatabaseCleaner @@ -13,10 +12,8 @@ def <=>(other) end def initialize(desired_orm = nil, opts = {}) - @orm_autodetector = ORMAutodetector.new self.orm = desired_orm self.db = opts[:connection] || opts[:model] if opts.has_key?(:connection) || opts.has_key?(:model) - self.strategy = orm_module && orm_module.default_strategy Safeguard.new.run end @@ -48,8 +45,7 @@ def strategy attr_reader :orm def orm=(desired_orm) - @orm = (desired_orm || :autodetect).to_sym - @orm = @orm_autodetector.orm if @orm == :autodetect + @orm = desired_orm && desired_orm.to_sym end extend Forwardable @@ -62,41 +58,13 @@ def clean_with(*args) strategy end - # TODO remove the following methods in 2.0 - - def auto_detected? - DatabaseCleaner.deprecate "Calling `DatabaseCleaner[...].auto_detected?` is deprecated, and will be removed in database_cleaner 2.0 with no replacement." - @orm_autodetector.autodetected? - end - - def autodetect_orm - DatabaseCleaner.deprecate "Calling `DatabaseCleaner[...].autodetect_orm` is deprecated, and will be removed in database_cleaner 2.0 with no replacement." - @orm_autodetector.orm - end - - def clean! - DatabaseCleaner.deprecate "Calling `DatabaseCleaner[...].clean!` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner[...].clean instead." - clean - end - - def clean_with! - DatabaseCleaner.deprecate "Calling `DatabaseCleaner[...].clean_with!` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner[...].clean_with instead." - clean_with - end - - # TODO privatize the following methods in 2.0 + private def strategy_db=(desired_db) - if called_externally?(caller) - DatabaseCleaner.deprecate "Calling `DatabaseCleaner[...].strategy_db=` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner[...].db=` instead." - end set_strategy_db(strategy, desired_db) end def set_strategy_db(strategy, desired_db) - if called_externally?(caller) - DatabaseCleaner.deprecate "Calling `DatabaseCleaner[...].set_strategy_db=` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner[...].db=` instead." - end if strategy.respond_to? :db= strategy.db = desired_db elsif desired_db != :default @@ -105,45 +73,28 @@ def set_strategy_db(strategy, desired_db) end def create_strategy(*args) - if called_externally?(caller) - DatabaseCleaner.deprecate "Calling `DatabaseCleaner[...].create_strategy` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner[...].strategy=` instead." - end strategy, *strategy_args = args orm_strategy(strategy).new(*strategy_args) end - private - - def orm_module - return unless [:active_record, :data_mapper, :mongo, :mongoid, :mongo_mapper, :moped, :couch_potato, :sequel, :ohm, :redis, :neo4j].include?(orm) - $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../../adapters/database_cleaner-#{orm}/lib") - require "database_cleaner/#{orm}" - orm_module_name = ORMAutodetector::ORMS[orm] - DatabaseCleaner.const_get(orm_module_name) - end - def orm_strategy(strategy) strategy_module_name = strategy.to_s.capitalize orm_module.const_get(strategy_module_name) rescue NameError - if orm != :active_record - DatabaseCleaner.deprecate <<-TEXT - The #{orm_module} adapter has been extracted to its own gem: database_cleaner-#{orm}, and will be removed from database_cleaner in 2.0. To silence this message, please replace `gem "database_cleaner"` with `gem "database_cleaner-#{orm}"` in your Gemfile. - TEXT - end - require_orm_strategy(orm, strategy) - retry + raise UnknownStrategySpecified, "The '#{strategy}' strategy does not exist for the #{orm} ORM! Available strategies: #{orm_module.available_strategies.join(', ')}" end - def require_orm_strategy(orm, strategy) - $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../../adapters/database_cleaner-#{orm}/lib") - require "database_cleaner/#{orm}/#{strategy}" - rescue LoadError - raise UnknownStrategySpecified, "The '#{strategy}' strategy does not exist for the #{orm} ORM! Available strategies: #{orm_module.available_strategies.join(', ')}" + def orm_module + orm_module_name = camelize(orm) + DatabaseCleaner.const_get(orm_module_name) end - def called_externally?(caller) - __FILE__ != caller.first.split(":").first + def camelize(term) + string = term.to_s + string = string.sub(/^[a-z\d]*/) { |match| match.capitalize } + string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" } + string.gsub!("/", "::") + string end end end diff --git a/lib/database_cleaner/configuration.rb b/lib/database_cleaner/configuration.rb index 6e359835..bb32294c 100644 --- a/lib/database_cleaner/configuration.rb +++ b/lib/database_cleaner/configuration.rb @@ -26,7 +26,7 @@ def orm=(orm) remove_duplicates end - # TODO privatize the following methods in 2.0 + private def add_cleaner(orm, opts = {}) self[[orm, opts]] = ::DatabaseCleaner::Base.new(orm, opts) @@ -54,26 +54,6 @@ def initialize attr_accessor :cleaners - def app_root - DatabaseCleaner.deprecate "Calling `DatabaseCleaner.app_root` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner::ActiveRecord.config_file_location`, instead." - @app_root ||= Dir.pwd - end - - def app_root= value - DatabaseCleaner.deprecate "Calling `DatabaseCleaner.app_root=` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner::ActiveRecord.config_file_location=`, instead." - @app_root = value - end - - def logger - DatabaseCleaner.deprecate "Calling `DatabaseCleaner.logger` is deprecated, and will be removed in database_cleaner 2.0 with no replacement." - @logger ||= Logger.new(STDOUT).tap { |l| l.level = Logger::ERROR } - end - - def logger= value - DatabaseCleaner.deprecate "Calling `DatabaseCleaner.logger=` is deprecated, and will be removed in database_cleaner 2.0 with no replacement." - @logger = value - end - def start connections.each { |connection| connection.start } end @@ -92,50 +72,18 @@ def clean_with(*args) connections.each { |connection| connection.clean_with(*args) } end - # TODO remove the following methods in 2.0 - - def clean! - DatabaseCleaner.deprecate "Calling `DatabaseCleaner.clean!` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.clean`, instead." - clean - end - - def clean_with!(*args) - DatabaseCleaner.deprecate "Calling `DatabaseCleaner.clean_with!` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.clean_with`, instead." - clean_with(*args) - end - - def init_cleaners - DatabaseCleaner.deprecate "Calling `DatabaseCleaner.init_cleaners` is deprecated, and will be removed in database_cleaner 2.0 with no replacement." - end + private def connections - if called_externally?(caller) - DatabaseCleaner.deprecate "Calling `DatabaseCleaner.connections` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.cleaners`, instead." - end - add_cleaner(:autodetect) if @cleaners.none? @cleaners.values end - # TODO privatize the following methods in 2.0 - def add_cleaner(orm, opts = {}) - if called_externally?(caller) - DatabaseCleaner.deprecate "Calling `DatabaseCleaner.add_cleaner` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.[]`, instead." - end @cleaners.add_cleaner(orm, opts = {}) end def remove_duplicates - if called_externally?(caller) - DatabaseCleaner.deprecate "Calling `DatabaseCleaner.remove_duplicates` is deprecated, and will be removed in database_cleaner 2.0 with no replacement." - end @cleaners.remove_duplicates end - - private - - def called_externally?(caller) - __FILE__ != caller.first.split(":").first - end end end diff --git a/lib/database_cleaner/orm_autodetector.rb b/lib/database_cleaner/orm_autodetector.rb deleted file mode 100644 index 04f432ff..00000000 --- a/lib/database_cleaner/orm_autodetector.rb +++ /dev/null @@ -1,40 +0,0 @@ -module DatabaseCleaner - class ORMAutodetector - ORMS = { - active_record: "ActiveRecord", - data_mapper: "DataMapper", - mongo_mapper: "MongoMapper", - mongoid: "Mongoid", - couch_potato: "CouchPotato", - sequel: "Sequel", - moped: "Moped", - ohm: "Ohm", - redis: "Redis", - neo4j: "Neo4j", - } - - def orm - @autodetected = true - autodetected_orm or raise no_orm_detected_error - ORMS.key(autodetected_orm.to_s) - end - - def autodetected? - !!@autodetected - end - - private - - def autodetected_orm - ORMS.values.find do |orm| - Kernel.const_get(orm) rescue next - end - end - - def no_orm_detected_error - orm_list = ORMS.values.join(", ").sub(ORMS.values.last, "or #{ORMS.values.last}") - NoORMDetected.new("No known ORM was detected! Is #{orm_list} loaded?") - end - end - private_constant :ORMAutodetector -end diff --git a/spec/database_cleaner/base_spec.rb b/spec/database_cleaner/base_spec.rb index b7b2783c..05b85605 100644 --- a/spec/database_cleaner/base_spec.rb +++ b/spec/database_cleaner/base_spec.rb @@ -1,131 +1,5 @@ -require 'active_record' -require 'data_mapper' -require 'mongo_mapper' -require 'mongoid' -require 'couch_potato' -require 'couch_potato' -require 'sequel' -require 'moped' -require 'ohm' -require 'redis' -require 'neo4j-core' - module DatabaseCleaner RSpec.describe Base do - describe "autodetect" do - it "should raise an error when no ORM is detected" do - hide_const "ActiveRecord" - hide_const "DataMapper" - hide_const "MongoMapper" - hide_const "Mongoid" - hide_const "CouchPotato" - hide_const "Sequel" - hide_const "Moped" - hide_const "Redis" - hide_const "Ohm" - hide_const "Neo4j" - - expect { subject }.to raise_error(DatabaseCleaner::NoORMDetected, <<-ERROR.chomp) -No known ORM was detected! Is ActiveRecord, DataMapper, MongoMapper, Mongoid, CouchPotato, Sequel, Moped, Ohm, Redis, or Neo4j loaded? - ERROR - end - - it "should detect ActiveRecord first" do - expect(subject.orm).to eq :active_record - expect(subject).to be_auto_detected - end - - it "should detect DataMapper second" do - hide_const "ActiveRecord" - expect(subject.orm).to eq :data_mapper - expect(subject).to be_auto_detected - end - - it "should detect MongoMapper third" do - hide_const "ActiveRecord" - hide_const "DataMapper" - expect(subject.orm).to eq :mongo_mapper - expect(subject).to be_auto_detected - end - - it "should detect Mongoid fourth" do - hide_const "ActiveRecord" - hide_const "DataMapper" - hide_const "MongoMapper" - expect(subject.orm).to eq :mongoid - expect(subject).to be_auto_detected - end - - it "should detect CouchPotato fifth" do - hide_const "ActiveRecord" - hide_const "DataMapper" - hide_const "MongoMapper" - hide_const "Mongoid" - expect(subject.orm).to eq :couch_potato - expect(subject).to be_auto_detected - end - - it "should detect Sequel sixth" do - hide_const "ActiveRecord" - hide_const "DataMapper" - hide_const "MongoMapper" - hide_const "Mongoid" - hide_const "CouchPotato" - expect(subject.orm).to eq :sequel - expect(subject).to be_auto_detected - end - - it 'detects Moped seventh' do - hide_const "ActiveRecord" - hide_const "DataMapper" - hide_const "MongoMapper" - hide_const "Mongoid" - hide_const "CouchPotato" - hide_const "Sequel" - expect(subject.orm).to eq :moped - expect(subject).to be_auto_detected - end - - it 'detects Ohm eighth' do - hide_const "ActiveRecord" - hide_const "DataMapper" - hide_const "MongoMapper" - hide_const "Mongoid" - hide_const "CouchPotato" - hide_const "Sequel" - hide_const "Moped" - expect(subject.orm).to eq :ohm - expect(subject).to be_auto_detected - end - - it 'detects Redis ninth' do - hide_const "ActiveRecord" - hide_const "DataMapper" - hide_const "MongoMapper" - hide_const "Mongoid" - hide_const "CouchPotato" - hide_const "Sequel" - hide_const "Moped" - hide_const "Ohm" - expect(subject.orm).to eq :redis - expect(subject).to be_auto_detected - end - - it 'detects Neo4j tenth' do - hide_const "ActiveRecord" - hide_const "DataMapper" - hide_const "MongoMapper" - hide_const "Mongoid" - hide_const "CouchPotato" - hide_const "Sequel" - hide_const "Moped" - hide_const "Ohm" - hide_const "Redis" - expect(subject.orm).to eq :neo4j - expect(subject).to be_auto_detected - end - end - describe "comparison" do it "should be equal if orm and connection are the same" do one = DatabaseCleaner::Base.new(:active_record, :connection => :default) @@ -172,18 +46,8 @@ module DatabaseCleaner expect(cleaner.orm).to eq :mongoid end - it "is autodetected if orm is not provided" do - cleaner = ::DatabaseCleaner::Base.new - expect(cleaner).to be_auto_detected - end - - it "is autodetected if you specify :autodetect" do - cleaner = ::DatabaseCleaner::Base.new "autodetect" - expect(cleaner).to be_auto_detected - end - - it "should default to autodetect upon initalisation" do - expect(subject).to be_auto_detected + it "should default to nil" do + expect(subject.orm).to be_nil end end end @@ -231,23 +95,29 @@ module DatabaseCleaner end describe "clean_with" do - # FIXME hacky null strategy - # because you can't pass a NullStrategy to #clean_with + subject { described_class.new(:active_record) } - let(:strategy) { double(clean: true) } + let(:strategy_class) { Class.new } - let(:strategy_class) do - require "database_cleaner/active_record/truncation" - DatabaseCleaner::ActiveRecord::Truncation + before do + orm_module = Module.new do + def self.available_strategies + %i[truncation transaction deletion] + end + end + stub_const "DatabaseCleaner::ActiveRecord", orm_module + stub_const "DatabaseCleaner::ActiveRecord::Truncation", strategy_class end + let(:strategy) { double } + before do - allow(::ActiveRecord::Base).to receive(:connection).and_return(double.as_null_object) allow(strategy_class).to receive(:new).and_return(strategy) end it "should pass all arguments to strategy initializer" do expect(strategy_class).to receive(:new).with(:dollar, :amet, ipsum: "random").and_return(strategy) + expect(strategy).to receive(:clean) subject.clean_with :truncation, :dollar, :amet, ipsum: "random" end @@ -257,14 +127,24 @@ module DatabaseCleaner end it "should return the created strategy" do + expect(strategy).to receive(:clean) expect(subject.clean_with(:truncation)).to eq strategy end end describe "strategy=" do - let(:strategy_class) do - require "database_cleaner/active_record/truncation" - DatabaseCleaner::ActiveRecord::Truncation + subject { described_class.new(:active_record) } + + let(:strategy_class) { Class.new } + + before do + orm_module = Module.new do + def self.available_strategies + %i[truncation transaction deletion] + end + end + stub_const "DatabaseCleaner::ActiveRecord", orm_module + stub_const "DatabaseCleaner::ActiveRecord::Truncation", strategy_class end it "should look up and create a the named strategy for the current ORM" do @@ -299,13 +179,6 @@ module DatabaseCleaner expect { subject.strategy = :horrible_plan }.to \ raise_error(UnknownStrategySpecified, "The 'horrible_plan' strategy does not exist for the active_record ORM! Available strategies: truncation, transaction, deletion") end - - it "loads and instantiates the described strategy" do - stub_const "DatabaseCleaner::ActiveRecord::Cunningplan", strategy_class - - subject.strategy = :cunningplan - expect(subject.strategy).to be_a strategy_class - end end describe "strategy" do @@ -323,18 +196,6 @@ module DatabaseCleaner subject.orm = :desired_orm expect(subject.orm).to eq :desired_orm end - - context "orm isn't set" do - subject { described_class.new } - - it "should run autodetect if orm isn't set" do - expect(subject).to be_auto_detected - end - - it "should return the result of autodetect if orm isn't set" do - expect(subject.orm).to eq :active_record - end - end end describe "proxy methods" do @@ -365,68 +226,5 @@ module DatabaseCleaner end end end - - describe "autodetected?" do - it "is true if auto detection was used" do - expect(subject).to be_auto_detected - end - - it "is false if orm was specified" do - subject = described_class.new(:a_orm) - expect(subject).to_not be_auto_detected - end - end - - describe 'set_default_orm_strategy' do - it 'sets strategy to :transaction for ActiveRecord' do - cleaner = DatabaseCleaner::Base.new(:active_record) - expect(cleaner.strategy).to be_instance_of DatabaseCleaner::ActiveRecord::Transaction - end - - it 'sets strategy to :transaction for DataMapper' do - cleaner = DatabaseCleaner::Base.new(:data_mapper) - expect(cleaner.strategy).to be_instance_of DatabaseCleaner::DataMapper::Transaction - end - - it 'sets strategy to :truncation for MongoMapper' do - cleaner = DatabaseCleaner::Base.new(:mongo_mapper) - expect(cleaner.strategy).to be_instance_of DatabaseCleaner::MongoMapper::Truncation - end - - it 'sets strategy to :truncation for Mongoid' do - cleaner = DatabaseCleaner::Base.new(:mongoid) - expect(cleaner.strategy).to be_instance_of DatabaseCleaner::Mongoid::Truncation - end - - it 'sets strategy to :truncation for CouchPotato' do - cleaner = DatabaseCleaner::Base.new(:couch_potato) - expect(cleaner.strategy).to be_instance_of DatabaseCleaner::CouchPotato::Truncation - end - - it 'sets strategy to :transaction for Sequel' do - cleaner = DatabaseCleaner::Base.new(:sequel) - expect(cleaner.strategy).to be_instance_of DatabaseCleaner::Sequel::Transaction - end - - it 'sets strategy to :truncation for Moped' do - cleaner = DatabaseCleaner::Base.new(:moped) - expect(cleaner.strategy).to be_instance_of DatabaseCleaner::Moped::Truncation - end - - it 'sets strategy to :truncation for Ohm' do - cleaner = DatabaseCleaner::Base.new(:ohm) - expect(cleaner.strategy).to be_instance_of DatabaseCleaner::Ohm::Truncation - end - - it 'sets strategy to :truncation for Redis' do - cleaner = DatabaseCleaner::Base.new(:redis) - expect(cleaner.strategy).to be_instance_of DatabaseCleaner::Redis::Truncation - end - - it 'sets strategy to :transaction for Neo4j' do - cleaner = DatabaseCleaner::Base.new(:neo4j) - expect(cleaner.strategy).to be_instance_of DatabaseCleaner::Neo4j::Transaction - end - end end end diff --git a/spec/database_cleaner/configuration_spec.rb b/spec/database_cleaner/configuration_spec.rb index c7c84d10..f30bf7ba 100644 --- a/spec/database_cleaner/configuration_spec.rb +++ b/spec/database_cleaner/configuration_spec.rb @@ -14,13 +14,6 @@ def stub_cleaners(array) expect { subject[nil] }.to raise_error(DatabaseCleaner::NoORMDetected) end - it "should default to autodetection" do - require "active_record" - subject.strategy = :truncation - cleaner = subject.cleaners.values.first - expect(cleaner.orm).to eq :active_record - end - it "should accept :active_record" do cleaner = subject[:active_record] expect(cleaner).to be_a(DatabaseCleaner::Base) @@ -93,6 +86,9 @@ def stub_cleaners(array) end it "should retrieve a db rather than create a new one" do + stub_const "DatabaseCleaner::ActiveRecord", Module.new + stub_const "DatabaseCleaner::ActiveRecord::Truncation", Class.new + connection = subject[:active_record] subject[:active_record].strategy = :truncation expect(subject[:active_record]).to equal connection @@ -245,15 +241,4 @@ class FakeStrategy < Struct.new(:orm, :db, :strategy); end end end end - - describe "app_root" do - it "should default to Dir.pwd" do - expect(subject.app_root).to eq Dir.pwd - end - - it "should store specific paths" do - subject.app_root = '/path/to' - expect(subject.app_root).to eq '/path/to' - end - end end From eb80a78e011f4f5df25fea81e9ad5f1d529b38ca Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Sat, 1 Feb 2020 14:42:58 -0800 Subject: [PATCH 05/21] drop support for older rubies, and add support for current rubies. --- .travis.yml | 22 ++++------------------ database_cleaner.gemspec | 3 --- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 718419d1..ebd6e337 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,13 @@ -dist: trusty language: ruby rvm: - - 1.9.3 - - 2.0.0 - - 2.1 - - 2.2 + - 2.4 + - 2.5 + - 2.6 + - 2.7 before_install: - gem install bundler -v 1.17.3 - - | # cached install of Neo4j locally: - if [ ! -d neo4j-community-2.3.3/bin ]; - then - wget dist.neo4j.org/neo4j-community-2.3.3-unix.tar.gz; - tar -xzf neo4j-community-2.3.3-unix.tar.gz; - sed -i.bak s/dbms.security.auth_enabled=true/dbms.security.auth_enabled=false/g neo4j-community-2.3.3/conf/neo4j-server.properties; - fi before_script: - - neo4j-community-2.3.3/bin/neo4j start - bin/setup -services: - - redis-server - - mongodb cache: bundler: true - directories: - - neo4j-community-2.3.3 diff --git a/database_cleaner.gemspec b/database_cleaner.gemspec index 85a3306a..c83f590b 100644 --- a/database_cleaner.gemspec +++ b/database_cleaner.gemspec @@ -32,9 +32,6 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] - spec.rubygems_version = "2.4.5" - spec.required_ruby_version = ">= 1.9.3" - spec.add_development_dependency "rake" spec.add_development_dependency "bundler" spec.add_development_dependency 'guard-rspec' From 4d50d8864b79c7d59181014e4ff10888dc225b49 Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Sat, 1 Feb 2020 14:48:34 -0800 Subject: [PATCH 06/21] modernize gemspec. --- TODO | 3 --- database_cleaner.gemspec | 21 +++++---------------- 2 files changed, 5 insertions(+), 19 deletions(-) delete mode 100644 TODO diff --git a/TODO b/TODO deleted file mode 100644 index 3116452a..00000000 --- a/TODO +++ /dev/null @@ -1,3 +0,0 @@ -Could be more Datamapper -MongoMapper multiple db support -CouchDB multiple db support \ No newline at end of file diff --git a/database_cleaner.gemspec b/database_cleaner.gemspec index c83f590b..ad8f4d8c 100644 --- a/database_cleaner.gemspec +++ b/database_cleaner.gemspec @@ -14,22 +14,11 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner" spec.license = "MIT" - spec.files = [ - "CONTRIBUTE.markdown", - "Gemfile.lock", - "History.rdoc", - "README.markdown", - "Rakefile", - "cucumber.yml"] - spec.files += Dir['lib/**/*.rb'] - spec.files += Dir['adapters/**/lib/**/*.rb'] - - spec.extra_rdoc_files = [ - "LICENSE", - "README.markdown", - "TODO" - ] - + spec.files = `git ls-files -z`.split("\x0").reject do |f| + f.match(%r{^(test|spec|features)/}) + end + spec.bindir = "exe" + spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] spec.add_development_dependency "rake" From 22192c8451655a726f2c29b127dcebbc39331cfc Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Sat, 1 Feb 2020 14:59:22 -0800 Subject: [PATCH 07/21] don't run cucumber tests in this repo, at least not yet. --- Rakefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index e262d789..97879de9 100644 --- a/Rakefile +++ b/Rakefile @@ -15,10 +15,7 @@ RSpec::Core::RakeTask.new(:rcov) do |spec| spec.rcov = true end -require 'cucumber/rake/task' -Cucumber::Rake::Task.new(:features) - -task :default => [:spec, :features] +task :default => :spec desc "Cleans the project of any tmp file that should not be included in the gemspec." task :clean do From fa72e43c9e4bad33b5b30a470eb239ce5d9cc237 Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Sat, 1 Feb 2020 15:23:55 -0800 Subject: [PATCH 08/21] split gem into database_cleaner-core and database_cleaner metagem. --- Gemfile | 2 +- Gemfile.lock | 4 ++-- Rakefile | 38 +++++++++-------------------------- database_cleaner-core.gemspec | 30 +++++++++++++++++++++++++++ database_cleaner.gemspec | 19 ++---------------- lib/database_cleaner-core.rb | 1 + 6 files changed, 45 insertions(+), 49 deletions(-) create mode 100644 database_cleaner-core.gemspec create mode 100644 lib/database_cleaner-core.rb diff --git a/Gemfile b/Gemfile index 0b98f7b0..ec415ae0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,3 @@ -gemspec +gemspec name: "database_cleaner-core" gem "byebug" diff --git a/Gemfile.lock b/Gemfile.lock index 7519c50a..a9761aab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - database_cleaner (2.0.0.beta) + database_cleaner-core (2.0.0.beta) GEM remote: https://rubygems.org/ @@ -84,7 +84,7 @@ DEPENDENCIES bundler byebug cucumber - database_cleaner! + database_cleaner-core! guard-rspec listen rake diff --git a/Rakefile b/Rakefile index 97879de9..c6daf512 100644 --- a/Rakefile +++ b/Rakefile @@ -1,32 +1,12 @@ -require "rubygems" -require "bundler" -require "bundler/gem_tasks" -Bundler.setup - -require 'rake' -require 'rspec/core' -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) do |spec| - spec.pattern = FileList['spec/**/*_spec.rb'] -end - -RSpec::Core::RakeTask.new(:rcov) do |spec| - spec.pattern = 'spec/**/*_spec.rb' - spec.rcov = true -end - +# testing +require "rspec/core/rake_task" +RSpec::Core::RakeTask.new(:spec) task :default => :spec -desc "Cleans the project of any tmp file that should not be included in the gemspec." -task :clean do - ["examples/config/database.yml", "examples/db/activerecord_one.db", "examples/db/activerecord_two.db", "examples/db/datamapper_default.db", - "examples/db/datamapper_one.db", "examples/db/datamapper_two.db"].each do |f| - FileUtils.rm_f(f) - end - %w[*.sqlite3 *.log #* *.swp *.swo].each do |pattern| - `find . -name "#{pattern}" -delete` - end -end +# releasing +require "rake/clean" +CLOBBER.include "pkg" +require "bundler/gem_helper" +Bundler::GemHelper.install_tasks name: :database_cleaner +Bundler::GemHelper.install_tasks name: :"database_cleaner-core" -desc "Cleans the dir and builds the gem" -task :prep => [:clean, :gemspec, :build] diff --git a/database_cleaner-core.gemspec b/database_cleaner-core.gemspec new file mode 100644 index 00000000..65b51195 --- /dev/null +++ b/database_cleaner-core.gemspec @@ -0,0 +1,30 @@ +lib = File.expand_path("../lib", __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require "database_cleaner/version" + +Gem::Specification.new do |spec| + spec.name = "database_cleaner-core" + spec.version = DatabaseCleaner::VERSION + spec.authors = ["Ben Mabey", "Ernesto Tagwerker"] + spec.email = ["ernesto@ombulabs.com"] + + spec.summary = "Strategies for cleaning databases. Can be used to ensure a clean slate for testing." + spec.description = "Strategies for cleaning databases. Can be used to ensure a clean slate for testing." + spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner" + spec.license = "MIT" + + spec.files = `git ls-files -z`.split("\x0").reject do |f| + f.match(%r{^(test|spec|features)/}) + end + spec.bindir = "exe" + spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] + + spec.add_development_dependency "rake" + spec.add_development_dependency "bundler" + spec.add_development_dependency 'guard-rspec' + spec.add_development_dependency "listen" + spec.add_development_dependency "rspec" + spec.add_development_dependency "cucumber" +end + diff --git a/database_cleaner.gemspec b/database_cleaner.gemspec index ad8f4d8c..e8c7a068 100644 --- a/database_cleaner.gemspec +++ b/database_cleaner.gemspec @@ -1,7 +1,4 @@ - -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "database_cleaner/version" +require_relative "./lib/database_cleaner/version" Gem::Specification.new do |spec| spec.name = "database_cleaner" @@ -14,17 +11,5 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner" spec.license = "MIT" - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_development_dependency "rake" - spec.add_development_dependency "bundler" - spec.add_development_dependency 'guard-rspec' - spec.add_development_dependency "listen" - spec.add_development_dependency "rspec" - spec.add_development_dependency "cucumber" + spec.add_dependency "database_cleaner-active_record" end diff --git a/lib/database_cleaner-core.rb b/lib/database_cleaner-core.rb new file mode 100644 index 00000000..9b65f62c --- /dev/null +++ b/lib/database_cleaner-core.rb @@ -0,0 +1 @@ +# empty file to avoid LoadError if someone requires database_cleaner-core directly From 00c212f822ef8bf2e458cdf0ecdb47d7ed41c55c Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Sun, 2 Feb 2020 15:21:45 -0800 Subject: [PATCH 09/21] RIP mysql1 adapter. --- lib/database_cleaner/spec/database_helper.rb | 2 +- spec/support/sample.config.yml | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/database_cleaner/spec/database_helper.rb b/lib/database_cleaner/spec/database_helper.rb index 536b9da4..b316c522 100644 --- a/lib/database_cleaner/spec/database_helper.rb +++ b/lib/database_cleaner/spec/database_helper.rb @@ -4,7 +4,7 @@ module DatabaseCleaner module Spec class DatabaseHelper < Struct.new(:db) def self.with_all_dbs &block - %w[mysql mysql2 sqlite3 postgres].map(&:to_sym).each do |db| + %w[mysql2 sqlite3 postgres].map(&:to_sym).each do |db| yield new(db) end end diff --git a/spec/support/sample.config.yml b/spec/support/sample.config.yml index 90132c0d..7cd47a3c 100644 --- a/spec/support/sample.config.yml +++ b/spec/support/sample.config.yml @@ -1,12 +1,3 @@ -mysql: - adapter: mysql - database: database_cleaner_test - username: root - password: - host: 127.0.0.1 - port: 3306 - encoding: utf8 - mysql2: adapter: mysql2 database: database_cleaner_test From 504b9de1c9d6dc8f5bf70789a3354e4e73de6714 Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Sun, 2 Feb 2020 15:40:22 -0800 Subject: [PATCH 10/21] modernize DC::Base specs. --- spec/database_cleaner/base_spec.rb | 55 +++++++++++------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/spec/database_cleaner/base_spec.rb b/spec/database_cleaner/base_spec.rb index 05b85605..a20df76f 100644 --- a/spec/database_cleaner/base_spec.rb +++ b/spec/database_cleaner/base_spec.rb @@ -2,24 +2,24 @@ module DatabaseCleaner RSpec.describe Base do describe "comparison" do it "should be equal if orm and connection are the same" do - one = DatabaseCleaner::Base.new(:active_record, :connection => :default) - two = DatabaseCleaner::Base.new(:active_record, :connection => :default) + one = Base.new(:active_record, connection: :default) + two = Base.new(:active_record, connection: :default) expect(one).to eq two expect(two).to eq one end it "should not be equal if orm are not the same" do - one = DatabaseCleaner::Base.new(:mongo_id, :connection => :default) - two = DatabaseCleaner::Base.new(:active_record, :connection => :default) + one = Base.new(:mongo_id, connection: :default) + two = Base.new(:active_record, connection: :default) expect(one).not_to eq two expect(two).not_to eq one end it "should not be equal if connection are not the same" do - one = DatabaseCleaner::Base.new(:active_record, :connection => :default) - two = DatabaseCleaner::Base.new(:active_record, :connection => :other) + one = Base.new(:active_record, connection: :default) + two = Base.new(:active_record, connection: :other) expect(one).not_to eq two expect(two).not_to eq one @@ -28,7 +28,9 @@ module DatabaseCleaner describe "initialization" do context "db specified" do - subject { ::DatabaseCleaner::Base.new(:active_record, :connection => :my_db) } + subject(:active_record_cleaner_with_specified_connection) do + Base.new(:active_record, connection: :my_db) + end it "should store db from :connection in params hash" do expect(subject.db).to eq :my_db @@ -37,12 +39,12 @@ module DatabaseCleaner describe "orm" do it "should store orm" do - cleaner = ::DatabaseCleaner::Base.new :a_orm + cleaner = Base.new :a_orm expect(cleaner.orm).to eq :a_orm end it "converts string to symbols" do - cleaner = ::DatabaseCleaner::Base.new "mongoid" + cleaner = Base.new "mongoid" expect(cleaner.orm).to eq :mongoid end @@ -73,6 +75,7 @@ module DatabaseCleaner context "when strategy doesn't support db specification" do let(:strategy) { double(respond_to?: false) } + before { subject.strategy = strategy } it "doesn't pass the default db down to it" do @@ -87,32 +90,14 @@ module DatabaseCleaner end describe "clean_with" do - let (:strategy) { double("strategy", clean: true) } - - before do - allow(subject).to receive(:create_strategy).with(anything).and_return(strategy) - end - end - - describe "clean_with" do - subject { described_class.new(:active_record) } + subject(:active_record_cleaner) { Base.new(:active_record) } let(:strategy_class) { Class.new } - - before do - orm_module = Module.new do - def self.available_strategies - %i[truncation transaction deletion] - end - end - stub_const "DatabaseCleaner::ActiveRecord", orm_module - stub_const "DatabaseCleaner::ActiveRecord::Truncation", strategy_class - end - let(:strategy) { double } + before { allow(strategy_class).to receive(:new).and_return(strategy) } before do - allow(strategy_class).to receive(:new).and_return(strategy) + stub_const "DatabaseCleaner::ActiveRecord::Truncation", strategy_class end it "should pass all arguments to strategy initializer" do @@ -133,7 +118,7 @@ def self.available_strategies end describe "strategy=" do - subject { described_class.new(:active_record) } + subject(:active_record_cleaner) { Base.new(:active_record) } let(:strategy_class) { Class.new } @@ -182,7 +167,7 @@ def self.available_strategies end describe "strategy" do - subject { described_class.new(:a_orm) } + subject(:invalid_cleaner) { Base.new(:a_orm) } it "returns a null strategy when strategy is not set and undetectable" do expect(subject.strategy).to be_a(DatabaseCleaner::NullStrategy) @@ -199,11 +184,9 @@ def self.available_strategies end describe "proxy methods" do - let (:strategy) { double("strategy") } + let(:strategy) { double(:strategy) } - before(:each) do - subject.strategy = strategy - end + before { subject.strategy = strategy } describe "start" do it "should proxy start to the strategy" do From e90c54b022a8d62457dcf1e2c75740cfe4b8999f Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Sun, 2 Feb 2020 15:53:23 -0800 Subject: [PATCH 11/21] bump latest release version on README. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index cbed4af9..1f0812d1 100644 --- a/README.markdown +++ b/README.markdown @@ -1,7 +1,7 @@ **If you're viewing this at https://github.com/DatabaseCleaner/database_cleaner, you're reading the documentation for the `master` branch. [View documentation for the latest release -(1.8.1).](https://github.com/DatabaseCleaner/database_cleaner/blob/v1.8.1/README.markdown)** +(1.8.2).](https://github.com/DatabaseCleaner/database_cleaner/blob/v1.8.2/README.markdown)** # Database Cleaner From 2181127b3e567a78c8db4c49fb4006563a23968b Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Mon, 3 Feb 2020 08:41:02 -0800 Subject: [PATCH 12/21] fix gem loading situation. --- database_cleaner-core.gemspec | 5 ++--- database_cleaner.gemspec | 3 +++ examples/features/support/env.rb | 5 ++--- features/support/env.rb | 2 +- lib/database_cleaner-core.rb | 2 +- lib/database_cleaner.rb | 34 +------------------------------- lib/database_cleaner/core.rb | 30 ++++++++++++++++++++++++++++ spec/spec_helper.rb | 2 +- 8 files changed, 41 insertions(+), 42 deletions(-) create mode 100644 lib/database_cleaner/core.rb diff --git a/database_cleaner-core.gemspec b/database_cleaner-core.gemspec index 65b51195..467710f0 100644 --- a/database_cleaner-core.gemspec +++ b/database_cleaner-core.gemspec @@ -14,8 +14,8 @@ Gem::Specification.new do |spec| spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end + f.match(%r{^(test|spec|features|examples)/}) + end - ["lib/database_cleaner.rb"] # should only exist in database_cleaner gem spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] @@ -27,4 +27,3 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rspec" spec.add_development_dependency "cucumber" end - diff --git a/database_cleaner.gemspec b/database_cleaner.gemspec index e8c7a068..f6b9a546 100644 --- a/database_cleaner.gemspec +++ b/database_cleaner.gemspec @@ -11,5 +11,8 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner" spec.license = "MIT" + spec.files = ["lib/database_cleaner.rb"] + spec.require_paths = ["lib"] + spec.add_dependency "database_cleaner-active_record" end diff --git a/examples/features/support/env.rb b/examples/features/support/env.rb index 2ca27d5d..bb6350f3 100644 --- a/examples/features/support/env.rb +++ b/examples/features/support/env.rb @@ -1,12 +1,11 @@ #Hilarious as it seems, this is necessary so bundle exec cucumber works for mongoid cukeage (I'm assuming mongomapper is automatically present because its a git repo) Object.send(:remove_const, 'MongoMapper') if defined?(::MongoMapper) -require 'rubygems' require 'bundler' Bundler.setup require 'rspec/expectations' -#require 'ruby-debug' +#require 'byebug' DB_DIR = "#{File.dirname(__FILE__)}/../../db" @@ -29,7 +28,7 @@ require "database_cleaner-#{orm.underscore}" else $:.unshift(File.dirname(__FILE__) + '/../../../lib') - require "database_cleaner" + require "database_cleaner-core" end if another_orm diff --git a/features/support/env.rb b/features/support/env.rb index b96546ab..ce8a338a 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,4 +1,4 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') -require 'database_cleaner' +require 'database_cleaner-core' require 'rspec/expectations' diff --git a/lib/database_cleaner-core.rb b/lib/database_cleaner-core.rb index 9b65f62c..f2e121a8 100644 --- a/lib/database_cleaner-core.rb +++ b/lib/database_cleaner-core.rb @@ -1 +1 @@ -# empty file to avoid LoadError if someone requires database_cleaner-core directly +require "database_cleaner/core" diff --git a/lib/database_cleaner.rb b/lib/database_cleaner.rb index 6210a7a3..484e99cb 100644 --- a/lib/database_cleaner.rb +++ b/lib/database_cleaner.rb @@ -1,34 +1,2 @@ -$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__))) -require 'database_cleaner/version' -require 'database_cleaner/configuration' -require 'database_cleaner/deprecation' -require 'forwardable' +require "database_cleaner/active_record" -module DatabaseCleaner - class << self - extend Forwardable - delegate [ - :[], - :app_root=, - :app_root, - :logger=, - :logger, - :cleaners, - :cleaners=, - :strategy=, - :orm=, - :start, - :clean, - :clean_with, - :cleaning, - ] => :configuration - - attr_accessor :allow_remote_database_url, :allow_production, :url_whitelist - - private - - def configuration - @configuration ||= Configuration.new - end - end -end diff --git a/lib/database_cleaner/core.rb b/lib/database_cleaner/core.rb new file mode 100644 index 00000000..925fc9ea --- /dev/null +++ b/lib/database_cleaner/core.rb @@ -0,0 +1,30 @@ +require 'database_cleaner/version' +require 'database_cleaner/configuration' +require 'database_cleaner/deprecation' +require 'forwardable' + +module DatabaseCleaner + class << self + extend Forwardable + delegate [ + :[], + :cleaners, + :cleaners=, + :strategy=, + :orm=, + :start, + :clean, + :clean_with, + :cleaning, + ] => :configuration + + attr_accessor :allow_remote_database_url, :allow_production, :url_whitelist + + private + + def configuration + @configuration ||= Configuration.new + end + end +end + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 362950c0..bbdceaa1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ require "bundler/setup" -require "database_cleaner" +require "database_cleaner-core" require "byebug" RSpec.configure do |config| From 9c8824198874ebbc7f9a41f14fa41e1b08514bdb Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Mon, 3 Feb 2020 09:23:03 -0800 Subject: [PATCH 13/21] remove extra line endings. --- Guardfile | 1 - Rakefile | 1 - bin/setup | 1 - examples/features/example_multiple_db.feature | 1 - features/cleaning_multiple_dbs.feature | 1 - lib/database_cleaner.rb | 1 - lib/database_cleaner/core.rb | 1 - lib/database_cleaner/deprecation.rb | 1 - spec/spec_helper.rb | 1 - spec/support/active_record_helper.rb | 1 - spec/support/data_mapper_helper.rb | 1 - spec/support/example.database.yml | 1 - spec/support/sample.config.yml | 1 - 13 files changed, 13 deletions(-) diff --git a/Guardfile b/Guardfile index 7b6ade9e..53503b58 100644 --- a/Guardfile +++ b/Guardfile @@ -3,4 +3,3 @@ guard :rspec, cmd: "bundle exec rspec" do watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch("spec/spec_helper.rb") { "spec" } end - diff --git a/Rakefile b/Rakefile index c6daf512..7efc8732 100644 --- a/Rakefile +++ b/Rakefile @@ -9,4 +9,3 @@ CLOBBER.include "pkg" require "bundler/gem_helper" Bundler::GemHelper.install_tasks name: :database_cleaner Bundler::GemHelper.install_tasks name: :"database_cleaner-core" - diff --git a/bin/setup b/bin/setup index 268b1b43..f1f2dd2d 100755 --- a/bin/setup +++ b/bin/setup @@ -5,4 +5,3 @@ set -vx bundle check || bundle install cp spec/support/sample.config.yml spec/support/config.yml - diff --git a/examples/features/example_multiple_db.feature b/examples/features/example_multiple_db.feature index d9bbb663..971511bf 100644 --- a/examples/features/example_multiple_db.feature +++ b/examples/features/example_multiple_db.feature @@ -20,4 +20,3 @@ Feature: example When I create a widget in another db Then I should see 0 widget in one db And I should see 1 widget in another db - diff --git a/features/cleaning_multiple_dbs.feature b/features/cleaning_multiple_dbs.feature index debbb0ad..d637a08e 100644 --- a/features/cleaning_multiple_dbs.feature +++ b/features/cleaning_multiple_dbs.feature @@ -38,4 +38,3 @@ Feature: multiple database cleaning | DataMapper | transaction | | ActiveRecord | transaction | | Sequel | transaction | - diff --git a/lib/database_cleaner.rb b/lib/database_cleaner.rb index 484e99cb..ad7a57b3 100644 --- a/lib/database_cleaner.rb +++ b/lib/database_cleaner.rb @@ -1,2 +1 @@ require "database_cleaner/active_record" - diff --git a/lib/database_cleaner/core.rb b/lib/database_cleaner/core.rb index 925fc9ea..03e12ee5 100644 --- a/lib/database_cleaner/core.rb +++ b/lib/database_cleaner/core.rb @@ -27,4 +27,3 @@ def configuration end end end - diff --git a/lib/database_cleaner/deprecation.rb b/lib/database_cleaner/deprecation.rb index 80533117..10f98d29 100644 --- a/lib/database_cleaner/deprecation.rb +++ b/lib/database_cleaner/deprecation.rb @@ -18,4 +18,3 @@ def deprecate method, message end end end - diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bbdceaa1..ddcb2a91 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,4 +12,3 @@ config.disable_monkey_patching! end - diff --git a/spec/support/active_record_helper.rb b/spec/support/active_record_helper.rb index 5041e974..3a592491 100644 --- a/spec/support/active_record_helper.rb +++ b/spec/support/active_record_helper.rb @@ -37,4 +37,3 @@ def patch_mysql_adapters ActiveRecord::ConnectionAdapters::Mysql2Adapter::NATIVE_DATABASE_TYPES[:primary_key] = primary_key_sql end end - diff --git a/spec/support/data_mapper_helper.rb b/spec/support/data_mapper_helper.rb index c0d94fc5..5df570e2 100644 --- a/spec/support/data_mapper_helper.rb +++ b/spec/support/data_mapper_helper.rb @@ -33,4 +33,3 @@ def establish_connection(config = default_config) DataMapper.setup(:default, config) end end - diff --git a/spec/support/example.database.yml b/spec/support/example.database.yml index bddb4dc2..e4574a93 100644 --- a/spec/support/example.database.yml +++ b/spec/support/example.database.yml @@ -1,3 +1,2 @@ my_db: database: <%= "ONE".downcase %> - diff --git a/spec/support/sample.config.yml b/spec/support/sample.config.yml index 7cd47a3c..bcbeb1de 100644 --- a/spec/support/sample.config.yml +++ b/spec/support/sample.config.yml @@ -22,4 +22,3 @@ sqlite3: pool: 5 timeout: 5000 encoding: utf8 - From 5ab507c613764c36b007a796d5195cc9b875090b Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Tue, 4 Feb 2020 07:45:54 -0800 Subject: [PATCH 14/21] reduce usage of bare subject on advice of rspec core team. --- spec/database_cleaner/base_spec.rb | 78 ++++++++------- spec/database_cleaner/configuration_spec.rb | 100 ++++++++++---------- spec/database_cleaner/null_strategy_spec.rb | 10 +- 3 files changed, 99 insertions(+), 89 deletions(-) diff --git a/spec/database_cleaner/base_spec.rb b/spec/database_cleaner/base_spec.rb index a20df76f..90069827 100644 --- a/spec/database_cleaner/base_spec.rb +++ b/spec/database_cleaner/base_spec.rb @@ -28,69 +28,72 @@ module DatabaseCleaner describe "initialization" do context "db specified" do - subject(:active_record_cleaner_with_specified_connection) do - Base.new(:active_record, connection: :my_db) - end + subject(:cleaner) { Base.new(:active_record, connection: :my_db) } it "should store db from :connection in params hash" do - expect(subject.db).to eq :my_db + expect(cleaner.db).to eq :my_db end end describe "orm" do it "should store orm" do - cleaner = Base.new :a_orm + cleaner = Base.new(:a_orm) expect(cleaner.orm).to eq :a_orm end it "converts string to symbols" do - cleaner = Base.new "mongoid" + cleaner = Base.new("mongoid") expect(cleaner.orm).to eq :mongoid end it "should default to nil" do - expect(subject.orm).to be_nil + cleaner = Base.new + expect(cleaner.orm).to be_nil end end end describe "db" do + subject(:cleaner) { Base.new } + it "should default to :default" do - expect(subject.db).to eq :default + expect(cleaner.db).to eq :default end it "should return any stored db value" do - subject.db = :test_db - expect(subject.db).to eq :test_db + cleaner.db = :test_db + expect(cleaner.db).to eq :test_db end end describe "db=" do + subject(:cleaner) { Base.new } + context "when strategy supports db specification" do it "should pass db down to its current strategy" do - expect(subject.strategy).to receive(:db=).with(:a_new_db) - subject.db = :a_new_db + expect(cleaner.strategy).to receive(:db=).with(:a_new_db) + cleaner.db = :a_new_db end end context "when strategy doesn't support db specification" do let(:strategy) { double(respond_to?: false) } - before { subject.strategy = strategy } + before { cleaner.strategy = strategy } it "doesn't pass the default db down to it" do expect(strategy).to_not receive(:db=) - subject.db = :default + cleaner.db = :default end it "should raise an argument error when db isn't default" do - expect { subject.db = :test }.to raise_error ArgumentError + expect { cleaner.db = :test }.to raise_error ArgumentError end end end describe "clean_with" do - subject(:active_record_cleaner) { Base.new(:active_record) } + subject(:cleaner) { Base.new(:active_record) } let(:strategy_class) { Class.new } let(:strategy) { double } @@ -103,22 +106,22 @@ module DatabaseCleaner it "should pass all arguments to strategy initializer" do expect(strategy_class).to receive(:new).with(:dollar, :amet, ipsum: "random").and_return(strategy) expect(strategy).to receive(:clean) - subject.clean_with :truncation, :dollar, :amet, ipsum: "random" + cleaner.clean_with :truncation, :dollar, :amet, ipsum: "random" end it "should invoke clean on the created strategy" do expect(strategy).to receive(:clean) - subject.clean_with :truncation + cleaner.clean_with :truncation end it "should return the created strategy" do expect(strategy).to receive(:clean) - expect(subject.clean_with(:truncation)).to eq strategy + expect(cleaner.clean_with(:truncation)).to eq strategy end end describe "strategy=" do - subject(:active_record_cleaner) { Base.new(:active_record) } + subject(:cleaner) { Base.new(:active_record) } let(:strategy_class) { Class.new } @@ -133,44 +136,44 @@ def self.available_strategies end it "should look up and create a the named strategy for the current ORM" do - subject.strategy = :truncation - expect(subject.strategy).to be_a(strategy_class) + cleaner.strategy = :truncation + expect(cleaner.strategy).to be_a(strategy_class) end it "should proxy params with symbolised strategies" do expect(strategy_class).to receive(:new).with(param: "one") - subject.strategy = :truncation, { param: "one" } + cleaner.strategy = :truncation, { param: "one" } end it "should accept strategy objects" do strategy = double - subject.strategy = strategy - expect(subject.strategy).to eq strategy + cleaner.strategy = strategy + expect(cleaner.strategy).to eq strategy end it "should raise argument error when params given with strategy object" do expect do - subject.strategy = double, { param: "one" } + cleaner.strategy = double, { param: "one" } end.to raise_error ArgumentError end it "should attempt to set strategy db" do strategy = double expect(strategy).to receive(:db=).with(:default) - subject.strategy = strategy + cleaner.strategy = strategy end it "raises UnknownStrategySpecified on a bad strategy, and lists available strategies" do - expect { subject.strategy = :horrible_plan }.to \ + expect { cleaner.strategy = :horrible_plan }.to \ raise_error(UnknownStrategySpecified, "The 'horrible_plan' strategy does not exist for the active_record ORM! Available strategies: truncation, transaction, deletion") end end describe "strategy" do - subject(:invalid_cleaner) { Base.new(:a_orm) } + subject(:cleaner) { Base.new(:a_orm) } it "returns a null strategy when strategy is not set and undetectable" do - expect(subject.strategy).to be_a(DatabaseCleaner::NullStrategy) + expect(cleaner.strategy).to be_a(DatabaseCleaner::NullStrategy) end end @@ -178,34 +181,37 @@ def self.available_strategies let(:mock_orm) { double("orm") } it "should return orm if orm set" do - subject.orm = :desired_orm - expect(subject.orm).to eq :desired_orm + cleaner = Base.new + cleaner.orm = :desired_orm + expect(cleaner.orm).to eq :desired_orm end end describe "proxy methods" do + subject(:cleaner) { Base.new } + let(:strategy) { double(:strategy) } - before { subject.strategy = strategy } + before { cleaner.strategy = strategy } describe "start" do it "should proxy start to the strategy" do expect(strategy).to receive(:start) - subject.start + cleaner.start end end describe "clean" do it "should proxy clean to the strategy" do expect(strategy).to receive(:clean) - subject.clean + cleaner.clean end end describe "cleaning" do it "should proxy cleaning to the strategy" do expect(strategy).to receive(:cleaning) - subject.cleaning { } + cleaner.cleaning { } end end end diff --git a/spec/database_cleaner/configuration_spec.rb b/spec/database_cleaner/configuration_spec.rb index f30bf7ba..f633b372 100644 --- a/spec/database_cleaner/configuration_spec.rb +++ b/spec/database_cleaner/configuration_spec.rb @@ -9,127 +9,129 @@ def stub_cleaners(array) end RSpec.describe DatabaseCleaner::Configuration do + subject(:config) { described_class.new } + context "orm specification" do it "should not accept unrecognised orms" do - expect { subject[nil] }.to raise_error(DatabaseCleaner::NoORMDetected) + expect { config[nil] }.to raise_error(DatabaseCleaner::NoORMDetected) end it "should accept :active_record" do - cleaner = subject[:active_record] + cleaner = config[:active_record] expect(cleaner).to be_a(DatabaseCleaner::Base) expect(cleaner.orm).to eq :active_record - expect(subject.cleaners.values).to eq [cleaner] + expect(config.cleaners.values).to eq [cleaner] end it "should accept :data_mapper" do - cleaner = subject[:data_mapper] + cleaner = config[:data_mapper] expect(cleaner).to be_a(DatabaseCleaner::Base) expect(cleaner.orm).to eq :data_mapper - expect(subject.cleaners.values).to eq [cleaner] + expect(config.cleaners.values).to eq [cleaner] end it "should accept :mongo_mapper" do - cleaner = subject[:mongo_mapper] + cleaner = config[:mongo_mapper] expect(cleaner).to be_a(DatabaseCleaner::Base) expect(cleaner.orm).to eq :mongo_mapper - expect(subject.cleaners.values).to eq [cleaner] + expect(config.cleaners.values).to eq [cleaner] end it "should accept :couch_potato" do - cleaner = subject[:couch_potato] + cleaner = config[:couch_potato] expect(cleaner).to be_a(DatabaseCleaner::Base) expect(cleaner.orm).to eq :couch_potato - expect(subject.cleaners.values).to eq [cleaner] + expect(config.cleaners.values).to eq [cleaner] end it "should accept :moped" do - cleaner = subject[:moped] + cleaner = config[:moped] expect(cleaner).to be_a(DatabaseCleaner::Base) expect(cleaner.orm).to eq :moped - expect(subject.cleaners.values).to eq [cleaner] + expect(config.cleaners.values).to eq [cleaner] end it 'accepts :ohm' do - cleaner = subject[:ohm] + cleaner = config[:ohm] expect(cleaner).to be_a(DatabaseCleaner::Base) expect(cleaner.orm).to eq :ohm - expect(subject.cleaners.values).to eq [cleaner] + expect(config.cleaners.values).to eq [cleaner] end it "should accept multiple orm's" do - cleaners = [subject[:couch_potato], subject[:data_mapper]] - expect(subject.cleaners.values.map(&:orm)).to eq [:couch_potato, :data_mapper] - expect(subject.cleaners.values).to eq cleaners + cleaners = [config[:couch_potato], config[:data_mapper]] + expect(config.cleaners.values.map(&:orm)).to eq [:couch_potato, :data_mapper] + expect(config.cleaners.values).to eq cleaners end it "should accept a connection parameter and store it" do - cleaner = subject[:active_record, connection: :first_connection] + cleaner = config[:active_record, connection: :first_connection] expect(cleaner).to be_a(DatabaseCleaner::Base) expect(cleaner.orm).to eq :active_record expect(cleaner.db).to eq :first_connection end it "should accept multiple connections for a single orm" do - subject[:data_mapper, connection: :first_db] - subject[:data_mapper, connection: :second_db] - expect(subject.cleaners.values.map(&:orm)).to eq [:data_mapper, :data_mapper] - expect(subject.cleaners.values.map(&:db)).to eq [:first_db, :second_db] + config[:data_mapper, connection: :first_db] + config[:data_mapper, connection: :second_db] + expect(config.cleaners.values.map(&:orm)).to eq [:data_mapper, :data_mapper] + expect(config.cleaners.values.map(&:db)).to eq [:first_db, :second_db] end it "should accept multiple connections and multiple orms" do - subject[:data_mapper, connection: :first_db ] - subject[:active_record, connection: :second_db] - subject[:active_record, connection: :first_db ] - subject[:data_mapper, connection: :second_db] - expect(subject.cleaners.values.map(&:orm)).to eq [:data_mapper, :active_record, :active_record, :data_mapper] - expect(subject.cleaners.values.map(&:db)).to eq [:first_db, :second_db, :first_db, :second_db] + config[:data_mapper, connection: :first_db ] + config[:active_record, connection: :second_db] + config[:active_record, connection: :first_db ] + config[:data_mapper, connection: :second_db] + expect(config.cleaners.values.map(&:orm)).to eq [:data_mapper, :active_record, :active_record, :data_mapper] + expect(config.cleaners.values.map(&:db)).to eq [:first_db, :second_db, :first_db, :second_db] end it "should retrieve a db rather than create a new one" do stub_const "DatabaseCleaner::ActiveRecord", Module.new stub_const "DatabaseCleaner::ActiveRecord::Truncation", Class.new - connection = subject[:active_record] - subject[:active_record].strategy = :truncation - expect(subject[:active_record]).to equal connection + connection = config[:active_record] + config[:active_record].strategy = :truncation + expect(config[:active_record]).to equal connection end end context "top level api methods" do context "single orm single connection" do - let(:connection) { subject[:active_record] } + let(:connection) { config[:active_record] } it "should proxy strategy=" do stratagem = double("stratagem") expect(connection).to receive(:strategy=).with(stratagem) - subject.strategy = stratagem + config.strategy = stratagem end it "should proxy orm=" do orm = double("orm") expect(connection).to receive(:orm=).with(orm) - subject.orm = orm + config.orm = orm end it "should proxy start" do expect(connection).to receive(:start) - subject.start + config.start end it "should proxy clean" do expect(connection).to receive(:clean) - subject.clean + config.clean end it 'should proxy cleaning' do expect(connection).to receive(:cleaning) - subject.cleaning { } + config.cleaning { } end it "should proxy clean_with" do stratagem = double("stratgem") expect(connection).to receive(:clean_with).with(stratagem, {}) - subject.clean_with stratagem, {} + config.clean_with stratagem, {} end end @@ -141,28 +143,28 @@ def stub_cleaners(array) let(:data_mapper) { double("data_mock") } before do - subject.stub_cleaners([active_record,data_mapper]) + config.stub_cleaners([active_record,data_mapper]) end it "should proxy orm to all cleaners" do expect(active_record).to receive(:orm=) expect(data_mapper).to receive(:orm=) - subject.orm = double("orm") + config.orm = double("orm") end it "should proxy start to all cleaners" do expect(active_record).to receive(:start) expect(data_mapper).to receive(:start) - subject.start + config.start end it "should proxy clean to all cleaners" do expect(active_record).to receive(:clean) expect(data_mapper).to receive(:clean) - subject.clean + config.clean end it "should proxy clean_with to all cleaners" do @@ -170,7 +172,7 @@ def stub_cleaners(array) expect(active_record).to receive(:clean_with).with(stratagem) expect(data_mapper).to receive(:clean_with).with(stratagem) - subject.clean_with stratagem + config.clean_with stratagem end it "should initiate cleaning on each connection, yield, and finish cleaning each connection" do @@ -187,7 +189,7 @@ def cleaning &block end yielded = false - subject.cleaning do + config.cleaning do expect(active_record.started).to eq(true) expect(data_mapper.started).to eq(true) expect(active_record.cleaned).to eq(nil) @@ -212,12 +214,12 @@ class FakeStrategy < Struct.new(:orm, :db, :strategy); end let(:data_mapper_1) { FakeStrategy.new(:data_mapper) } before do - subject.stub_cleaners [active_record_1,active_record_2,data_mapper_1] + config.stub_cleaners [active_record_1,active_record_2,data_mapper_1] end it "should proxy #orm= to all cleaners and remove duplicate cleaners" do - expect { subject.orm = :data_mapper } - .to change { subject.cleaners.values } + expect { config.orm = :data_mapper } + .to change { config.cleaners.values } .from([active_record_1,active_record_2,data_mapper_1]) .to([active_record_1,active_record_2]) end @@ -228,12 +230,12 @@ class FakeStrategy < Struct.new(:orm, :db, :strategy); end let(:active_record_2) { FakeStrategy.new(:active_record, :default, :transaction) } before do - subject.stub_cleaners [active_record_1,active_record_2] + config.stub_cleaners [active_record_1,active_record_2] end it "should proxy #strategy= to all cleaners and remove duplicate cleaners" do - expect { subject.strategy = :truncation } - .to change { subject.cleaners.values } + expect { config.strategy = :truncation } + .to change { config.cleaners.values } .from([active_record_1,active_record_2]) .to([active_record_1]) end diff --git a/spec/database_cleaner/null_strategy_spec.rb b/spec/database_cleaner/null_strategy_spec.rb index e11fa979..e4eea585 100644 --- a/spec/database_cleaner/null_strategy_spec.rb +++ b/spec/database_cleaner/null_strategy_spec.rb @@ -2,24 +2,26 @@ module DatabaseCleaner RSpec.describe NullStrategy do + subject(:strategy) { NullStrategy.new } + it 'responds to .start' do - expect { subject.start }.not_to raise_error + expect { strategy.start }.not_to raise_error end it 'responds to .clean' do - expect { subject.clean }.not_to raise_error + expect { strategy.clean }.not_to raise_error end describe '.cleaning' do it 'fails without a block' do - expect { subject.cleaning }.to raise_error(LocalJumpError) + expect { strategy.cleaning }.to raise_error(LocalJumpError) end it 'no-ops with a block' do effect = double expect(effect).to receive(:occur).once - subject.cleaning do + strategy.cleaning do effect.occur end end From 33b8bb86f0d42c27f564b5fee1360c4f971f0d8f Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Tue, 4 Feb 2020 11:45:32 -0800 Subject: [PATCH 15/21] mark certain adapters as discontinued. --- README.markdown | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/README.markdown b/README.markdown index 1f0812d1..839402be 100644 --- a/README.markdown +++ b/README.markdown @@ -36,35 +36,37 @@ group :test do gem 'database_cleaner-redis' end ``` - ## List of adapters Here is an overview of the databases and ORMs supported by each adapter: MySQL, PostgreSQL, SQLite, etc -* [database_cleaner-active_record](adapters/database_cleaner-active_record) -* [database_cleaner-sequel](adapters/database_cleaner-sequel) -* [database_cleaner-data_mapper](adapters/database_cleaner-data_mapper) - -CouchDB -* [database_cleaner-couch_potato](adapters/database_cleaner-couch_potato) + * [database_cleaner-active_record](https://github.com/DatabaseCleaner/database_cleaner-active_record) + * [database_cleaner-sequel](https://github.com/DatabaseCleaner/database_cleaner-sequel) MongoDB - * [database_cleaner-mongoid](adapters/database_cleaner-mongoid) - * [database_cleaner-mongo_mapper](adapters/database_cleaner-mongo_mapper) - * [database_cleaner-moped](adapters/database_cleaner-moped) - * [database_cleaner-mongo](adapters/database_cleaner-mongo) + * [database_cleaner-mongoid](https://github.com/DatabaseCleaner/database_cleaner-mongoid) Redis - * [database_cleaner-redis](adapters/database_cleaner-redis) + * [database_cleaner-redis](https://github.com/DatabaseCleaner/database_cleaner-redis) Neo4j - * [database_cleaner-neo4j](adapters/database_cleaner-neo4j) + * [database_cleaner-neo4j](https://github.com/DatabaseCleaner/database_cleaner-neo4j) More details on available configuration options can be found in the README for the specific adapter gem that you're using. For support or to discuss development please use the [Google Group](https://groups.google.com/group/database_cleaner). +### Discontinued adapters + +The following adapters have been discontinued, as their libraries appear to be unmaintained. Please let us know on the [Google Group](https://groups.google.com/group/database_cleaner) if you think one of these should be resurrected! + + * [database_cleaner-data_mapper](https://github.com/DatabaseCleaner/database_cleaner-data_mapper) + * [database_cleaner-couch_potato](https://github.com/DatabaseCleaner/database_cleaner-couch_potato) + * [database_cleaner-mongo_mapper](https://github.com/DatabaseCleaner/database_cleaner-mongo_mapper) + * [database_cleaner-moped](https://github.com/DatabaseCleaner/database_cleaner-moped) + * [database_cleaner-mongo](https://github.com/DatabaseCleaner/database_cleaner-mongo) + ## How to use ```ruby From 3f4d395d8d0cca5f66cd4b72373328ad66ac2706 Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Tue, 4 Feb 2020 12:09:07 -0800 Subject: [PATCH 16/21] use class_double for a bit of extra reliability. --- spec/database_cleaner/configuration_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/database_cleaner/configuration_spec.rb b/spec/database_cleaner/configuration_spec.rb index f633b372..9e385b11 100644 --- a/spec/database_cleaner/configuration_spec.rb +++ b/spec/database_cleaner/configuration_spec.rb @@ -88,12 +88,13 @@ def stub_cleaners(array) end it "should retrieve a db rather than create a new one" do - stub_const "DatabaseCleaner::ActiveRecord", Module.new - stub_const "DatabaseCleaner::ActiveRecord::Truncation", Class.new + class_double("DatabaseCleaner::ActiveRecord").as_stubbed_const + strategy_class = class_double("DatabaseCleaner::ActiveRecord::Truncation").as_stubbed_const + allow(strategy_class).to receive(:new) - connection = config[:active_record] + cleaner = config[:active_record] config[:active_record].strategy = :truncation - expect(config[:active_record]).to equal connection + expect(config[:active_record]).to equal cleaner end end From 422d7623a07a9dafc2ac91c611afcd66318fade5 Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Fri, 7 Feb 2020 10:49:50 -0800 Subject: [PATCH 17/21] add Micah Geisel to list of gem authors. --- database_cleaner.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database_cleaner.gemspec b/database_cleaner.gemspec index f6b9a546..54656061 100644 --- a/database_cleaner.gemspec +++ b/database_cleaner.gemspec @@ -3,7 +3,7 @@ require_relative "./lib/database_cleaner/version" Gem::Specification.new do |spec| spec.name = "database_cleaner" spec.version = DatabaseCleaner::VERSION - spec.authors = ["Ben Mabey", "Ernesto Tagwerker"] + spec.authors = ["Ben Mabey", "Ernesto Tagwerker", "Micah Geisel"] spec.email = ["ernesto@ombulabs.com"] spec.summary = "Strategies for cleaning databases. Can be used to ensure a clean slate for testing." From 7410730a282e4632291d18ec46fff2cc68e68384 Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Fri, 7 Feb 2020 11:10:26 -0800 Subject: [PATCH 18/21] test nil case for DC::Base#orm=. --- spec/database_cleaner/base_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/database_cleaner/base_spec.rb b/spec/database_cleaner/base_spec.rb index 90069827..4f292259 100644 --- a/spec/database_cleaner/base_spec.rb +++ b/spec/database_cleaner/base_spec.rb @@ -50,6 +50,12 @@ module DatabaseCleaner cleaner = Base.new expect(cleaner.orm).to be_nil end + + it "can handle being set to nil" do + cleaner = Base.new + cleaner.orm = nil + expect(cleaner.orm).to be_nil + end end end From aa52404dd5dc6883a419df878808c4b0d7f4cc5e Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Fri, 7 Feb 2020 11:14:05 -0800 Subject: [PATCH 19/21] core no longer knows what a valid adapter is. --- spec/database_cleaner/configuration_spec.rb | 35 --------------------- 1 file changed, 35 deletions(-) diff --git a/spec/database_cleaner/configuration_spec.rb b/spec/database_cleaner/configuration_spec.rb index 9e385b11..dfe06091 100644 --- a/spec/database_cleaner/configuration_spec.rb +++ b/spec/database_cleaner/configuration_spec.rb @@ -23,41 +23,6 @@ def stub_cleaners(array) expect(config.cleaners.values).to eq [cleaner] end - it "should accept :data_mapper" do - cleaner = config[:data_mapper] - expect(cleaner).to be_a(DatabaseCleaner::Base) - expect(cleaner.orm).to eq :data_mapper - expect(config.cleaners.values).to eq [cleaner] - end - - it "should accept :mongo_mapper" do - cleaner = config[:mongo_mapper] - expect(cleaner).to be_a(DatabaseCleaner::Base) - expect(cleaner.orm).to eq :mongo_mapper - expect(config.cleaners.values).to eq [cleaner] - end - - it "should accept :couch_potato" do - cleaner = config[:couch_potato] - expect(cleaner).to be_a(DatabaseCleaner::Base) - expect(cleaner.orm).to eq :couch_potato - expect(config.cleaners.values).to eq [cleaner] - end - - it "should accept :moped" do - cleaner = config[:moped] - expect(cleaner).to be_a(DatabaseCleaner::Base) - expect(cleaner.orm).to eq :moped - expect(config.cleaners.values).to eq [cleaner] - end - - it 'accepts :ohm' do - cleaner = config[:ohm] - expect(cleaner).to be_a(DatabaseCleaner::Base) - expect(cleaner.orm).to eq :ohm - expect(config.cleaners.values).to eq [cleaner] - end - it "should accept multiple orm's" do cleaners = [config[:couch_potato], config[:data_mapper]] expect(config.cleaners.values.map(&:orm)).to eq [:couch_potato, :data_mapper] From 59c54abacbaac9d7455c8a02938f7ea8b1e0d086 Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Fri, 14 Feb 2020 12:13:38 -0800 Subject: [PATCH 20/21] raise ArgumentError when DC[nil] is invoked or DC.orm = nil. --- lib/database_cleaner/base.rb | 9 +++++---- lib/database_cleaner/configuration.rb | 3 +-- spec/database_cleaner/base_spec.rb | 9 ++++----- spec/database_cleaner/configuration_spec.rb | 4 ++-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/database_cleaner/base.rb b/lib/database_cleaner/base.rb index f2aba04e..6ccfecaf 100644 --- a/lib/database_cleaner/base.rb +++ b/lib/database_cleaner/base.rb @@ -11,8 +11,8 @@ def <=>(other) [orm, db] <=> [other.orm, other.db] end - def initialize(desired_orm = nil, opts = {}) - self.orm = desired_orm + def initialize(orm = :null, opts = {}) + self.orm = orm self.db = opts[:connection] || opts[:model] if opts.has_key?(:connection) || opts.has_key?(:model) Safeguard.new.run end @@ -44,8 +44,9 @@ def strategy attr_reader :orm - def orm=(desired_orm) - @orm = desired_orm && desired_orm.to_sym + def orm= orm + raise ArgumentError if orm.nil? + @orm = orm.to_sym end extend Forwardable diff --git a/lib/database_cleaner/configuration.rb b/lib/database_cleaner/configuration.rb index bb32294c..d690ff4c 100644 --- a/lib/database_cleaner/configuration.rb +++ b/lib/database_cleaner/configuration.rb @@ -4,13 +4,12 @@ module DatabaseCleaner - class NoORMDetected < StandardError; end class UnknownStrategySpecified < ArgumentError; end class Cleaners < Hash # FIXME this method conflates creation with lookup... both a command and a query. yuck. def [](orm, opts = {}) - raise NoORMDetected unless orm + raise ArgumentError if orm.nil? fetch([orm, opts]) { add_cleaner(orm, opts) } end diff --git a/spec/database_cleaner/base_spec.rb b/spec/database_cleaner/base_spec.rb index 4f292259..79671396 100644 --- a/spec/database_cleaner/base_spec.rb +++ b/spec/database_cleaner/base_spec.rb @@ -46,15 +46,14 @@ module DatabaseCleaner expect(cleaner.orm).to eq :mongoid end - it "should default to nil" do + it "should default to :null" do cleaner = Base.new - expect(cleaner.orm).to be_nil + expect(cleaner.orm).to eq :null end - it "can handle being set to nil" do + it "raises ArgumentError when explicitly set to nil" do cleaner = Base.new - cleaner.orm = nil - expect(cleaner.orm).to be_nil + expect { cleaner.orm = nil }.to raise_error(ArgumentError) end end end diff --git a/spec/database_cleaner/configuration_spec.rb b/spec/database_cleaner/configuration_spec.rb index dfe06091..21a13d5c 100644 --- a/spec/database_cleaner/configuration_spec.rb +++ b/spec/database_cleaner/configuration_spec.rb @@ -12,8 +12,8 @@ def stub_cleaners(array) subject(:config) { described_class.new } context "orm specification" do - it "should not accept unrecognised orms" do - expect { config[nil] }.to raise_error(DatabaseCleaner::NoORMDetected) + it "should not accept nil orms" do + expect { config[nil] }.to raise_error(ArgumentError) end it "should accept :active_record" do From d59d53a43669df11958693fe97d6b808191f15d6 Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Fri, 14 Feb 2020 12:15:24 -0800 Subject: [PATCH 21/21] rm Gemfile.lock from version control. --- .gitignore | 1 + Gemfile.lock | 94 ---------------------------------------------------- 2 files changed, 1 insertion(+), 94 deletions(-) delete mode 100644 Gemfile.lock diff --git a/.gitignore b/.gitignore index e628ebe8..3c5ec79b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ examples/config/database.yml spec/support/config.yml tmp/* !tmp/.keep +Gemfile.lock .rbenv-version .rvmrc .ruby-version diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index a9761aab..00000000 --- a/Gemfile.lock +++ /dev/null @@ -1,94 +0,0 @@ -PATH - remote: . - specs: - database_cleaner-core (2.0.0.beta) - -GEM - remote: https://rubygems.org/ - specs: - builder (2.1.2) - byebug (10.0.2) - coderay (1.1.2) - cucumber (1.2.1) - builder (>= 2.1.2) - diff-lcs (>= 1.1.3) - gherkin (~> 2.11.0) - json (>= 1.4.6) - diff-lcs (1.3) - ffi (1.9.25) - ffi (1.9.25-java) - formatador (0.2.5) - gherkin (2.11.6) - json (>= 1.7.6) - gherkin (2.11.6-java) - json (>= 1.7.6) - guard (2.14.2) - formatador (>= 0.2.4) - listen (>= 2.7, < 4.0) - lumberjack (>= 1.0.12, < 2.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.9.12) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-rspec (4.7.3) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) - json (1.8.6) - json (1.8.6-java) - listen (3.0.8) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - lumberjack (1.0.13) - method_source (0.9.0) - nenv (0.3.0) - notiffany (0.1.1) - nenv (~> 0.1) - shellany (~> 0.0) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry (0.11.3-java) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - spoon (~> 0.0) - rake (11.1.2) - rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - shellany (0.0.1) - spoon (0.0.6) - ffi - thor (0.20.0) - -PLATFORMS - java - ruby - -DEPENDENCIES - bundler - byebug - cucumber - database_cleaner-core! - guard-rspec - listen - rake - rspec - -BUNDLED WITH - 1.17.3