database_cleaner 1.6.2 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Gemfile.lock +3 -3
- data/History.rdoc +23 -0
- data/README.markdown +24 -1
- data/VERSION.yml +2 -2
- data/lib/database_cleaner.rb +6 -2
- data/lib/database_cleaner/active_record/base.rb +1 -1
- data/lib/database_cleaner/active_record/deletion.rb +9 -7
- data/lib/database_cleaner/base.rb +2 -0
- data/lib/database_cleaner/safeguard.rb +72 -0
- metadata +6 -86
- data/examples/Gemfile +0 -1
- data/examples/Gemfile.lock +0 -1
- data/examples/config/database.yml.example +0 -8
- data/examples/config/redis.yml +0 -8
- data/examples/db/sqlite_databases_go_here +0 -0
- data/examples/features/example.feature +0 -11
- data/examples/features/example_multiple_db.feature +0 -23
- data/examples/features/example_multiple_orm.feature +0 -22
- data/examples/features/step_definitions/activerecord_steps.rb +0 -31
- data/examples/features/step_definitions/couchpotato_steps.rb +0 -31
- data/examples/features/step_definitions/datamapper_steps.rb +0 -37
- data/examples/features/step_definitions/mongoid_steps.rb +0 -23
- data/examples/features/step_definitions/mongomapper_steps.rb +0 -31
- data/examples/features/step_definitions/neo4j_steps.rb +0 -23
- data/examples/features/step_definitions/ohm_steps.rb +0 -31
- data/examples/features/step_definitions/redis_steps.rb +0 -31
- data/examples/features/step_definitions/translation_steps.rb +0 -55
- data/examples/features/support/env.rb +0 -61
- data/examples/lib/activerecord_models.rb +0 -41
- data/examples/lib/couchpotato_models.rb +0 -61
- data/examples/lib/datamapper_models.rb +0 -50
- data/examples/lib/mongoid_models.rb +0 -44
- data/examples/lib/mongomapper_models.rb +0 -51
- data/examples/lib/neo4j_models.rb +0 -17
- data/examples/lib/ohm_models.rb +0 -43
- data/examples/lib/redis_models.rb +0 -65
- data/examples/lib/sequel_models.rb +0 -9
- data/features/cleaning.feature +0 -30
- data/features/cleaning_default_strategy.feature +0 -23
- data/features/cleaning_multiple_dbs.feature +0 -22
- data/features/cleaning_multiple_orms.feature +0 -67
- data/features/step_definitions/database_cleaner_steps.rb +0 -33
- data/features/support/env.rb +0 -4
- data/features/support/feature_runner.rb +0 -39
- data/spec/database_cleaner/active_record/base_spec.rb +0 -188
- data/spec/database_cleaner/active_record/transaction_spec.rb +0 -176
- data/spec/database_cleaner/active_record/truncation/mysql2_spec.rb +0 -38
- data/spec/database_cleaner/active_record/truncation/mysql_spec.rb +0 -38
- data/spec/database_cleaner/active_record/truncation/postgresql_spec.rb +0 -75
- data/spec/database_cleaner/active_record/truncation/shared_fast_truncation.rb +0 -40
- data/spec/database_cleaner/active_record/truncation/sqlite3_spec.rb +0 -40
- data/spec/database_cleaner/active_record/truncation_spec.rb +0 -180
- data/spec/database_cleaner/base_spec.rb +0 -617
- data/spec/database_cleaner/configuration_spec.rb +0 -345
- data/spec/database_cleaner/couch_potato/truncation_spec.rb +0 -41
- data/spec/database_cleaner/data_mapper/base_spec.rb +0 -30
- data/spec/database_cleaner/data_mapper/transaction_spec.rb +0 -23
- data/spec/database_cleaner/data_mapper/truncation/sqlite3_spec.rb +0 -41
- data/spec/database_cleaner/data_mapper/truncation_spec.rb +0 -11
- data/spec/database_cleaner/generic/base_spec.rb +0 -61
- data/spec/database_cleaner/generic/truncation_spec.rb +0 -118
- data/spec/database_cleaner/mongo/mongo_examples.rb +0 -26
- data/spec/database_cleaner/mongo/truncation_spec.rb +0 -72
- data/spec/database_cleaner/mongo_mapper/base_spec.rb +0 -33
- data/spec/database_cleaner/mongo_mapper/mongo_examples.rb +0 -8
- data/spec/database_cleaner/mongo_mapper/truncation_spec.rb +0 -74
- data/spec/database_cleaner/moped/moped_examples.rb +0 -32
- data/spec/database_cleaner/moped/truncation_spec.rb +0 -80
- data/spec/database_cleaner/neo4j/base_spec.rb +0 -43
- data/spec/database_cleaner/neo4j/transaction_spec.rb +0 -25
- data/spec/database_cleaner/null_strategy_spec.rb +0 -28
- data/spec/database_cleaner/ohm/truncation_spec.rb +0 -70
- data/spec/database_cleaner/redis/base_spec.rb +0 -43
- data/spec/database_cleaner/redis/truncation_spec.rb +0 -63
- data/spec/database_cleaner/sequel/base_spec.rb +0 -32
- data/spec/database_cleaner/sequel/deletion_spec.rb +0 -58
- data/spec/database_cleaner/sequel/transaction_spec.rb +0 -21
- data/spec/database_cleaner/sequel/truncation/sqlite3_spec.rb +0 -0
- data/spec/database_cleaner/sequel/truncation_spec.rb +0 -182
- data/spec/database_cleaner/shared_strategy.rb +0 -15
- data/spec/rcov.opts +0 -1
- data/spec/spec_helper.rb +0 -21
- data/spec/support/active_record/database_setup.rb +0 -6
- data/spec/support/active_record/migrations/20150101010000_create_users.rb +0 -14
- data/spec/support/active_record/migrations/20150101020000_create_agents.rb +0 -14
- data/spec/support/active_record/mysql2_setup.rb +0 -39
- data/spec/support/active_record/mysql_setup.rb +0 -38
- data/spec/support/active_record/postgresql_setup.rb +0 -48
- data/spec/support/active_record/schema_setup.rb +0 -17
- data/spec/support/active_record/sqlite3_setup.rb +0 -40
- data/spec/support/data_mapper/schema_setup.rb +0 -15
- data/spec/support/data_mapper/sqlite3_setup.rb +0 -39
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
shared_examples_for "a generic strategy" do
|
|
2
|
-
it { should respond_to(:db) }
|
|
3
|
-
end
|
|
4
|
-
|
|
5
|
-
shared_examples_for "a generic truncation strategy" do
|
|
6
|
-
it { should respond_to(:start) }
|
|
7
|
-
it { should respond_to(:clean) }
|
|
8
|
-
it { should respond_to(:cleaning) }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
shared_examples_for "a generic transaction strategy" do
|
|
12
|
-
it { should respond_to(:start) }
|
|
13
|
-
it { should respond_to(:clean) }
|
|
14
|
-
it { should respond_to(:cleaning) }
|
|
15
|
-
end
|
data/spec/rcov.opts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--exclude "spec/*,vendor/*,examples/*,features/*,Users/*/.rvm/gems/*/gems/*"
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require "rubygems"
|
|
2
|
-
|
|
3
|
-
require "bundler"
|
|
4
|
-
Bundler.setup
|
|
5
|
-
|
|
6
|
-
require 'rspec/core'
|
|
7
|
-
require 'rspec/mocks'
|
|
8
|
-
|
|
9
|
-
#require 'active_record'
|
|
10
|
-
#require 'mongo_mapper'
|
|
11
|
-
|
|
12
|
-
$:.unshift(File.dirname(__FILE__))
|
|
13
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
|
14
|
-
|
|
15
|
-
require 'database_cleaner'
|
|
16
|
-
|
|
17
|
-
RSpec.configure do |config|
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
alias running lambda
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require 'support/active_record/database_setup'
|
|
2
|
-
require 'support/active_record/schema_setup'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module MySQL2Helper
|
|
6
|
-
puts "Active Record #{ActiveRecord::VERSION::STRING}, mysql2"
|
|
7
|
-
|
|
8
|
-
# require 'logger'
|
|
9
|
-
# ActiveRecord::Base.logger = Logger.new(STDERR)
|
|
10
|
-
|
|
11
|
-
def default_config
|
|
12
|
-
db_config['mysql2']
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def create_db
|
|
16
|
-
establish_connection(default_config.merge(:database => nil))
|
|
17
|
-
|
|
18
|
-
ActiveRecord::Base.connection.drop_database default_config['database'] rescue nil
|
|
19
|
-
ActiveRecord::Base.connection.create_database default_config['database']
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def establish_connection(config = default_config)
|
|
23
|
-
ActiveRecord::Base.establish_connection config
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def active_record_mysql2_setup
|
|
27
|
-
create_db
|
|
28
|
-
establish_connection
|
|
29
|
-
active_record_load_schema
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def active_record_mysql2_connection
|
|
33
|
-
ActiveRecord::Base.connection
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
RSpec.configure do |c|
|
|
38
|
-
c.include MySQL2Helper
|
|
39
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
require 'support/active_record/database_setup'
|
|
2
|
-
require 'support/active_record/schema_setup'
|
|
3
|
-
|
|
4
|
-
module MySQLHelper
|
|
5
|
-
puts "Active Record #{ActiveRecord::VERSION::STRING}, mysql"
|
|
6
|
-
|
|
7
|
-
# require 'logger'
|
|
8
|
-
# ActiveRecord::Base.logger = Logger.new(STDERR)
|
|
9
|
-
|
|
10
|
-
def default_config
|
|
11
|
-
db_config['mysql']
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def create_db
|
|
15
|
-
establish_connection(default_config.merge(:database => nil))
|
|
16
|
-
|
|
17
|
-
ActiveRecord::Base.connection.drop_database default_config['database'] rescue nil
|
|
18
|
-
ActiveRecord::Base.connection.create_database default_config['database']
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def establish_connection(config = default_config)
|
|
22
|
-
ActiveRecord::Base.establish_connection config
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def active_record_mysql_setup
|
|
26
|
-
create_db
|
|
27
|
-
establish_connection
|
|
28
|
-
active_record_load_schema
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def active_record_mysql_connection
|
|
32
|
-
ActiveRecord::Base.connection
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
RSpec.configure do |c|
|
|
37
|
-
c.include MySQLHelper
|
|
38
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
require 'support/active_record/database_setup'
|
|
2
|
-
require 'support/active_record/schema_setup'
|
|
3
|
-
|
|
4
|
-
module PostgreSQLHelper
|
|
5
|
-
puts "Active Record #{ActiveRecord::VERSION::STRING}, pg"
|
|
6
|
-
|
|
7
|
-
# ActiveRecord::Base.logger = Logger.new(STDERR)
|
|
8
|
-
|
|
9
|
-
def default_config
|
|
10
|
-
db_config['postgres']
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def create_db
|
|
14
|
-
@encoding = default_config['encoding'] || ENV['CHARSET'] || 'utf8'
|
|
15
|
-
begin
|
|
16
|
-
establish_connection(default_config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
|
|
17
|
-
ActiveRecord::Base.connection.drop_database(default_config['database']) rescue nil
|
|
18
|
-
ActiveRecord::Base.connection.create_database(default_config['database'], default_config.merge('encoding' => @encoding))
|
|
19
|
-
rescue Exception => e
|
|
20
|
-
$stderr.puts e, *(e.backtrace)
|
|
21
|
-
$stderr.puts "Couldn't create database for #{default_config.inspect}"
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def establish_connection(config = default_config)
|
|
26
|
-
ActiveRecord::Base.establish_connection(config)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def active_record_pg_setup
|
|
30
|
-
create_db
|
|
31
|
-
establish_connection
|
|
32
|
-
active_record_load_schema
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def active_record_pg_migrate
|
|
36
|
-
create_db
|
|
37
|
-
establish_connection
|
|
38
|
-
ActiveRecord::Migrator.migrate 'spec/support/active_record/migrations'
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def active_record_pg_connection
|
|
42
|
-
ActiveRecord::Base.connection
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
RSpec.configure do |c|
|
|
47
|
-
c.include PostgreSQLHelper
|
|
48
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
def active_record_load_schema
|
|
2
|
-
ActiveRecord::Schema.define do
|
|
3
|
-
create_table :users, :force => true do |t|
|
|
4
|
-
t.integer :name
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
create_table :agents, :id => false, :force => true do |t|
|
|
8
|
-
t.integer :name
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
class ::User < ActiveRecord::Base
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
class ::Agent < ActiveRecord::Base
|
|
17
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
require 'support/active_record/database_setup'
|
|
2
|
-
require 'support/active_record/schema_setup'
|
|
3
|
-
|
|
4
|
-
module SQLite3Helper
|
|
5
|
-
puts "Active Record #{ActiveRecord::VERSION::STRING}, sqlite3"
|
|
6
|
-
|
|
7
|
-
# ActiveRecord::Base.logger = Logger.new(STDERR)
|
|
8
|
-
|
|
9
|
-
def default_config
|
|
10
|
-
db_config['sqlite3']
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def create_db
|
|
14
|
-
@encoding = default_config['encoding'] || ENV['CHARSET'] || 'utf8'
|
|
15
|
-
begin
|
|
16
|
-
establish_connection(default_config.merge('database' => 'sqlite3', 'schema_search_path' => 'public'))
|
|
17
|
-
rescue Exception => e
|
|
18
|
-
$stderr.puts e, *(e.backtrace)
|
|
19
|
-
$stderr.puts "Couldn't create database for #{default_config.inspect}"
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def establish_connection(config = default_config)
|
|
24
|
-
ActiveRecord::Base.establish_connection(config)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def active_record_sqlite3_setup
|
|
28
|
-
create_db
|
|
29
|
-
establish_connection
|
|
30
|
-
active_record_load_schema
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def active_record_sqlite3_connection
|
|
34
|
-
ActiveRecord::Base.connection
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
RSpec.configure do |c|
|
|
39
|
-
c.include SQLite3Helper
|
|
40
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require 'support/active_record/database_setup'
|
|
2
|
-
require 'support/data_mapper/schema_setup'
|
|
3
|
-
|
|
4
|
-
module DataMapperSQLite3Helper
|
|
5
|
-
|
|
6
|
-
puts "DataMapper #{DataMapper::VERSION}, sqlite3"
|
|
7
|
-
|
|
8
|
-
def default_config
|
|
9
|
-
db_config['sqlite3']
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def create_db
|
|
13
|
-
@encoding = default_config['encoding'] || ENV['CHARSET'] || 'utf8'
|
|
14
|
-
begin
|
|
15
|
-
establish_connection(default_config.merge('database' => 'sqlite3', 'schema_search_path' => 'public'))
|
|
16
|
-
rescue Exception => e
|
|
17
|
-
$stderr.puts e, *(e.backtrace)
|
|
18
|
-
$stderr.puts "Couldn't create database for #{default_config.inspect}"
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def establish_connection(config = default_config)
|
|
23
|
-
DataMapper.setup(:default, config)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def data_mapper_sqlite3_setup
|
|
27
|
-
create_db
|
|
28
|
-
establish_connection
|
|
29
|
-
data_mapper_load_schema
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def data_mapper_sqlite3_connection
|
|
33
|
-
DataMapper.repository.adapter
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
RSpec.configure do |c|
|
|
38
|
-
c.include(DataMapperSQLite3Helper)
|
|
39
|
-
end
|