database_cleaner 0.5.2 → 0.6.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/Gemfile.lock +145 -0
  2. data/History.txt +24 -1
  3. data/README.textile +48 -0
  4. data/Rakefile +4 -0
  5. data/TODO +3 -0
  6. data/VERSION.yml +3 -2
  7. data/examples/Gemfile +46 -0
  8. data/examples/Gemfile.lock +145 -0
  9. data/examples/config/database.yml +7 -0
  10. data/examples/config/database.yml.example +8 -0
  11. data/examples/db/activerecord_one.db +0 -0
  12. data/examples/db/activerecord_two.db +0 -0
  13. data/examples/db/datamapper_default.db +0 -0
  14. data/examples/db/datamapper_one.db +0 -0
  15. data/examples/db/datamapper_two.db +0 -0
  16. data/examples/db/sqlite_databases_go_here +0 -0
  17. data/examples/features/example_multiple_db.feature +23 -0
  18. data/examples/features/example_multiple_orm.feature +22 -0
  19. data/examples/features/step_definitions/activerecord_steps.rb +31 -0
  20. data/examples/features/step_definitions/couchpotato_steps.rb +31 -0
  21. data/examples/features/step_definitions/datamapper_steps.rb +37 -0
  22. data/examples/features/step_definitions/mongoid_steps.rb +23 -0
  23. data/examples/features/step_definitions/mongomapper_steps.rb +31 -0
  24. data/examples/features/step_definitions/translation_steps.rb +55 -0
  25. data/examples/features/support/env.rb +49 -10
  26. data/examples/lib/activerecord_models.rb +34 -5
  27. data/examples/lib/couchpotato_models.rb +46 -6
  28. data/examples/lib/datamapper_models.rb +37 -3
  29. data/examples/lib/mongoid_models.rb +28 -2
  30. data/examples/lib/mongomapper_models.rb +35 -1
  31. data/features/cleaning_multiple_dbs.feature +20 -0
  32. data/features/cleaning_multiple_orms.feature +29 -0
  33. data/features/step_definitions/database_cleaner_steps.rb +20 -13
  34. data/features/support/feature_runner.rb +39 -0
  35. data/lib/database_cleaner/active_record/base.rb +46 -0
  36. data/lib/database_cleaner/active_record/transaction.rb +10 -10
  37. data/lib/database_cleaner/active_record/truncation.rb +17 -7
  38. data/lib/database_cleaner/base.rb +129 -0
  39. data/lib/database_cleaner/configuration.rb +45 -97
  40. data/lib/database_cleaner/couch_potato/base.rb +7 -0
  41. data/lib/database_cleaner/couch_potato/truncation.rb +4 -2
  42. data/lib/database_cleaner/cucumber.rb +0 -1
  43. data/lib/database_cleaner/data_mapper/base.rb +21 -0
  44. data/lib/database_cleaner/data_mapper/transaction.rb +10 -5
  45. data/lib/database_cleaner/data_mapper/truncation.rb +52 -19
  46. data/lib/database_cleaner/generic/base.rb +23 -0
  47. data/lib/database_cleaner/generic/truncation.rb +43 -0
  48. data/lib/database_cleaner/mongo_mapper/base.rb +20 -0
  49. data/lib/database_cleaner/mongo_mapper/truncation.rb +9 -3
  50. data/lib/database_cleaner/mongoid/base.rb +20 -0
  51. data/lib/database_cleaner/mongoid/truncation.rb +9 -5
  52. data/spec/database_cleaner/active_record/base_spec.rb +130 -0
  53. data/spec/database_cleaner/active_record/truncation_spec.rb +19 -18
  54. data/spec/database_cleaner/base_spec.rb +441 -0
  55. data/spec/database_cleaner/configuration_spec.rb +255 -68
  56. data/spec/database_cleaner/couch_potato/truncation_spec.rb +4 -3
  57. data/spec/database_cleaner/data_mapper/base_spec.rb +30 -0
  58. data/spec/database_cleaner/data_mapper/transaction_spec.rb +23 -0
  59. data/spec/database_cleaner/data_mapper/truncation_spec.rb +11 -0
  60. data/spec/database_cleaner/generic/base_spec.rb +22 -0
  61. data/spec/database_cleaner/generic/truncation_spec.rb +68 -0
  62. data/spec/database_cleaner/mongo_mapper/base_spec.rb +33 -0
  63. data/spec/database_cleaner/mongo_mapper/mongo_examples.rb +8 -0
  64. data/spec/database_cleaner/mongo_mapper/truncation_spec.rb +11 -18
  65. data/spec/database_cleaner/shared_strategy_spec.rb +13 -0
  66. data/spec/rcov.opts +1 -0
  67. data/spec/spec.opts +1 -0
  68. data/spec/spec_helper.rb +10 -3
  69. metadata +76 -8
  70. data/examples/features/step_definitions/example_steps.rb +0 -8
  71. data/lib/database_cleaner/truncation_base.rb +0 -41
data/Gemfile.lock ADDED
@@ -0,0 +1,145 @@
1
+ GEM
2
+ remote: http://rubygems.org/
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)
14
+ json
15
+ couchrest (1.0.1)
16
+ json (>= 1.4.6)
17
+ mime-types (>= 1.15)
18
+ 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)
26
+ addressable (~> 2.1)
27
+ datamapper (1.0.0)
28
+ dm-aggregates (= 1.0.0)
29
+ dm-constraints (= 1.0.0)
30
+ dm-core (= 1.0.0)
31
+ dm-core (= 1.0.0)
32
+ dm-migrations (= 1.0.0)
33
+ dm-serializer (= 1.0.0)
34
+ dm-timestamps (= 1.0.0)
35
+ dm-transactions (= 1.0.0)
36
+ dm-types (= 1.0.0)
37
+ dm-validations (= 1.0.0)
38
+ diff-lcs (1.1.2)
39
+ dm-aggregates (1.0.0)
40
+ dm-core (~> 1.0.0)
41
+ dm-constraints (1.0.0)
42
+ dm-core (~> 1.0.0)
43
+ dm-migrations (~> 1.0.0)
44
+ dm-core (1.0.0)
45
+ addressable (~> 2.1)
46
+ extlib (~> 0.9.15)
47
+ dm-do-adapter (1.0.0)
48
+ data_objects (~> 0.10.1)
49
+ dm-core (~> 1.0.0)
50
+ dm-migrations (1.0.0)
51
+ dm-core (~> 1.0.0)
52
+ dm-serializer (1.0.0)
53
+ dm-core (~> 1.0.0)
54
+ fastercsv (~> 1.5.3)
55
+ json_pure (~> 1.4.3)
56
+ dm-sqlite-adapter (1.0.0)
57
+ dm-do-adapter (~> 1.0.0)
58
+ do_sqlite3 (~> 0.10.2)
59
+ dm-timestamps (1.0.0)
60
+ dm-core (~> 1.0.0)
61
+ dm-transactions (1.0.0)
62
+ dm-core (~> 1.0.0)
63
+ dm-types (1.0.0)
64
+ dm-core (~> 1.0.0)
65
+ fastercsv (~> 1.5.3)
66
+ json_pure (~> 1.4.3)
67
+ stringex (~> 1.1.0)
68
+ uuidtools (~> 2.1.1)
69
+ dm-validations (1.0.0)
70
+ dm-core (~> 1.0.0)
71
+ do_sqlite3 (0.10.2)
72
+ data_objects (= 0.10.2)
73
+ durran-validatable (2.0.1)
74
+ extlib (0.9.15)
75
+ fastercsv (1.5.3)
76
+ gemcutter (0.6.1)
77
+ gherkin (2.1.5)
78
+ trollop (~> 1.16.2)
79
+ git (1.2.5)
80
+ jeweler (1.4.0)
81
+ gemcutter (>= 0.1.0)
82
+ git (>= 1.2.5)
83
+ rubyforge (>= 2.0.0)
84
+ jnunemaker-validatable (1.8.4)
85
+ activesupport (>= 2.3.4)
86
+ json (1.4.6)
87
+ json_pure (1.4.6)
88
+ linecache (0.43)
89
+ mime-types (1.16)
90
+ mongo (1.0.7)
91
+ bson (>= 1.0.4)
92
+ mongo_mapper (0.8.2)
93
+ activesupport (>= 2.3.4)
94
+ jnunemaker-validatable (~> 1.8.4)
95
+ plucky (~> 0.3.1)
96
+ mongoid (1.9.1)
97
+ activesupport (<= 3.0.0)
98
+ bson (~> 1.0.1)
99
+ durran-validatable (>= 2.0.1)
100
+ mongo (~> 1.0.1)
101
+ will_paginate (< 2.9)
102
+ plucky (0.3.4)
103
+ mongo (~> 1.0.7)
104
+ rake (0.8.7)
105
+ rcov (0.9.8)
106
+ rest-client (1.6.0)
107
+ mime-types (>= 1.16)
108
+ rspec (1.3.0)
109
+ ruby-debug (0.10.3)
110
+ columnize (>= 0.1)
111
+ ruby-debug-base (~> 0.10.3.0)
112
+ ruby-debug-base (0.10.3)
113
+ linecache (>= 0.3)
114
+ rubyforge (2.0.4)
115
+ json_pure (>= 1.1.7)
116
+ sqlite3-ruby (1.3.1)
117
+ stringex (1.1.0)
118
+ term-ansicolor (1.0.5)
119
+ trollop (1.16.2)
120
+ tzinfo (0.3.22)
121
+ uuidtools (2.1.1)
122
+ will_paginate (2.3.14)
123
+
124
+ PLATFORMS
125
+ ruby
126
+
127
+ DEPENDENCIES
128
+ ZenTest
129
+ activerecord (= 2.3.8)
130
+ bundler
131
+ couch_potato (= 0.3.0)
132
+ cucumber
133
+ datamapper (= 1.0.0)
134
+ dm-migrations (= 1.0.0)
135
+ dm-sqlite-adapter (= 1.0.0)
136
+ jeweler
137
+ json_pure
138
+ mongo_mapper (= 0.8.2)
139
+ mongoid (= 1.9.1)
140
+ rake
141
+ rcov
142
+ rspec
143
+ ruby-debug
144
+ sqlite3-ruby
145
+ tzinfo (= 0.3.22)
data/History.txt CHANGED
@@ -1,4 +1,27 @@
1
- 0.5.x (In Git)
1
+ == 0.6.x (In Git)
2
+
3
+ == 0.6.0 2010-08-2x - The Multi-ORM/Connection Release
4
+
5
+ This release has the often asked for functionality of being able to clean
6
+ multiple databases within the same project. This involves being able to
7
+ clean databases managed by the same ORM (i.e. different connections) and
8
+ also being able to clean databases managed by distinct ORMs. So, for
9
+ example you can now use DatabaseCleaner on a project that has ActiveRecord
10
+ and Mongoid to help ensure all DBs all in a clean state. Please see the
11
+ README for more information. The old API has been preserved so this release
12
+ is backwards compatible.
13
+
14
+ This release is a result of Jon Rowe's hard work. Many thanks to Jon for all
15
+ of the hours and effort he put into making this feature request a reality.
16
+
17
+ === New Features
18
+ * Ability to clean multiple database connections managed by the same ORM. (Jon Rowe)
19
+ * Ability to clean multiple DBs managed by different ORMs in same project. (Jon Rowe)
20
+ * Allows for the ActiveRecord config file (database.yml) to contain ERB and process it. (Fletcher Nichol)
21
+ * Mysql2Adapter support. (Kamal Fariz Mahyuddin and John Ferlito)
22
+
23
+ === Bugfixes
24
+ * Updates the DataMapper truncation strategy to version 0.10.3. (Robert Rouse)
2
25
 
3
26
  == 0.5.2
4
27
 
data/README.textile CHANGED
@@ -76,7 +76,55 @@ end
76
76
 
77
77
  For use in Cucumber please see the section below.
78
78
 
79
+ h2. How to use with multiple ORM's
79
80
 
81
+ Sometimes you need to use multiple ORMs in your application. You can use DatabaseCleaner to clean multiple ORMs, and multiple connections for those ORMs.
82
+
83
+ <pre>
84
+ #How to specify particular orms
85
+ DatabaseCleaner[:active_record].strategy = :transaction
86
+ DatabaseCleaner[:mongo_mapper].strategy = :truncation
87
+
88
+ #How to specify particular connections
89
+ DatabaseCleaner[:active_record,{:connection => :two}]
90
+ </pre>
91
+
92
+ Usage beyond that remains the same with DatabaseCleaner.start calling any setup on the different configured connections, and DatabaseCleaner.clean executing afterwards.
93
+
94
+ Configuration options
95
+
96
+ <table>
97
+ <tr>
98
+ <th>ORM</th>
99
+ <th>How to access</th>
100
+ <th>Notes</th>
101
+ </tr>
102
+ <tr>
103
+ <td>Active Record</td>
104
+ <td>DatabaseCleaner[:active_record]</td>
105
+ <td>Connection specified as :symbol keys, loaded from config/database.yml</td>
106
+ </th>
107
+ <tr>
108
+ <td>Data Mapper</td>
109
+ <td>DatabaseCleaner[:data_mapper]</td>
110
+ <td>Connection specified as :symbol keys, loaded via Datamapper repositories</td>
111
+ </th>
112
+ <tr>
113
+ <td>Mongo Mapper</td>
114
+ <td>DatabaseCleaner[:mongo_mapper]</td>
115
+ <td>Multiple connections not yet supported</td>
116
+ </th>
117
+ <tr>
118
+ <td>Mongoid</td>
119
+ <td>DatabaseCleaner[:mongoid]</td>
120
+ <td>Multiple connections not yet supported</td>
121
+ </th>
122
+ <tr>
123
+ <td>Couch Potato</td>
124
+ <td>DatabaseCleaner[:couch_potato]</td>
125
+ <td>Multiple connections not yet supported</td>
126
+ </tr>
127
+ </table>
80
128
 
81
129
  h2. Why?
82
130
 
data/Rakefile CHANGED
@@ -1,3 +1,7 @@
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler.setup
4
+
1
5
  require 'rake'
2
6
 
3
7
  begin
data/TODO CHANGED
@@ -0,0 +1,3 @@
1
+ Could be more Datamapper
2
+ MongoMapper multiple db support
3
+ CouchDB multiple db support
data/VERSION.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  ---
2
- :minor: 5
3
- :patch: 2
2
+ :minor: 6
3
+ :patch: 0
4
4
  :build:
5
5
  :major: 0
6
+
data/examples/Gemfile ADDED
@@ -0,0 +1,46 @@
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
16
+
17
+ group :development do
18
+ gem "rake"
19
+ gem "ruby-debug"
20
+
21
+ gem "bundler"
22
+ gem "jeweler"
23
+
24
+ gem "json_pure"
25
+
26
+ #ORM's
27
+ gem "activerecord", "2.3.8"
28
+ gem "datamapper", "1.0.0"
29
+ gem "dm-migrations", "1.0.0"
30
+ 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"
35
+ end
36
+
37
+ group :test do
38
+ gem "rspec"
39
+ gem "rcov"
40
+ gem "ZenTest"
41
+ end
42
+
43
+ group :cucumber do
44
+ gem "cucumber"
45
+ gem 'sqlite3-ruby'
46
+ end
@@ -0,0 +1,145 @@
1
+ GEM
2
+ remote: http://rubygems.org/
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)
14
+ json
15
+ couchrest (1.0.1)
16
+ json (>= 1.4.6)
17
+ mime-types (>= 1.15)
18
+ 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)
26
+ addressable (~> 2.1)
27
+ datamapper (1.0.0)
28
+ dm-aggregates (= 1.0.0)
29
+ dm-constraints (= 1.0.0)
30
+ dm-core (= 1.0.0)
31
+ dm-core (= 1.0.0)
32
+ dm-migrations (= 1.0.0)
33
+ dm-serializer (= 1.0.0)
34
+ dm-timestamps (= 1.0.0)
35
+ dm-transactions (= 1.0.0)
36
+ dm-types (= 1.0.0)
37
+ dm-validations (= 1.0.0)
38
+ diff-lcs (1.1.2)
39
+ dm-aggregates (1.0.0)
40
+ dm-core (~> 1.0.0)
41
+ dm-constraints (1.0.0)
42
+ dm-core (~> 1.0.0)
43
+ dm-migrations (~> 1.0.0)
44
+ dm-core (1.0.0)
45
+ addressable (~> 2.1)
46
+ extlib (~> 0.9.15)
47
+ dm-do-adapter (1.0.0)
48
+ data_objects (~> 0.10.1)
49
+ dm-core (~> 1.0.0)
50
+ dm-migrations (1.0.0)
51
+ dm-core (~> 1.0.0)
52
+ dm-serializer (1.0.0)
53
+ dm-core (~> 1.0.0)
54
+ fastercsv (~> 1.5.3)
55
+ json_pure (~> 1.4.3)
56
+ dm-sqlite-adapter (1.0.0)
57
+ dm-do-adapter (~> 1.0.0)
58
+ do_sqlite3 (~> 0.10.2)
59
+ dm-timestamps (1.0.0)
60
+ dm-core (~> 1.0.0)
61
+ dm-transactions (1.0.0)
62
+ dm-core (~> 1.0.0)
63
+ dm-types (1.0.0)
64
+ dm-core (~> 1.0.0)
65
+ fastercsv (~> 1.5.3)
66
+ json_pure (~> 1.4.3)
67
+ stringex (~> 1.1.0)
68
+ uuidtools (~> 2.1.1)
69
+ dm-validations (1.0.0)
70
+ dm-core (~> 1.0.0)
71
+ do_sqlite3 (0.10.2)
72
+ data_objects (= 0.10.2)
73
+ durran-validatable (2.0.1)
74
+ extlib (0.9.15)
75
+ fastercsv (1.5.3)
76
+ gemcutter (0.6.1)
77
+ gherkin (2.1.5)
78
+ trollop (~> 1.16.2)
79
+ git (1.2.5)
80
+ jeweler (1.4.0)
81
+ gemcutter (>= 0.1.0)
82
+ git (>= 1.2.5)
83
+ rubyforge (>= 2.0.0)
84
+ jnunemaker-validatable (1.8.4)
85
+ activesupport (>= 2.3.4)
86
+ json (1.4.6)
87
+ json_pure (1.4.6)
88
+ linecache (0.43)
89
+ mime-types (1.16)
90
+ mongo (1.0.7)
91
+ bson (>= 1.0.4)
92
+ mongo_mapper (0.8.2)
93
+ activesupport (>= 2.3.4)
94
+ jnunemaker-validatable (~> 1.8.4)
95
+ plucky (~> 0.3.1)
96
+ mongoid (1.9.1)
97
+ activesupport (<= 3.0.0)
98
+ bson (~> 1.0.1)
99
+ durran-validatable (>= 2.0.1)
100
+ mongo (~> 1.0.1)
101
+ will_paginate (< 2.9)
102
+ plucky (0.3.4)
103
+ mongo (~> 1.0.7)
104
+ rake (0.8.7)
105
+ rcov (0.9.8)
106
+ rest-client (1.6.0)
107
+ mime-types (>= 1.16)
108
+ rspec (1.3.0)
109
+ ruby-debug (0.10.3)
110
+ columnize (>= 0.1)
111
+ ruby-debug-base (~> 0.10.3.0)
112
+ ruby-debug-base (0.10.3)
113
+ linecache (>= 0.3)
114
+ rubyforge (2.0.4)
115
+ json_pure (>= 1.1.7)
116
+ sqlite3-ruby (1.3.1)
117
+ stringex (1.1.0)
118
+ term-ansicolor (1.0.5)
119
+ trollop (1.16.2)
120
+ tzinfo (0.3.22)
121
+ uuidtools (2.1.1)
122
+ will_paginate (2.3.14)
123
+
124
+ PLATFORMS
125
+ ruby
126
+
127
+ DEPENDENCIES
128
+ ZenTest
129
+ activerecord (= 2.3.8)
130
+ bundler
131
+ couch_potato (= 0.3.0)
132
+ cucumber
133
+ datamapper (= 1.0.0)
134
+ dm-migrations (= 1.0.0)
135
+ dm-sqlite-adapter (= 1.0.0)
136
+ jeweler
137
+ json_pure
138
+ mongo_mapper (= 0.8.2)
139
+ mongoid (= 1.9.1)
140
+ rake
141
+ rcov
142
+ rspec
143
+ ruby-debug
144
+ sqlite3-ruby
145
+ tzinfo (= 0.3.22)