database_cleaner 0.3.0 → 0.4.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.
data/History.txt CHANGED
@@ -1,4 +1,9 @@
1
- 0.3.x (In Git)
1
+ 0.4.x (In Git)
2
+
3
+ == 0.4.0 2009-12-23 (The MongoMapper Edition)
4
+
5
+ === New features
6
+ * MongoMapper support for the truncation strategy. (Aubrey Holland)
2
7
 
3
8
  == 0.3.0 2009-12-20
4
9
 
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
- Both ActiveRecord and DataMapper are supported.
8
+ ActiveRecord, DataMapper and MongoMapper are supported.
9
9
 
10
10
  h2. How to use
11
11
 
data/VERSION.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  ---
2
+ :minor: 4
2
3
  :patch: 0
4
+ :build:
3
5
  :major: 0
4
- :minor: 3
@@ -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
@@ -0,0 +1,10 @@
1
+ require 'mongo_mapper'
2
+
3
+ ::MongoMapper.connection = Mongo::Connection.new('127.0.0.1')
4
+ ::MongoMapper.database = 'database_cleaner_test'
5
+
6
+ class Widget
7
+ include MongoMapper::Document
8
+ key :id, Integer
9
+ key :name, String
10
+ end
@@ -15,4 +15,5 @@ Feature: database cleaning
15
15
  | ActiveRecord | transaction |
16
16
  | ActiveRecord | truncation |
17
17
  | DataMapper | transaction |
18
- | DataMapper | truncation |
18
+ | DataMapper | truncation |
19
+ | MongoMapper | truncation |
@@ -1,4 +1,4 @@
1
- Given /^I am using (ActiveRecord|DataMapper)$/ do |orm|
1
+ Given /^I am using (ActiveRecord|DataMapper|MongoMapper)$/ do |orm|
2
2
  @orm = orm
3
3
  end
4
4
 
@@ -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.3.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-20 00:00:00 -07:00
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