database_cleaner 0.8.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/Gemfile.lock +150 -82
  2. data/History.txt +19 -1
  3. data/README.textile +61 -59
  4. data/Rakefile +7 -17
  5. data/VERSION.yml +3 -3
  6. data/examples/Gemfile +14 -20
  7. data/examples/Gemfile.lock +150 -82
  8. data/examples/features/step_definitions/translation_steps.rb +14 -14
  9. data/examples/features/support/env.rb +6 -2
  10. data/features/cleaning.feature +1 -1
  11. data/features/cleaning_default_strategy.feature +1 -1
  12. data/features/cleaning_multiple_dbs.feature +1 -2
  13. data/features/cleaning_multiple_orms.feature +7 -7
  14. data/features/support/env.rb +1 -1
  15. data/lib/database_cleaner/active_record/base.rb +26 -6
  16. data/lib/database_cleaner/active_record/deletion.rb +2 -2
  17. data/lib/database_cleaner/active_record/transaction.rb +9 -9
  18. data/lib/database_cleaner/active_record/truncation.rb +157 -50
  19. data/lib/database_cleaner/base.rb +2 -2
  20. data/lib/database_cleaner/configuration.rb +26 -3
  21. data/lib/database_cleaner/data_mapper/truncation.rb +2 -2
  22. data/lib/database_cleaner/generic/truncation.rb +7 -5
  23. data/lib/database_cleaner/mongo/base.rb +16 -0
  24. data/lib/database_cleaner/mongo/truncation.rb +9 -14
  25. data/lib/database_cleaner/mongo/truncation_mixin.rb +22 -0
  26. data/lib/database_cleaner/mongo_mapper/truncation.rb +2 -2
  27. data/lib/database_cleaner/mongoid/truncation.rb +2 -2
  28. data/lib/database_cleaner/moped/truncation.rb +6 -2
  29. data/lib/database_cleaner/sequel/truncation.rb +6 -6
  30. data/spec/database_cleaner/active_record/base_spec.rb +27 -15
  31. data/spec/database_cleaner/active_record/truncation/mysql2_spec.rb +40 -0
  32. data/spec/database_cleaner/active_record/truncation/mysql_spec.rb +40 -0
  33. data/spec/database_cleaner/active_record/truncation/postgresql_spec.rb +48 -0
  34. data/spec/database_cleaner/active_record/truncation/shared_fast_truncation.rb +40 -0
  35. data/spec/database_cleaner/active_record/truncation_spec.rb +102 -33
  36. data/spec/database_cleaner/base_spec.rb +14 -14
  37. data/spec/database_cleaner/configuration_spec.rb +15 -10
  38. data/spec/database_cleaner/data_mapper/base_spec.rb +1 -1
  39. data/spec/database_cleaner/data_mapper/transaction_spec.rb +1 -1
  40. data/spec/database_cleaner/data_mapper/truncation_spec.rb +1 -1
  41. data/spec/database_cleaner/generic/base_spec.rb +1 -1
  42. data/spec/database_cleaner/generic/truncation_spec.rb +35 -5
  43. data/spec/database_cleaner/mongo/mongo_examples.rb +26 -0
  44. data/spec/database_cleaner/mongo/truncation_spec.rb +72 -0
  45. data/spec/database_cleaner/mongo_mapper/base_spec.rb +1 -1
  46. data/spec/database_cleaner/sequel/base_spec.rb +1 -1
  47. data/spec/database_cleaner/sequel/transaction_spec.rb +1 -1
  48. data/spec/database_cleaner/sequel/truncation_spec.rb +1 -1
  49. data/spec/database_cleaner/{shared_strategy_spec.rb → shared_strategy.rb} +0 -0
  50. data/spec/spec_helper.rb +6 -4
  51. data/spec/support/active_record/database_setup.rb +4 -0
  52. data/spec/support/active_record/mysql2_setup.rb +38 -0
  53. data/spec/support/active_record/mysql_setup.rb +38 -0
  54. data/spec/support/active_record/postgresql_setup.rb +41 -0
  55. data/spec/support/active_record/schema_setup.rb +10 -0
  56. metadata +313 -46
  57. data/spec/spec.opts +0 -7
data/Rakefile CHANGED
@@ -19,25 +19,15 @@ rescue LoadError
19
19
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
20
20
  end
21
21
 
22
- require 'rake/rdoctask'
23
- Rake::RDocTask.new do |rdoc|
24
- rdoc.rdoc_dir = 'rdoc'
25
- rdoc.title = 'database_cleaner'
26
- rdoc.options << '--line-numbers' << '--inline-source'
27
- rdoc.rdoc_files.include('README*')
28
- rdoc.rdoc_files.include('lib/**/*.rb')
22
+ require 'rspec/core'
23
+ require 'rspec/core/rake_task'
24
+ RSpec::Core::RakeTask.new(:spec) do |spec|
25
+ spec.pattern = FileList['spec/**/*_spec.rb']
29
26
  end
30
27
 
31
- require 'spec/rake/spectask'
32
- Spec::Rake::SpecTask.new(:spec) do |t|
33
- t.libs << 'lib' << 'spec'
34
- t.spec_files = FileList['spec/**/*_spec.rb']
35
- end
36
-
37
- Spec::Rake::SpecTask.new(:rcov) do |t|
38
- t.libs << 'lib' << 'spec'
39
- t.spec_files = FileList['spec/**/*_spec.rb']
40
- t.rcov = true
28
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
29
+ spec.pattern = 'spec/**/*_spec.rb'
30
+ spec.rcov = true
41
31
  end
42
32
 
43
33
  begin
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :major: 0
2
+ :minor: 9
3
3
  :build:
4
- :minor: 8
5
- :patch: 0
4
+ :patch: 1
5
+ :major: 0
data/examples/Gemfile CHANGED
@@ -1,18 +1,5 @@
1
1
  source "http://rubygems.org"
2
- # group :development do
3
- # # gem "mysql"
4
- # # gem "json_pure", "1.4.3"
5
- #
6
- #
7
- # # gem "datamapper", "1.0.0"
8
- # # gem "dm-migrations", "1.0.0"
9
- # # gem "dm-sqlite-adapter", "1.0.0"
10
- #
11
- # # mongo requirements
12
- # # gem "mongo", "1.0.1"
13
- # # gem "mongo_ext", "0.19.3"
14
- # # gem "bson_ext", "1.0.1"
15
- # end
2
+ # TODO: move these to the gemspec...
16
3
 
17
4
  group :development do
18
5
  gem "rake"
@@ -24,20 +11,27 @@ group :development do
24
11
  gem "json_pure"
25
12
 
26
13
  #ORM's
27
- gem "activerecord", "2.3.8"
14
+ gem "activerecord"
28
15
  gem "datamapper", "1.0.0"
29
16
  gem "dm-migrations", "1.0.0"
30
17
  gem "dm-sqlite-adapter", "1.0.0"
31
- gem "mongoid", "1.9.1"
32
- gem "tzinfo", "0.3.22"
33
- gem "mongo_mapper", "0.8.2"
34
- gem "couch_potato", "0.3.0"
18
+ gem "mongoid"
19
+ gem "tzinfo"
20
+ gem "mongo_ext"
21
+ gem "bson_ext"
22
+ gem "mongo_mapper"
23
+ gem "couch_potato"
35
24
  gem "sequel", "~>3.21.0"
36
25
  #gem "ibm_db" # I don't want to add this dependency, even as a dev one since it requires DB2 to be installed
26
+ gem 'mysql'
27
+ gem 'mysql2'
28
+ gem 'pg'
29
+
30
+ gem 'guard-rspec'
37
31
  end
38
32
 
39
33
  group :test do
40
- gem "rspec"
34
+ gem "rspec-rails"
41
35
  gem "rspactor"
42
36
  gem "rcov"
43
37
  gem "ZenTest"
@@ -1,28 +1,49 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- ZenTest (4.3.3)
5
- activerecord (2.3.8)
6
- activesupport (= 2.3.8)
7
- activesupport (2.3.8)
8
- addressable (2.2.0)
9
- bson (1.0.4)
10
- builder (2.1.2)
11
- columnize (0.3.1)
12
- couch_potato (0.3.0)
13
- couchrest (>= 0.24)
4
+ ZenTest (4.8.1)
5
+ actionpack (3.2.6)
6
+ activemodel (= 3.2.6)
7
+ activesupport (= 3.2.6)
8
+ builder (~> 3.0.0)
9
+ erubis (~> 2.7.0)
10
+ journey (~> 1.0.1)
11
+ rack (~> 1.4.0)
12
+ rack-cache (~> 1.2)
13
+ rack-test (~> 0.6.1)
14
+ sprockets (~> 2.1.3)
15
+ activemodel (3.2.6)
16
+ activesupport (= 3.2.6)
17
+ builder (~> 3.0.0)
18
+ activerecord (3.2.6)
19
+ activemodel (= 3.2.6)
20
+ activesupport (= 3.2.6)
21
+ arel (~> 3.0.2)
22
+ tzinfo (~> 0.3.29)
23
+ activesupport (3.2.6)
24
+ i18n (~> 0.6)
25
+ multi_json (~> 1.0)
26
+ addressable (2.2.8)
27
+ arel (3.0.2)
28
+ bson (1.6.4)
29
+ bson_ext (1.6.4)
30
+ bson (~> 1.6.4)
31
+ builder (3.0.0)
32
+ columnize (0.3.6)
33
+ couch_potato (0.5.7)
34
+ activemodel
35
+ couchrest (>= 1.0.1)
14
36
  json
15
37
  couchrest (1.0.1)
16
38
  json (>= 1.4.6)
17
39
  mime-types (>= 1.15)
18
40
  rest-client (>= 1.5.1)
19
- cucumber (0.8.5)
20
- builder (~> 2.1.2)
21
- diff-lcs (~> 1.1.2)
22
- gherkin (~> 2.1.4)
23
- json_pure (~> 1.4.3)
24
- term-ansicolor (~> 1.0.4)
25
- data_objects (0.10.2)
41
+ cucumber (1.2.1)
42
+ builder (>= 2.1.2)
43
+ diff-lcs (>= 1.1.3)
44
+ gherkin (~> 2.11.0)
45
+ json (>= 1.4.6)
46
+ data_objects (0.10.8)
26
47
  addressable (~> 2.1)
27
48
  datamapper (1.0.0)
28
49
  dm-aggregates (= 1.0.0)
@@ -35,7 +56,7 @@ GEM
35
56
  dm-transactions (= 1.0.0)
36
57
  dm-types (= 1.0.0)
37
58
  dm-validations (= 1.0.0)
38
- diff-lcs (1.1.2)
59
+ diff-lcs (1.1.3)
39
60
  dm-aggregates (1.0.0)
40
61
  dm-core (~> 1.0.0)
41
62
  dm-constraints (1.0.0)
@@ -68,96 +89,143 @@ GEM
68
89
  uuidtools (~> 2.1.1)
69
90
  dm-validations (1.0.0)
70
91
  dm-core (~> 1.0.0)
71
- do_sqlite3 (0.10.2)
72
- data_objects (= 0.10.2)
73
- durran-validatable (2.0.1)
92
+ do_sqlite3 (0.10.8)
93
+ data_objects (= 0.10.8)
94
+ erubis (2.7.0)
74
95
  extlib (0.9.15)
75
- fastercsv (1.5.3)
76
- ffi (0.6.3)
77
- rake (>= 0.8.7)
78
- gemcutter (0.6.1)
79
- gherkin (2.1.5)
80
- trollop (~> 1.16.2)
96
+ fastercsv (1.5.5)
97
+ ffi (1.1.4)
98
+ gherkin (2.11.1)
99
+ json (>= 1.4.6)
81
100
  git (1.2.5)
82
- growl (1.0.3)
83
- jeweler (1.4.0)
84
- gemcutter (>= 0.1.0)
101
+ guard (1.3.0)
102
+ listen (>= 0.4.2)
103
+ thor (>= 0.14.6)
104
+ guard-rspec (1.2.1)
105
+ guard (>= 1.1)
106
+ hike (1.2.1)
107
+ i18n (0.6.0)
108
+ jeweler (1.8.4)
109
+ bundler (~> 1.0)
85
110
  git (>= 1.2.5)
86
- rubyforge (>= 2.0.0)
87
- jnunemaker-validatable (1.8.4)
88
- activesupport (>= 2.3.4)
89
- json (1.4.6)
111
+ rake
112
+ rdoc
113
+ journey (1.0.4)
114
+ json (1.7.3)
90
115
  json_pure (1.4.6)
91
- libnotify (0.2.0)
92
- ffi (>= 0.6.2)
93
- linecache (0.43)
94
- mime-types (1.16)
95
- mongo (1.0.7)
96
- bson (>= 1.0.4)
97
- mongo_mapper (0.8.2)
98
- activesupport (>= 2.3.4)
99
- jnunemaker-validatable (~> 1.8.4)
100
- plucky (~> 0.3.1)
101
- mongoid (1.9.1)
102
- activesupport (<= 3.0.0)
103
- bson (~> 1.0.1)
104
- durran-validatable (>= 2.0.1)
105
- mongo (~> 1.0.1)
106
- will_paginate (< 2.9)
107
- plucky (0.3.4)
108
- mongo (~> 1.0.7)
109
- rake (0.8.7)
110
- rb-inotify (0.8.1)
116
+ linecache (0.46)
117
+ rbx-require-relative (> 0.0.4)
118
+ listen (0.4.7)
119
+ rb-fchange (~> 0.0.5)
120
+ rb-fsevent (~> 0.9.1)
121
+ rb-inotify (~> 0.8.8)
122
+ mime-types (1.19)
123
+ mongo (1.6.4)
124
+ bson (~> 1.6.4)
125
+ mongo_ext (0.19.3)
126
+ mongo_mapper (0.11.1)
127
+ activemodel (~> 3.0)
128
+ activesupport (~> 3.0)
129
+ plucky (~> 0.4.0)
130
+ mongoid (3.0.1)
131
+ activemodel (~> 3.1)
132
+ moped (~> 1.1.1)
133
+ origin (~> 1.0.3)
134
+ tzinfo (~> 0.3.22)
135
+ moped (1.1.2)
136
+ multi_json (1.3.6)
137
+ mysql (2.8.1)
138
+ mysql2 (0.3.11)
139
+ origin (1.0.4)
140
+ pg (0.14.0)
141
+ plucky (0.4.4)
142
+ mongo (~> 1.5)
143
+ rack (1.4.1)
144
+ rack-cache (1.2)
145
+ rack (>= 0.4)
146
+ rack-ssl (1.3.2)
147
+ rack
148
+ rack-test (0.6.1)
149
+ rack (>= 1.0)
150
+ railties (3.2.6)
151
+ actionpack (= 3.2.6)
152
+ activesupport (= 3.2.6)
153
+ rack-ssl (~> 1.3.2)
154
+ rake (>= 0.8.7)
155
+ rdoc (~> 3.4)
156
+ thor (>= 0.14.6, < 2.0)
157
+ rake (0.9.2.2)
158
+ rb-fchange (0.0.5)
159
+ ffi
160
+ rb-fsevent (0.9.1)
161
+ rb-inotify (0.8.8)
111
162
  ffi (>= 0.5.0)
112
- rcov (0.9.8)
113
- rest-client (1.6.0)
163
+ rbx-require-relative (0.0.9)
164
+ rcov (1.0.0)
165
+ rdoc (3.12)
166
+ json (~> 1.4)
167
+ rest-client (1.6.7)
114
168
  mime-types (>= 1.16)
115
- rspactor (0.7.0.beta.6)
116
- bundler (>= 1.0.0.rc.5)
117
- growl (>= 1.0.3)
118
- libnotify (>= 0.1.3)
119
- rb-inotify
120
- sys-uname (>= 0.8.4)
121
- trollop (>= 1.16.2)
122
- rspec (1.3.0)
123
- ruby-debug (0.10.3)
169
+ rspactor (0.6.4)
170
+ rspec (2.11.0)
171
+ rspec-core (~> 2.11.0)
172
+ rspec-expectations (~> 2.11.0)
173
+ rspec-mocks (~> 2.11.0)
174
+ rspec-core (2.11.1)
175
+ rspec-expectations (2.11.1)
176
+ diff-lcs (~> 1.1.3)
177
+ rspec-mocks (2.11.1)
178
+ rspec-rails (2.11.0)
179
+ actionpack (>= 3.0)
180
+ activesupport (>= 3.0)
181
+ railties (>= 3.0)
182
+ rspec (~> 2.11.0)
183
+ ruby-debug (0.10.4)
124
184
  columnize (>= 0.1)
125
- ruby-debug-base (~> 0.10.3.0)
126
- ruby-debug-base (0.10.3)
185
+ ruby-debug-base (~> 0.10.4.0)
186
+ ruby-debug-base (0.10.4)
127
187
  linecache (>= 0.3)
128
- rubyforge (2.0.4)
129
- json_pure (>= 1.1.7)
130
188
  sequel (3.21.0)
131
- sqlite3-ruby (1.3.1)
189
+ sprockets (2.1.3)
190
+ hike (~> 1.2)
191
+ rack (~> 1.0)
192
+ tilt (~> 1.1, != 1.3.0)
193
+ sqlite3 (1.3.6)
194
+ sqlite3-ruby (1.3.3)
195
+ sqlite3 (>= 1.3.3)
132
196
  stringex (1.1.0)
133
- sys-uname (0.8.4)
134
- term-ansicolor (1.0.5)
135
- trollop (1.16.2)
136
- tzinfo (0.3.22)
137
- uuidtools (2.1.1)
138
- will_paginate (2.3.14)
197
+ thor (0.15.4)
198
+ tilt (1.3.3)
199
+ tzinfo (0.3.33)
200
+ uuidtools (2.1.3)
139
201
 
140
202
  PLATFORMS
141
203
  ruby
142
204
 
143
205
  DEPENDENCIES
144
206
  ZenTest
145
- activerecord (= 2.3.8)
207
+ activerecord
208
+ bson_ext
146
209
  bundler
147
- couch_potato (= 0.3.0)
210
+ couch_potato
148
211
  cucumber
149
212
  datamapper (= 1.0.0)
150
213
  dm-migrations (= 1.0.0)
151
214
  dm-sqlite-adapter (= 1.0.0)
215
+ guard-rspec
152
216
  jeweler
153
217
  json_pure
154
- mongo_mapper (= 0.8.2)
155
- mongoid (= 1.9.1)
218
+ mongo_ext
219
+ mongo_mapper
220
+ mongoid
221
+ mysql
222
+ mysql2
223
+ pg
156
224
  rake
157
225
  rcov
158
226
  rspactor
159
- rspec
227
+ rspec-rails
160
228
  ruby-debug
161
229
  sequel (~> 3.21.0)
162
230
  sqlite3-ruby
163
- tzinfo (= 0.3.22)
231
+ tzinfo
@@ -1,55 +1,55 @@
1
1
  When /^I create a widget$/ do
2
- When "I create a widget using #{ENV['ORM'].downcase}"
2
+ step "I create a widget using #{ENV['ORM'].downcase}"
3
3
  end
4
4
 
5
5
  Then /^I should see 1 widget$/ do
6
- Then "I should see 1 widget using #{ENV['ORM'].downcase}"
6
+ step "I should see 1 widget using #{ENV['ORM'].downcase}"
7
7
  end
8
8
 
9
9
  When /^I create a widget in one orm$/ do
10
- When "I create a widget using #{ENV['ORM'].downcase}"
10
+ step "I create a widget using #{ENV['ORM'].downcase}"
11
11
  end
12
12
 
13
13
  When /^I create a widget in another orm$/ do
14
- When "I create a widget using #{ENV['ANOTHER_ORM'].downcase}"
14
+ step "I create a widget using #{ENV['ANOTHER_ORM'].downcase}"
15
15
  end
16
16
 
17
17
  Then /^I should see 1 widget in one orm$/ do
18
- When "I should see 1 widget using #{ENV['ORM'].downcase}"
18
+ step "I should see 1 widget using #{ENV['ORM'].downcase}"
19
19
  end
20
20
 
21
21
  Then /^I should see 1 widget in another orm$/ do
22
- When "I should see 1 widget using #{ENV['ANOTHER_ORM'].downcase}"
22
+ step "I should see 1 widget using #{ENV['ANOTHER_ORM'].downcase}"
23
23
  end
24
24
 
25
25
  Then /^I should see 0 widget in another orm$/ do
26
- When "I should see 0 widget using #{ENV['ANOTHER_ORM'].downcase}"
26
+ step "I should see 0 widget using #{ENV['ANOTHER_ORM'].downcase}"
27
27
  end
28
28
 
29
29
  Then /^I should see 0 widget in one orm$/ do
30
- When "I should see 0 widget using #{ENV['ORM'].downcase}"
30
+ step "I should see 0 widget using #{ENV['ORM'].downcase}"
31
31
  end
32
32
 
33
33
  When /^I create a widget in one db$/ do
34
- When "I create a widget in one db using #{ENV['ORM'].downcase}"
34
+ step "I create a widget in one db using #{ENV['ORM'].downcase}"
35
35
  end
36
36
 
37
37
  When /^I create a widget in another db$/ do
38
- When "I create a widget in another db using #{ENV['ORM'].downcase}"
38
+ step "I create a widget in another db using #{ENV['ORM'].downcase}"
39
39
  end
40
40
 
41
41
  Then /^I should see 1 widget in one db$/ do
42
- When "I should see 1 widget in one db using #{ENV['ORM'].downcase}"
42
+ step "I should see 1 widget in one db using #{ENV['ORM'].downcase}"
43
43
  end
44
44
 
45
45
  Then /^I should see 1 widget in another db$/ do
46
- When "I should see 1 widget in another db using #{ENV['ORM'].downcase}"
46
+ step "I should see 1 widget in another db using #{ENV['ORM'].downcase}"
47
47
  end
48
48
 
49
49
  Then /^I should see 0 widget in another db$/ do
50
- When "I should see 0 widget in another db using #{ENV['ORM'].downcase}"
50
+ step "I should see 0 widget in another db using #{ENV['ORM'].downcase}"
51
51
  end
52
52
 
53
53
  Then /^I should see 0 widget in one db$/ do
54
- When "I should see 0 widget in one db using #{ENV['ORM'].downcase}"
54
+ step "I should see 0 widget in one db using #{ENV['ORM'].downcase}"
55
55
  end