database_cleaner 1.7.0 → 1.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTE.markdown +1 -2
- data/Gemfile.lock +130 -91
- data/History.rdoc +45 -1
- data/README.markdown +74 -226
- data/Rakefile +12 -8
- data/adapters/database_cleaner-active_record/lib/database_cleaner-active_record.rb +1 -0
- data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record.rb +6 -0
- data/{lib → adapters/database_cleaner-active_record/lib}/database_cleaner/active_record/base.rb +13 -4
- data/{lib → adapters/database_cleaner-active_record/lib}/database_cleaner/active_record/deletion.rb +19 -19
- data/{lib → adapters/database_cleaner-active_record/lib}/database_cleaner/active_record/transaction.rb +0 -0
- data/{lib → adapters/database_cleaner-active_record/lib}/database_cleaner/active_record/truncation.rb +25 -20
- data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/version.rb +5 -0
- data/adapters/database_cleaner-couch_potato/lib/database_cleaner-couch_potato.rb +1 -0
- data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato.rb +11 -0
- data/{lib → adapters/database_cleaner-couch_potato/lib}/database_cleaner/couch_potato/base.rb +0 -0
- data/{lib → adapters/database_cleaner-couch_potato/lib}/database_cleaner/couch_potato/truncation.rb +0 -0
- data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/version.rb +5 -0
- data/adapters/database_cleaner-data_mapper/lib/database_cleaner-data_mapper.rb +1 -0
- data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper.rb +4 -0
- data/{lib → adapters/database_cleaner-data_mapper/lib}/database_cleaner/data_mapper/base.rb +4 -0
- data/{lib → adapters/database_cleaner-data_mapper/lib}/database_cleaner/data_mapper/transaction.rb +0 -0
- data/{lib → adapters/database_cleaner-data_mapper/lib}/database_cleaner/data_mapper/truncation.rb +4 -3
- data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/version.rb +5 -0
- data/adapters/database_cleaner-mongo/lib/database_cleaner-mongo.rb +1 -0
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo.rb +10 -0
- data/{lib → adapters/database_cleaner-mongo/lib}/database_cleaner/mongo/base.rb +0 -0
- data/{lib → adapters/database_cleaner-mongo/lib}/database_cleaner/mongo/truncation.rb +2 -0
- data/{lib → adapters/database_cleaner-mongo/lib}/database_cleaner/mongo/truncation_mixin.rb +0 -0
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/version.rb +5 -0
- data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner-mongo_mapper.rb +1 -0
- data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper.rb +4 -0
- data/{lib → adapters/database_cleaner-mongo_mapper/lib}/database_cleaner/mongo_mapper/base.rb +4 -0
- data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/truncation.rb +35 -0
- data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/version.rb +5 -0
- data/adapters/database_cleaner-mongoid/lib/database_cleaner-mongoid.rb +1 -0
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid.rb +10 -0
- data/{lib → adapters/database_cleaner-mongoid/lib}/database_cleaner/mongoid/base.rb +0 -0
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo1_truncation_mixin.rb +26 -0
- data/{lib/database_cleaner/mongo2/truncation_mixin.rb → adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo2_truncation_mixin.rb} +3 -4
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongoid_truncation_mixin.rb +65 -0
- data/{lib → adapters/database_cleaner-mongoid/lib}/database_cleaner/mongoid/truncation.rb +6 -6
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/version.rb +5 -0
- data/adapters/database_cleaner-moped/lib/database_cleaner-moped.rb +1 -0
- data/adapters/database_cleaner-moped/lib/database_cleaner/moped.rb +10 -0
- data/{lib → adapters/database_cleaner-moped/lib}/database_cleaner/moped/base.rb +1 -1
- data/{lib → adapters/database_cleaner-moped/lib}/database_cleaner/moped/truncation.rb +0 -0
- data/{lib → adapters/database_cleaner-moped/lib}/database_cleaner/moped/truncation_base.rb +4 -0
- data/adapters/database_cleaner-moped/lib/database_cleaner/moped/version.rb +5 -0
- data/adapters/database_cleaner-neo4j/lib/database_cleaner-neo4j.rb +1 -0
- data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j.rb +6 -0
- data/{lib → adapters/database_cleaner-neo4j/lib}/database_cleaner/neo4j/base.rb +4 -0
- data/{lib → adapters/database_cleaner-neo4j/lib}/database_cleaner/neo4j/deletion.rb +0 -0
- data/{lib → adapters/database_cleaner-neo4j/lib}/database_cleaner/neo4j/transaction.rb +0 -0
- data/{lib → adapters/database_cleaner-neo4j/lib}/database_cleaner/neo4j/truncation.rb +0 -0
- data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/version.rb +5 -0
- data/adapters/database_cleaner-ohm/lib/database_cleaner-ohm.rb +1 -0
- data/adapters/database_cleaner-ohm/lib/database_cleaner/ohm.rb +12 -0
- data/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/truncation.rb +24 -0
- data/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/version.rb +5 -0
- data/adapters/database_cleaner-redis/lib/database_cleaner-redis.rb +1 -0
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis.rb +4 -0
- data/{lib → adapters/database_cleaner-redis/lib}/database_cleaner/redis/base.rb +4 -0
- data/{lib → adapters/database_cleaner-redis/lib}/database_cleaner/redis/truncation.rb +0 -0
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis/version.rb +5 -0
- data/adapters/database_cleaner-sequel/lib/database_cleaner-sequel.rb +1 -0
- data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel.rb +6 -0
- data/{lib → adapters/database_cleaner-sequel/lib}/database_cleaner/sequel/base.rb +4 -0
- data/{lib → adapters/database_cleaner-sequel/lib}/database_cleaner/sequel/deletion.rb +0 -0
- data/{lib → adapters/database_cleaner-sequel/lib}/database_cleaner/sequel/transaction.rb +0 -0
- data/{lib → adapters/database_cleaner-sequel/lib}/database_cleaner/sequel/truncation.rb +16 -15
- data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/version.rb +5 -0
- data/lib/database_cleaner.rb +36 -1
- data/lib/database_cleaner/base.rb +92 -105
- data/lib/database_cleaner/configuration.rb +87 -83
- data/lib/database_cleaner/deprecation.rb +26 -0
- data/lib/database_cleaner/null_strategy.rb +6 -6
- data/lib/database_cleaner/orm_autodetector.rb +41 -0
- data/lib/database_cleaner/safeguard.rb +38 -3
- data/lib/database_cleaner/spec.rb +2 -0
- data/lib/database_cleaner/spec/database_helper.rb +82 -0
- data/lib/database_cleaner/spec/shared_examples.rb +15 -0
- data/lib/database_cleaner/version.rb +3 -0
- metadata +111 -44
- data/VERSION.yml +0 -4
- data/lib/database_cleaner/mongo2/base.rb +0 -16
- data/lib/database_cleaner/mongo_mapper/truncation.rb +0 -19
- data/lib/database_cleaner/ohm/truncation.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51b1c0f591c9266160e7ba246ab5a2e0edc88ff8e55aa10b205dad2371db9222
|
4
|
+
data.tar.gz: cbea6b1677f20cd1bc95eb0578df54933cdd329a034e67ef876b8bf9f1d406c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73ddb8b888360027d2f09c8c1f04a2e71605dad8b1166744df0b9b61c4c4ae382a5f43631857fe34ef8f899e7c0733351eddb014b6c729b8e394bd609ef484de
|
7
|
+
data.tar.gz: e3a654d8957c9f200750c244995e293a7a487c82f9885204cd6e29ac382daf1acc6101c751a25e42cdd418dd1afe6b9c90b46bb2386ec08573afa447dc468122
|
data/CONTRIBUTE.markdown
CHANGED
@@ -11,8 +11,7 @@ upstream:
|
|
11
11
|
## 2. Make sure the tests run fine
|
12
12
|
|
13
13
|
- `bundle install`
|
14
|
-
- Copy `
|
15
|
-
- Make sure to create the databases specified in `db/config.yml`
|
14
|
+
- Copy `spec/support/sample.config.yml` to `spec/support/config.yml` and edit it
|
16
15
|
- Run the tests with `bundle exec rspec`
|
17
16
|
|
18
17
|
Note that if you don't have all the supported databases installed and running,
|
data/Gemfile.lock
CHANGED
@@ -1,22 +1,51 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
database_cleaner (1.
|
4
|
+
database_cleaner (1.8.5)
|
5
|
+
|
6
|
+
PATH
|
7
|
+
remote: adapters
|
8
|
+
specs:
|
9
|
+
database_cleaner-active_record (1.8.0)
|
10
|
+
activerecord
|
11
|
+
database_cleaner (~> 1.8.0)
|
12
|
+
database_cleaner-couch_potato (1.8.0)
|
13
|
+
couch_potato
|
14
|
+
database_cleaner (~> 1.8.0)
|
15
|
+
database_cleaner-data_mapper (1.8.0)
|
16
|
+
database_cleaner (~> 1.8.0)
|
17
|
+
datamapper
|
18
|
+
dm-transactions
|
19
|
+
database_cleaner-mongo (1.8.0)
|
20
|
+
database_cleaner (~> 1.8.0)
|
21
|
+
mongo
|
22
|
+
database_cleaner-mongo_mapper (1.8.1)
|
23
|
+
database_cleaner (~> 1.8.0)
|
24
|
+
mongo_mapper
|
25
|
+
database_cleaner-mongoid (1.8.1)
|
26
|
+
database_cleaner (~> 1.8.0)
|
27
|
+
database_cleaner-mongo (~> 1.8.0)
|
28
|
+
mongoid
|
29
|
+
database_cleaner-moped (1.8.0)
|
30
|
+
database_cleaner (~> 1.8.0)
|
31
|
+
moped
|
32
|
+
database_cleaner-neo4j (1.8.0)
|
33
|
+
database_cleaner (~> 1.8.0)
|
34
|
+
neo4j-core
|
35
|
+
database_cleaner-ohm (1.8.1)
|
36
|
+
database_cleaner (~> 1.8.0)
|
37
|
+
database_cleaner-redis (~> 1.8.0)
|
38
|
+
ohm
|
39
|
+
database_cleaner-redis (1.8.0)
|
40
|
+
database_cleaner (~> 1.8.0)
|
41
|
+
redis
|
42
|
+
database_cleaner-sequel (1.8.0)
|
43
|
+
database_cleaner (~> 1.8.0)
|
44
|
+
sequel
|
5
45
|
|
6
46
|
GEM
|
7
47
|
remote: https://rubygems.org/
|
8
48
|
specs:
|
9
|
-
abstract (1.0.0)
|
10
|
-
actionpack (3.0.0)
|
11
|
-
activemodel (= 3.0.0)
|
12
|
-
activesupport (= 3.0.0)
|
13
|
-
builder (~> 2.1.2)
|
14
|
-
erubis (~> 2.6.6)
|
15
|
-
i18n (~> 0.4.1)
|
16
|
-
rack (~> 1.2.1)
|
17
|
-
rack-mount (~> 0.6.12)
|
18
|
-
rack-test (~> 0.5.4)
|
19
|
-
tzinfo (~> 0.3.23)
|
20
49
|
activemodel (3.0.0)
|
21
50
|
activesupport (= 3.0.0)
|
22
51
|
builder (~> 2.1.2)
|
@@ -38,20 +67,20 @@ GEM
|
|
38
67
|
bcrypt (>= 3.1.3)
|
39
68
|
bcrypt-ruby (3.1.5-java)
|
40
69
|
bcrypt (>= 3.1.3)
|
41
|
-
bson (1.
|
42
|
-
bson (1.
|
43
|
-
bson_ext (1.
|
44
|
-
bson (~> 1.
|
70
|
+
bson (1.12.5)
|
71
|
+
bson (1.12.5-java)
|
72
|
+
bson_ext (1.12.5)
|
73
|
+
bson (~> 1.12.5)
|
45
74
|
builder (2.1.2)
|
46
|
-
coderay (1.1.
|
75
|
+
coderay (1.1.2)
|
47
76
|
couch_potato (1.3.0)
|
48
77
|
activemodel
|
49
78
|
couchrest (~> 1.2.0)
|
50
79
|
json (~> 1.6)
|
51
|
-
couchrest (1.2.
|
52
|
-
mime-types (
|
53
|
-
multi_json (~> 1.0)
|
54
|
-
rest-client (~> 1.
|
80
|
+
couchrest (1.2.1)
|
81
|
+
mime-types (>= 1.15)
|
82
|
+
multi_json (~> 1.7, ~> 1.0)
|
83
|
+
rest-client (~> 1.8.0)
|
55
84
|
cucumber (1.2.1)
|
56
85
|
builder (>= 2.1.2)
|
57
86
|
diff-lcs (>= 1.1.3)
|
@@ -69,7 +98,7 @@ GEM
|
|
69
98
|
dm-transactions (~> 1.2.0)
|
70
99
|
dm-types (~> 1.2.0)
|
71
100
|
dm-validations (~> 1.2.0)
|
72
|
-
diff-lcs (1.
|
101
|
+
diff-lcs (1.3)
|
73
102
|
dm-aggregates (1.2.0)
|
74
103
|
dm-core (~> 1.2.0)
|
75
104
|
dm-constraints (1.2.0)
|
@@ -112,29 +141,36 @@ GEM
|
|
112
141
|
data_objects (= 0.10.14)
|
113
142
|
do_jdbc (= 0.10.14)
|
114
143
|
jdbc-sqlite3 (>= 3.5.8)
|
115
|
-
|
116
|
-
|
144
|
+
domain_name (0.5.20180417)
|
145
|
+
unf (>= 0.0.5, < 1.0.0)
|
117
146
|
faraday (0.9.0)
|
118
147
|
multipart-post (>= 1.2, < 3)
|
119
148
|
faraday_middleware (0.9.1)
|
120
149
|
faraday (>= 0.7.4, < 0.10)
|
121
150
|
fastercsv (1.5.5)
|
122
|
-
ffi (1.9.
|
123
|
-
ffi (1.9.
|
151
|
+
ffi (1.9.25)
|
152
|
+
ffi (1.9.25-java)
|
124
153
|
formatador (0.2.5)
|
125
154
|
gherkin (2.11.6)
|
126
155
|
json (>= 1.7.6)
|
127
156
|
gherkin (2.11.6-java)
|
128
157
|
json (>= 1.7.6)
|
129
|
-
guard (
|
158
|
+
guard (2.14.2)
|
130
159
|
formatador (>= 0.2.4)
|
131
|
-
listen (
|
132
|
-
lumberjack (>= 1.0.2)
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
160
|
+
listen (>= 2.7, < 4.0)
|
161
|
+
lumberjack (>= 1.0.12, < 2.0)
|
162
|
+
nenv (~> 0.1)
|
163
|
+
notiffany (~> 0.0)
|
164
|
+
pry (>= 0.9.12)
|
165
|
+
shellany (~> 0.0)
|
166
|
+
thor (>= 0.18.1)
|
167
|
+
guard-compat (1.2.1)
|
168
|
+
guard-rspec (4.7.3)
|
169
|
+
guard (~> 2.1)
|
170
|
+
guard-compat (~> 1.1)
|
171
|
+
rspec (>= 2.99.0, < 4.0)
|
172
|
+
http-cookie (1.0.3)
|
173
|
+
domain_name (~> 0.5)
|
138
174
|
httparty (0.13.3)
|
139
175
|
json (~> 1.8)
|
140
176
|
multi_xml (>= 0.5.2)
|
@@ -144,15 +180,14 @@ GEM
|
|
144
180
|
json (1.8.6)
|
145
181
|
json (1.8.6-java)
|
146
182
|
json_pure (1.8.1)
|
147
|
-
listen (
|
148
|
-
rb-fsevent (>= 0.9.
|
149
|
-
rb-inotify (>= 0.9)
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
bson (= 1.11.1)
|
183
|
+
listen (3.0.8)
|
184
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
185
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
186
|
+
lumberjack (1.0.13)
|
187
|
+
method_source (0.9.0)
|
188
|
+
mime-types (2.99.3)
|
189
|
+
mongo (1.12.5)
|
190
|
+
bson (= 1.12.5)
|
156
191
|
mongo_ext (0.19.3)
|
157
192
|
mongo_mapper (0.12.0)
|
158
193
|
activemodel (~> 3.0)
|
@@ -165,11 +200,12 @@ GEM
|
|
165
200
|
mongoid-tree (0.7.0)
|
166
201
|
mongoid (~> 2.0)
|
167
202
|
moped (1.5.2)
|
168
|
-
multi_json (1.
|
203
|
+
multi_json (1.13.1)
|
169
204
|
multi_xml (0.5.5)
|
170
205
|
multipart-post (2.0.0)
|
171
206
|
mysql (2.9.1)
|
172
207
|
mysql2 (0.3.18)
|
208
|
+
nenv (0.3.0)
|
173
209
|
neo4j-community (2.1.5)
|
174
210
|
neo4j-core (3.0.8)
|
175
211
|
activesupport
|
@@ -185,67 +221,57 @@ GEM
|
|
185
221
|
nest (1.1.2)
|
186
222
|
redis
|
187
223
|
net-http-persistent (2.9.4)
|
224
|
+
netrc (0.11.0)
|
225
|
+
notiffany (0.1.1)
|
226
|
+
nenv (~> 0.1)
|
227
|
+
shellany (~> 0.0)
|
188
228
|
ohm (0.1.5)
|
189
229
|
nest (~> 1.0)
|
190
230
|
os (0.9.6)
|
191
231
|
pg (0.18.2)
|
192
232
|
plucky (0.5.2)
|
193
233
|
mongo (~> 1.5)
|
194
|
-
pry (0.
|
234
|
+
pry (0.11.3)
|
195
235
|
coderay (~> 1.1.0)
|
196
|
-
method_source (~> 0.
|
197
|
-
|
198
|
-
pry (0.10.1-java)
|
236
|
+
method_source (~> 0.9.0)
|
237
|
+
pry (0.11.3-java)
|
199
238
|
coderay (~> 1.1.0)
|
200
|
-
method_source (~> 0.
|
201
|
-
slop (~> 3.4)
|
239
|
+
method_source (~> 0.9.0)
|
202
240
|
spoon (~> 0.0)
|
203
|
-
rack (1.2.8)
|
204
|
-
rack-mount (0.6.14)
|
205
|
-
rack (>= 1.0.0)
|
206
|
-
rack-test (0.5.7)
|
207
|
-
rack (>= 1.0)
|
208
|
-
railties (3.0.0)
|
209
|
-
actionpack (= 3.0.0)
|
210
|
-
activesupport (= 3.0.0)
|
211
|
-
rake (>= 0.8.4)
|
212
|
-
thor (~> 0.14.0)
|
213
241
|
rake (11.1.2)
|
214
|
-
rb-fsevent (0.
|
215
|
-
rb-inotify (0.9.
|
216
|
-
ffi (>= 0.5.0)
|
217
|
-
rb-kqueue (0.2.3)
|
218
|
-
ffi (>= 0.5.0)
|
219
|
-
rdoc (4.1.2)
|
220
|
-
json (~> 1.4)
|
242
|
+
rb-fsevent (0.10.3)
|
243
|
+
rb-inotify (0.9.10)
|
244
|
+
ffi (>= 0.5.0, < 2)
|
221
245
|
redis (3.1.0)
|
222
|
-
rest-client (1.
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
rspec-
|
228
|
-
rspec-
|
229
|
-
|
230
|
-
rspec-
|
231
|
-
|
232
|
-
rspec-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
rspec-expectations (~> 2.14.0)
|
240
|
-
rspec-mocks (~> 2.14.0)
|
246
|
+
rest-client (1.8.0)
|
247
|
+
http-cookie (>= 1.0.2, < 2.0)
|
248
|
+
mime-types (>= 1.16, < 3.0)
|
249
|
+
netrc (~> 0.7)
|
250
|
+
rspec (3.7.0)
|
251
|
+
rspec-core (~> 3.7.0)
|
252
|
+
rspec-expectations (~> 3.7.0)
|
253
|
+
rspec-mocks (~> 3.7.0)
|
254
|
+
rspec-core (3.7.1)
|
255
|
+
rspec-support (~> 3.7.0)
|
256
|
+
rspec-expectations (3.7.0)
|
257
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
258
|
+
rspec-support (~> 3.7.0)
|
259
|
+
rspec-mocks (3.7.0)
|
260
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
261
|
+
rspec-support (~> 3.7.0)
|
262
|
+
rspec-support (3.7.1)
|
241
263
|
sequel (3.21.0)
|
242
|
-
|
243
|
-
spoon (0.0.
|
264
|
+
shellany (0.0.1)
|
265
|
+
spoon (0.0.6)
|
244
266
|
ffi
|
245
267
|
sqlite3 (1.3.10)
|
246
268
|
stringex (1.5.1)
|
247
|
-
thor (0.
|
269
|
+
thor (0.20.0)
|
248
270
|
tzinfo (0.3.48)
|
271
|
+
unf (0.1.4)
|
272
|
+
unf_ext
|
273
|
+
unf (0.1.4-java)
|
274
|
+
unf_ext (0.0.7.5)
|
249
275
|
uuidtools (2.1.5)
|
250
276
|
zip (2.0.2)
|
251
277
|
|
@@ -261,11 +287,24 @@ DEPENDENCIES
|
|
261
287
|
couch_potato
|
262
288
|
cucumber
|
263
289
|
database_cleaner!
|
290
|
+
database_cleaner-active_record!
|
291
|
+
database_cleaner-couch_potato!
|
292
|
+
database_cleaner-data_mapper!
|
293
|
+
database_cleaner-mongo!
|
294
|
+
database_cleaner-mongo_mapper!
|
295
|
+
database_cleaner-mongoid!
|
296
|
+
database_cleaner-moped!
|
297
|
+
database_cleaner-neo4j!
|
298
|
+
database_cleaner-ohm!
|
299
|
+
database_cleaner-redis!
|
300
|
+
database_cleaner-sequel!
|
264
301
|
datamapper
|
265
302
|
dm-migrations
|
266
303
|
dm-sqlite-adapter
|
267
304
|
guard-rspec
|
268
305
|
json_pure
|
306
|
+
listen (~> 3.0.0)
|
307
|
+
mongo (~> 1.12.0)
|
269
308
|
mongo_ext
|
270
309
|
mongo_mapper
|
271
310
|
mongoid
|
@@ -277,10 +316,10 @@ DEPENDENCIES
|
|
277
316
|
ohm (~> 0.1.3)
|
278
317
|
pg
|
279
318
|
rake
|
280
|
-
rspec
|
319
|
+
rspec
|
281
320
|
sequel (~> 3.21.0)
|
282
321
|
sqlite3
|
283
322
|
tzinfo
|
284
323
|
|
285
324
|
BUNDLED WITH
|
286
|
-
1.
|
325
|
+
1.17.3
|
data/History.rdoc
CHANGED
@@ -1,9 +1,53 @@
|
|
1
1
|
== Development (master)
|
2
2
|
|
3
|
+
== 1.8.5 2020-05-04
|
4
|
+
|
5
|
+
=== Bug Fixes
|
6
|
+
* Fix :mongo strategy: https://github.com/DatabaseCleaner/database_cleaner/pull/645
|
7
|
+
|
8
|
+
== 1.8.4 2020-04-02
|
9
|
+
|
10
|
+
=== Bug Fixes
|
11
|
+
* Fix false positive deprecation warnings on Windows: https://github.com/DatabaseCleaner/database_cleaner/pull/633
|
12
|
+
|
13
|
+
== 1.8.3 2020-02-18
|
14
|
+
|
15
|
+
=== Bug Fixes
|
16
|
+
* Fix performance issue of DatabaseCleaner::Base#orm_module: https://github.com/DatabaseCleaner/database_cleaner/pull/625
|
17
|
+
|
18
|
+
== 1.8.2 2020-02-01
|
19
|
+
|
3
20
|
=== Bug Fixes
|
21
|
+
* Fix database_cleaner-ohm autodetected adapter loading: https://github.com/DatabaseCleaner/database_cleaner/pull/619
|
22
|
+
* Fix database_cleaner-mongo_mapper autodetected adapter loading: @botandrose
|
23
|
+
* Fix database_cleaner-mongoid autodetected adapter loading: https://github.com/DatabaseCleaner/database_cleaner/pull/617
|
24
|
+
* Exclude ar_internal_metadata from truncation on Rails 5: https://github.com/DatabaseCleaner/database_cleaner/pull/588
|
25
|
+
|
4
26
|
=== Changes
|
27
|
+
* Deprecate ohm adapter: https://github.com/DatabaseCleaner/database_cleaner/pull/619
|
28
|
+
|
29
|
+
== 1.8.1 2020-01-30
|
30
|
+
|
31
|
+
=== Bug Fixes
|
32
|
+
* Remove undeclared active_support dependency: https://github.com/DatabaseCleaner/database_cleaner/pull/612
|
5
33
|
|
6
|
-
== 1.
|
34
|
+
== 1.8.0 2020-01-29
|
35
|
+
|
36
|
+
=== Bug Fixes
|
37
|
+
* Fix MySQL deprecation warnings with Rails 5: https://github.com/DatabaseCleaner/database_cleaner/pull/574
|
38
|
+
* Fix MySQL truncation with `pre_count: true`: https://github.com/DatabaseCleaner/database_cleaner/pull/498
|
39
|
+
* Fix primary key sequence resetting in Sequel with Postgres and SQLite: https://github.com/DatabaseCleaner/database_cleaner/pull/538/files
|
40
|
+
* ActiveRecord truncation adapter doesn't work with Oracle: https://github.com/DatabaseCleaner/database_cleaner/pull/542
|
41
|
+
|
42
|
+
=== Changes
|
43
|
+
* Extract ORM adapters into gems: https://github.com/DatabaseCleaner/database_cleaner/pull/560
|
44
|
+
* Allow postgres:///dbname as a local url: https://github.com/DatabaseCleaner/database_cleaner/pull/569
|
45
|
+
* Add an optional URL whitelist safeguard: https://github.com/DatabaseCleaner/database_cleaner/pull/526
|
46
|
+
* Add `local` tld to safeguard check: https://github.com/DatabaseCleaner/database_cleaner/pull/547
|
47
|
+
* Speed up ActiveRecord deletion strategy: https://github.com/DatabaseCleaner/database_cleaner/pull/534
|
48
|
+
* Consider `sqlite:` database urls to be local: https://github.com/DatabaseCleaner/database_cleaner/pull/529
|
49
|
+
|
50
|
+
== 1.7.0 2018-04-19
|
7
51
|
|
8
52
|
=== Bug Fixes
|
9
53
|
* Remove unnecessary folders from gem: https://github.com/DatabaseCleaner/database_cleaner/pull/508
|
data/README.markdown
CHANGED
@@ -1,149 +1,76 @@
|
|
1
|
+
<!--
|
2
|
+
**If you're viewing this at https://github.com/DatabaseCleaner/database_cleaner,
|
3
|
+
you're reading the documentation for the `master` branch.
|
4
|
+
[View documentation for the latest release
|
5
|
+
(1.7.0).](https://github.com/DatabaseCleaner/database_cleaner/blob/v1.7.0/README.markdown)**
|
6
|
+
-->
|
1
7
|
# Database Cleaner
|
2
8
|
|
3
9
|
[![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner)
|
4
10
|
[![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner)
|
11
|
+
![Gem Version](https://badge.fury.io/rb/database_cleaner.svg)
|
12
|
+
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=database_cleaner&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=database_cleaner&package-manager=bundler&version-scheme=semver)
|
5
13
|
|
6
|
-
Database Cleaner is a set of strategies for cleaning your database in Ruby.
|
14
|
+
Database Cleaner is a set of gems containing strategies for cleaning your database in Ruby.
|
7
15
|
|
8
16
|
The original use case was to ensure a clean state during tests.
|
9
17
|
Each strategy is a small amount of code but is code that is usually needed in any ruby app that is testing with a database.
|
10
18
|
|
11
19
|
## Gem Setup
|
12
20
|
|
21
|
+
Instead of using the `database_cleaner` gem directly, each ORM has its own gem. Most projects will only need the `database_cleaner-active_record` gem:
|
22
|
+
|
13
23
|
```ruby
|
14
24
|
# Gemfile
|
15
25
|
group :test do
|
16
|
-
gem 'database_cleaner'
|
26
|
+
gem 'database_cleaner-active_record'
|
17
27
|
end
|
18
28
|
```
|
19
29
|
|
20
|
-
|
21
|
-
|
22
|
-
ActiveRecord, DataMapper, Sequel, MongoMapper, Mongoid, CouchPotato, Ohm and Redis are supported.
|
23
|
-
|
24
|
-
Here is an overview of the strategies supported for each library:
|
25
|
-
|
26
|
-
<table>
|
27
|
-
<tbody>
|
28
|
-
<tr>
|
29
|
-
<th>ORM</th>
|
30
|
-
<th>Truncation</th>
|
31
|
-
<th>Transaction</th>
|
32
|
-
<th>Deletion</th>
|
33
|
-
</tr>
|
34
|
-
<tr>
|
35
|
-
<td> ActiveRecord </td>
|
36
|
-
<td> Yes</td>
|
37
|
-
<td> <b>Yes</b></td>
|
38
|
-
<td> Yes</td>
|
39
|
-
</tr>
|
40
|
-
<tr>
|
41
|
-
<td> DataMapper</td>
|
42
|
-
<td> Yes</td>
|
43
|
-
<td> <b>Yes</b></td>
|
44
|
-
<td> No</td>
|
45
|
-
</tr>
|
46
|
-
<tr>
|
47
|
-
<td> CouchPotato</td>
|
48
|
-
<td> <b>Yes</b></td>
|
49
|
-
<td> No</td>
|
50
|
-
<td> No</td>
|
51
|
-
</tr>
|
52
|
-
<tr>
|
53
|
-
<td> MongoMapper</td>
|
54
|
-
<td> <b>Yes</b></td>
|
55
|
-
<td> No</td>
|
56
|
-
<td> No</td>
|
57
|
-
</tr>
|
58
|
-
<tr>
|
59
|
-
<td> Mongoid</td>
|
60
|
-
<td> <b>Yes</b></td>
|
61
|
-
<td> No</td>
|
62
|
-
<td> No</td>
|
63
|
-
</tr>
|
64
|
-
<tr>
|
65
|
-
<td> Sequel</td>
|
66
|
-
<td> <b>Yes</b></td>
|
67
|
-
<td> Yes</td>
|
68
|
-
<td> Yes</td>
|
69
|
-
</tr>
|
70
|
-
<tr>
|
71
|
-
<td>Redis</td>
|
72
|
-
<td><b>Yes</b></td>
|
73
|
-
<td>No</td>
|
74
|
-
<td>No</td>
|
75
|
-
</tr>
|
76
|
-
<tr>
|
77
|
-
<td>Ohm</td>
|
78
|
-
<td><b>Yes</b></td>
|
79
|
-
<td>No</td>
|
80
|
-
<td>No</td>
|
81
|
-
</tr>
|
82
|
-
<tr>
|
83
|
-
<td>Neo4j</td>
|
84
|
-
<td>Yes</td>
|
85
|
-
<td>Yes*</td>
|
86
|
-
<td>Yes*</td>
|
87
|
-
</tr>
|
88
|
-
</tbody>
|
89
|
-
</table>
|
90
|
-
|
91
|
-
\* Truncation and Deletion strategies for Neo4j will just delete all nodes and relationships from the database.
|
92
|
-
|
93
|
-
<table>
|
94
|
-
<tbody>
|
95
|
-
<tr>
|
96
|
-
<th>Driver</th>
|
97
|
-
<th>Truncation</th>
|
98
|
-
<th>Transaction</th>
|
99
|
-
<th>Deletion</th>
|
100
|
-
</tr>
|
101
|
-
<tr>
|
102
|
-
<td> Mongo</td>
|
103
|
-
<td> Yes</td>
|
104
|
-
<td> No</td>
|
105
|
-
<td> No</td>
|
106
|
-
</tr>
|
107
|
-
<tr>
|
108
|
-
<td> Moped</td>
|
109
|
-
<td> Yes</td>
|
110
|
-
<td> No</td>
|
111
|
-
<td> No</td>
|
112
|
-
</tr>
|
113
|
-
</tbody>
|
114
|
-
</table>
|
115
|
-
|
116
|
-
(Default strategy for each library is denoted in bold)
|
117
|
-
|
118
|
-
Database Cleaner also includes a `null` strategy (that does no cleaning at all) which can be used with any ORM library.
|
119
|
-
You can also explicitly use it by setting your strategy to `nil`.
|
30
|
+
If you are using multiple ORMs, just load multiple gems:
|
120
31
|
|
121
|
-
For support or to discuss development please use the [Google Group](http://groups.google.com/group/database_cleaner).
|
122
32
|
|
123
|
-
|
33
|
+
```ruby
|
34
|
+
# Gemfile
|
35
|
+
group :test do
|
36
|
+
gem 'database_cleaner-active_record'
|
37
|
+
gem 'database_cleaner-redis'
|
38
|
+
end
|
39
|
+
```
|
124
40
|
|
125
|
-
|
41
|
+
## List of adapters
|
126
42
|
|
127
|
-
|
43
|
+
Here is an overview of the databases and ORMs supported by each adapter:
|
128
44
|
|
129
|
-
|
45
|
+
MySQL, PostgreSQL, SQLite, etc
|
46
|
+
* [database_cleaner-active_record](adapters/database_cleaner-active_record)
|
47
|
+
* [database_cleaner-sequel](adapters/database_cleaner-sequel)
|
48
|
+
* [database_cleaner-data_mapper](adapters/database_cleaner-data_mapper)
|
130
49
|
|
131
|
-
|
50
|
+
CouchDB
|
51
|
+
* [database_cleaner-couch_potato](adapters/database_cleaner-couch_potato)
|
132
52
|
|
133
|
-
|
53
|
+
MongoDB
|
54
|
+
* [database_cleaner-mongoid](adapters/database_cleaner-mongoid)
|
55
|
+
* [database_cleaner-mongo_mapper](adapters/database_cleaner-mongo_mapper)
|
56
|
+
* [database_cleaner-moped](adapters/database_cleaner-moped)
|
57
|
+
* [database_cleaner-mongo](adapters/database_cleaner-mongo)
|
134
58
|
|
135
|
-
|
59
|
+
Redis
|
60
|
+
* [database_cleaner-redis](adapters/database_cleaner-redis)
|
61
|
+
* [database_cleaner-ohm](adapters/database_cleaner-ohm)
|
136
62
|
|
137
|
-
|
63
|
+
Neo4j
|
64
|
+
* [database_cleaner-neo4j](adapters/database_cleaner-neo4j)
|
138
65
|
|
139
|
-
|
66
|
+
More details on available configuration options can be found in the README for the specific adapter gem that you're using.
|
140
67
|
|
141
|
-
|
68
|
+
For support or to discuss development please use the [Google Group](https://groups.google.com/group/database_cleaner).
|
142
69
|
|
143
70
|
## How to use
|
144
71
|
|
145
72
|
```ruby
|
146
|
-
require 'database_cleaner'
|
73
|
+
require 'database_cleaner/active_record'
|
147
74
|
|
148
75
|
DatabaseCleaner.strategy = :truncation
|
149
76
|
|
@@ -161,15 +88,12 @@ DatabaseCleaner.strategy = :truncation, {:only => %w[widgets dogs some_other_tab
|
|
161
88
|
DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
|
162
89
|
```
|
163
90
|
|
164
|
-
With Ohm and Redis, `:only` and `:except` take a list of strings to be
|
165
|
-
passed to [`keys`](http://redis.io/commands/keys)).
|
166
|
-
|
167
91
|
(I should point out the truncation strategy will never truncate your schema_migrations table.)
|
168
92
|
|
169
93
|
Some strategies need to be started before tests are run (for example the `:transaction` strategy needs to know to open up a transaction). This can be accomplished by calling `DatabaseCleaner.start` at the beginning of the run, or by running the tests inside a block to `DatabaseCleaner.cleaning`. So you would have:
|
170
94
|
|
171
95
|
```ruby
|
172
|
-
require 'database_cleaner'
|
96
|
+
require 'database_cleaner/active_record'
|
173
97
|
|
174
98
|
DatabaseCleaner.strategy = :transaction
|
175
99
|
|
@@ -191,7 +115,7 @@ At times you may want to do a single clean with one strategy.
|
|
191
115
|
For example, you may want to start the process by truncating all the tables, but then use the faster transaction strategy the remaining time. To accomplish this you can say:
|
192
116
|
|
193
117
|
```ruby
|
194
|
-
require 'database_cleaner'
|
118
|
+
require 'database_cleaner/active_record'
|
195
119
|
|
196
120
|
DatabaseCleaner.clean_with :truncation
|
197
121
|
|
@@ -200,17 +124,26 @@ DatabaseCleaner.strategy = :transaction
|
|
200
124
|
# then make the DatabaseCleaner.start and DatabaseCleaner.clean calls appropriately
|
201
125
|
```
|
202
126
|
|
203
|
-
|
127
|
+
## What strategy is fastest?
|
128
|
+
|
129
|
+
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.
|
204
130
|
|
205
|
-
|
131
|
+
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.
|
206
132
|
|
207
|
-
|
208
|
-
* `: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`.
|
133
|
+
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).
|
209
134
|
|
210
|
-
|
135
|
+
An easier, but slower, solution is to use the `:truncation` or `:deletion` strategy.
|
211
136
|
|
212
|
-
|
137
|
+
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).
|
213
138
|
|
139
|
+
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.
|
140
|
+
|
141
|
+
If you are using ActiveRecord then take a look at the [additional options](#additional-activerecord-options-for-truncation) available for `:truncation`.
|
142
|
+
|
143
|
+
Database Cleaner also includes a `null` strategy (that does no cleaning at all) which can be used with any ORM library.
|
144
|
+
You can also explicitly use it by setting your strategy to `nil`.
|
145
|
+
|
146
|
+
## Test Framework Examples
|
214
147
|
|
215
148
|
### RSpec Example
|
216
149
|
|
@@ -345,14 +278,9 @@ If you're using Cucumber with Rails, just use the generator that ships with cucu
|
|
345
278
|
Otherwise, to add DatabaseCleaner to your project by hand, create a file `features/support/database_cleaner.rb` that looks like this:
|
346
279
|
|
347
280
|
```ruby
|
348
|
-
|
349
|
-
require 'database_cleaner'
|
350
|
-
require 'database_cleaner/cucumber'
|
281
|
+
require 'database_cleaner/active_record'
|
351
282
|
|
352
|
-
|
353
|
-
rescue NameError
|
354
|
-
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
|
355
|
-
end
|
283
|
+
DatabaseCleaner.strategy = :truncation
|
356
284
|
|
357
285
|
Around do |scenario, block|
|
358
286
|
DatabaseCleaner.cleaning(&block)
|
@@ -370,11 +298,14 @@ Sometimes you need to use multiple ORMs in your application.
|
|
370
298
|
You can use DatabaseCleaner to clean multiple ORMs, and multiple connections for those ORMs.
|
371
299
|
|
372
300
|
```ruby
|
373
|
-
|
301
|
+
require 'database_cleaner/active_record'
|
302
|
+
require 'database_cleaner/mongo_mapper'
|
303
|
+
|
304
|
+
# How to specify particular orms
|
374
305
|
DatabaseCleaner[:active_record].strategy = :transaction
|
375
306
|
DatabaseCleaner[:mongo_mapper].strategy = :truncation
|
376
307
|
|
377
|
-
#How to specify particular connections
|
308
|
+
# How to specify particular connections
|
378
309
|
DatabaseCleaner[:active_record, { :connection => :two }]
|
379
310
|
|
380
311
|
# You may also pass in the model directly:
|
@@ -383,68 +314,6 @@ DatabaseCleaner[:active_record, { :model => ModelWithDifferentConnection }]
|
|
383
314
|
|
384
315
|
Usage beyond that remains the same with `DatabaseCleaner.start` calling any setup on the different configured connections, and `DatabaseCleaner.clean` executing afterwards.
|
385
316
|
|
386
|
-
### Configuration options
|
387
|
-
|
388
|
-
<table>
|
389
|
-
<tbody>
|
390
|
-
<tr>
|
391
|
-
<th>ORM</th>
|
392
|
-
<th>How to access</th>
|
393
|
-
<th>Notes</th>
|
394
|
-
</tr>
|
395
|
-
<tr>
|
396
|
-
<td> Active Record </td>
|
397
|
-
<td> <code>DatabaseCleaner[:active_record]</code></td>
|
398
|
-
<td> Connection specified as <code>:symbol</code> keys, loaded from <code>config/database.yml</code>. You may also pass in the ActiveRecord model under the <code>:model</code> key.</td>
|
399
|
-
</tr>
|
400
|
-
<tr>
|
401
|
-
<td> Data Mapper</td>
|
402
|
-
<td> <code>DatabaseCleaner[:data_mapper]</code></td>
|
403
|
-
<td> Connection specified as <code>:symbol</code> keys, loaded via Datamapper repositories </td>
|
404
|
-
</tr>
|
405
|
-
<tr>
|
406
|
-
<td> Mongo Mapper</td>
|
407
|
-
<td> <code>DatabaseCleaner[:mongo_mapper]</code></td>
|
408
|
-
<td> Multiple connections not yet supported</td>
|
409
|
-
</tr>
|
410
|
-
<tr>
|
411
|
-
<td> Mongoid</td>
|
412
|
-
<td> <code>DatabaseCleaner[:mongoid]</code></td>
|
413
|
-
<td> Multiple databases supported for Mongoid 3. Specify <code>DatabaseCleaner[:mongoid, {:connection => :db_name}]</code> </td>
|
414
|
-
</tr>
|
415
|
-
<tr>
|
416
|
-
<td> Moped</td>
|
417
|
-
<td> <code>DatabaseCleaner[:moped]</code></td>
|
418
|
-
<td> It is necessary to configure database name with <code>DatabaseCleaner[:moped].db = db_name</code> otherwise name `default` will be used.</td>
|
419
|
-
</tr>
|
420
|
-
<tr>
|
421
|
-
<td> Couch Potato</td>
|
422
|
-
<td> <code>DatabaseCleaner[:couch_potato]</code></td>
|
423
|
-
<td> Multiple connections not yet supported</td>
|
424
|
-
</tr>
|
425
|
-
<tr>
|
426
|
-
<td> Sequel</td>
|
427
|
-
<td> <code>DatabaseCleaner[:sequel]</code></td>
|
428
|
-
<td> Multiple databases supported; specify <code>DatabaseCleaner[:sequel, {:connection => Sequel.connect(uri)}]</code></td>
|
429
|
-
</tr>
|
430
|
-
<tr>
|
431
|
-
<td>Redis</td>
|
432
|
-
<td><code>DatabaseCleaner[:redis]</code></td>
|
433
|
-
<td>Connection specified as Redis URI</td>
|
434
|
-
</tr>
|
435
|
-
<tr>
|
436
|
-
<td>Ohm</td>
|
437
|
-
<td><code>DatabaseCleaner[:ohm]</code></td>
|
438
|
-
<td>Connection specified as Redis URI</td>
|
439
|
-
</tr>
|
440
|
-
<tr>
|
441
|
-
<td>Neo4j</td>
|
442
|
-
<td><code>DatabaseCleaner[:neo4j]</code></td>
|
443
|
-
<td>Database type and path(URI) <code>DatabaseCleaner[:neo4j, connection: {type: :server_db, path: 'http://localhost:7475'}].</code></td>
|
444
|
-
</tr>
|
445
|
-
</tbody>
|
446
|
-
</table>
|
447
|
-
|
448
317
|
## Why?
|
449
318
|
|
450
319
|
One of my motivations for writing this library was to have an easy way to turn on what Rails calls "transactional_fixtures" in my non-rails ActiveRecord projects.
|
@@ -455,15 +324,15 @@ After copying and pasting code to do this several times I decided to package it
|
|
455
324
|
|
456
325
|
#### DatabaseCleaner is trying to use the wrong ORM
|
457
326
|
|
458
|
-
DatabaseCleaner has
|
327
|
+
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.
|
459
328
|
|
460
329
|
Since ActiveRecord is the most common ORM used that is the first one checked for.
|
461
330
|
|
462
|
-
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
|
331
|
+
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:
|
463
332
|
|
464
333
|
```ruby
|
465
|
-
#
|
466
|
-
|
334
|
+
# Gemfile
|
335
|
+
gem "database_cleaner-mongoid"
|
467
336
|
```
|
468
337
|
|
469
338
|
### STDERR is being flooded when using Postgres
|
@@ -485,29 +354,12 @@ test:
|
|
485
354
|
min_messages: WARNING
|
486
355
|
</pre>
|
487
356
|
|
488
|
-
### Nothing happens in JRuby with Sequel using transactions
|
489
|
-
|
490
|
-
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.
|
491
|
-
|
492
|
-
### Model fails to load with Neo4j using transactions
|
493
|
-
|
494
|
-
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.
|
495
|
-
|
496
|
-
Add to your rails_helper or spec_helper after requiring database_cleaner:
|
497
|
-
|
498
|
-
```ruby
|
499
|
-
require 'database_cleaner'
|
500
|
-
Dir["#{Rails.root}/app/models/**/*.rb"].each do |model|
|
501
|
-
load model
|
502
|
-
end
|
503
|
-
```
|
504
|
-
|
505
357
|
## Safeguards
|
506
358
|
|
507
359
|
DatabaseCleaner comes with safeguards against:
|
508
360
|
|
509
361
|
* Running in production (checking for `ENV`, `RACK_ENV`, and `RAILS_ENV`)
|
510
|
-
* Running against a remote database (checking for a `DATABASE_URL` that does not include `localhost`)
|
362
|
+
* Running against a remote database (checking for a `DATABASE_URL` that does not include `localhost`, `.local` or `127.0.0.1`)
|
511
363
|
|
512
364
|
Both safeguards can be disabled separately as follows.
|
513
365
|
|
@@ -525,17 +377,13 @@ DatabaseCleaner.allow_production = true
|
|
525
377
|
DatabaseCleaner.allow_remote_database_url = true
|
526
378
|
```
|
527
379
|
|
528
|
-
|
529
|
-
|
530
|
-
In rare cases DatabaseCleaner will encounter errors that it will log. By default it uses STDOUT set to the ERROR level but you can configure this to use whatever Logger you desire.
|
531
|
-
|
532
|
-
Here's an example of using the `Rails.logger` in `env.rb`:
|
380
|
+
In Ruby, a URL whitelist can be specified. When specified, DatabaseCleaner will only allow `DATABASE_URL` to be equal
|
381
|
+
to one of the values specified in the url whitelist like so:
|
533
382
|
|
534
383
|
```ruby
|
535
|
-
DatabaseCleaner.
|
384
|
+
DatabaseCleaner.url_whitelist = ['postgres://postgres@localhost', 'postgres://foo@bar']
|
536
385
|
```
|
537
386
|
|
538
|
-
|
539
387
|
## COPYRIGHT
|
540
388
|
|
541
|
-
|
389
|
+
See [LICENSE](LICENSE) for details.
|