database_cleaner 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -1
- data/README.textile +1 -1
- data/VERSION.yml +2 -1
- data/examples/features/support/env.rb +1 -1
- data/examples/lib/mongomapper.rb +10 -0
- data/features/cleaning.feature +2 -1
- data/features/step_definitions/database_cleaner_steps.rb +1 -1
- data/lib/database_cleaner/configuration.rb +10 -0
- data/lib/database_cleaner/mongo_mapper/truncation.rb +21 -0
- metadata +5 -2
data/History.txt
CHANGED
data/README.textile
CHANGED
@@ -5,7 +5,7 @@ The original use case was to ensure a clean state during tests. Each strategy
|
|
5
5
|
is a small amount of code but is code that is usually needed in any ruby app
|
6
6
|
that is testing with a database.
|
7
7
|
|
8
|
-
|
8
|
+
ActiveRecord, DataMapper and MongoMapper are supported.
|
9
9
|
|
10
10
|
h2. How to use
|
11
11
|
|
data/VERSION.yml
CHANGED
@@ -19,5 +19,5 @@ if orm && strategy
|
|
19
19
|
DatabaseCleaner.strategy = strategy.to_sym
|
20
20
|
|
21
21
|
else
|
22
|
-
raise "Run 'ORM=activerecord|datamapper STRATEGY=transaction|truncation cucumber examples/features'"
|
22
|
+
raise "Run 'ORM=activerecord|datamapper|mongomapper STRATEGY=transaction|truncation cucumber examples/features'"
|
23
23
|
end
|
data/features/cleaning.feature
CHANGED
@@ -15,6 +15,12 @@ module DatabaseCleaner
|
|
15
15
|
%w[truncation transaction]
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
module MongoMapper
|
20
|
+
def self.available_strategies
|
21
|
+
%w[truncation]
|
22
|
+
end
|
23
|
+
end
|
18
24
|
|
19
25
|
class << self
|
20
26
|
|
@@ -73,6 +79,8 @@ module DatabaseCleaner
|
|
73
79
|
'active_record'
|
74
80
|
elsif defined? ::DataMapper
|
75
81
|
'data_mapper'
|
82
|
+
elsif defined? ::MongoMapper
|
83
|
+
'mongo_mapper'
|
76
84
|
else
|
77
85
|
raise NoORMDetected, "No known ORM was detected! Is ActiveRecord or DataMapper loaded?"
|
78
86
|
end
|
@@ -86,6 +94,8 @@ module DatabaseCleaner
|
|
86
94
|
DatabaseCleaner::ActiveRecord
|
87
95
|
when 'data_mapper'
|
88
96
|
DatabaseCleaner::DataMapper
|
97
|
+
when 'mongo_mapper'
|
98
|
+
DatabaseCleaner::MongoMapper
|
89
99
|
end
|
90
100
|
end
|
91
101
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'database_cleaner/truncation_base'
|
2
|
+
|
3
|
+
module DatabaseCleaner
|
4
|
+
module MongoMapper
|
5
|
+
class Truncation < DatabaseCleaner::TruncationBase
|
6
|
+
def clean
|
7
|
+
connection.db(database).collections.each { |c| c.remove }
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def connection
|
13
|
+
::MongoMapper.connection
|
14
|
+
end
|
15
|
+
|
16
|
+
def database
|
17
|
+
::MongoMapper.database.name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_cleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Mabey
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-23 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- examples/features/support/env.rb
|
35
35
|
- examples/lib/activerecord.rb
|
36
36
|
- examples/lib/datamapper.rb
|
37
|
+
- examples/lib/mongomapper.rb
|
37
38
|
- features/cleaning.feature
|
38
39
|
- features/step_definitions/database_cleaner_steps.rb
|
39
40
|
- features/support/env.rb
|
@@ -44,6 +45,7 @@ files:
|
|
44
45
|
- lib/database_cleaner/cucumber.rb
|
45
46
|
- lib/database_cleaner/data_mapper/transaction.rb
|
46
47
|
- lib/database_cleaner/data_mapper/truncation.rb
|
48
|
+
- lib/database_cleaner/mongo_mapper/truncation.rb
|
47
49
|
- lib/database_cleaner/truncation_base.rb
|
48
50
|
- spec/database_cleaner/active_record/truncation_spec.rb
|
49
51
|
- spec/database_cleaner/configuration_spec.rb
|
@@ -87,3 +89,4 @@ test_files:
|
|
87
89
|
- examples/features/support/env.rb
|
88
90
|
- examples/lib/activerecord.rb
|
89
91
|
- examples/lib/datamapper.rb
|
92
|
+
- examples/lib/mongomapper.rb
|