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
@@ -0,0 +1,7 @@
1
+ ---
2
+ two:
3
+ adapter: sqlite3
4
+ database: /Users/bmabey/Programming/ruby/database_cleaner/examples/features/support/../../db/activerecord_two.db
5
+ one:
6
+ adapter: sqlite3
7
+ database: /Users/bmabey/Programming/ruby/database_cleaner/examples/features/support/../../db/activerecord_one.db
@@ -0,0 +1,8 @@
1
+ #This is an example of what database.yml *should* look like (when I wrote it)
2
+ #The real database.yml is generated automatically by the active record model lib (so it can be correct)
3
+ two:
4
+ adapter: sqlite3
5
+ database: /path/to/examples/features/support/../../db/activerecord_two.db
6
+ one:
7
+ adapter: sqlite3
8
+ database: /path/to/examples/features/support/../../db/activerecord_one.db
Binary file
Binary file
Binary file
Binary file
Binary file
File without changes
@@ -0,0 +1,23 @@
1
+ Feature: example
2
+ In order to test DataBase Cleaner
3
+ Here are some scenarios that rely on the DB being clean!
4
+
5
+ # Background:
6
+ # Given I have setup DatabaseCleaner to clean multiple databases
7
+ #
8
+ Scenario: dirty the db
9
+ When I create a widget in one db
10
+ And I create a widget in another db
11
+ Then I should see 1 widget in one db
12
+ And I should see 1 widget in another db
13
+
14
+ Scenario: assume a clean db
15
+ When I create a widget in one db
16
+ Then I should see 1 widget in one db
17
+ And I should see 0 widget in another db
18
+
19
+ Scenario: assume a clean db
20
+ When I create a widget in another db
21
+ Then I should see 0 widget in one db
22
+ And I should see 1 widget in another db
23
+
@@ -0,0 +1,22 @@
1
+ Feature: example
2
+ In order to test DataBase Cleaner
3
+ Here are some scenarios that rely on the DB being clean!
4
+
5
+ # Background:
6
+ # Given I have setup DatabaseCleaner to clean multiple orms
7
+
8
+ Scenario: dirty the db
9
+ When I create a widget in one orm
10
+ And I create a widget in another orm
11
+ Then I should see 1 widget in one orm
12
+ And I should see 1 widget in another orm
13
+
14
+ Scenario: assume a clean db
15
+ When I create a widget in one orm
16
+ Then I should see 1 widget in one orm
17
+ And I should see 0 widget in another orm
18
+
19
+ Scenario: assume a clean db
20
+ When I create a widget in another orm
21
+ Then I should see 0 widget in one orm
22
+ And I should see 1 widget in another orm
@@ -0,0 +1,31 @@
1
+ Given /^I have setup database cleaner to clean multiple databases using activerecord$/ do
2
+ #DatabaseCleaner
3
+ # require "#{File.dirname(__FILE__)}/../../../lib/datamapper_models"
4
+ #
5
+ # DatabaseCleaner[:datamapper, {:connection => :one} ].strategy = :truncation
6
+ # DatabaseCleaner[:datamapper, {:connection => :two} ].strategy = :truncation
7
+ end
8
+
9
+ When /^I create a widget using activerecord$/ do
10
+ ActiveRecordWidget.create!
11
+ end
12
+
13
+ Then /^I should see ([\d]+) widget using activerecord$/ do |widget_count|
14
+ ActiveRecordWidget.count.should == widget_count.to_i
15
+ end
16
+
17
+ When /^I create a widget in one db using activerecord$/ do
18
+ ActiveRecordWidgetUsingDatabaseOne.create!
19
+ end
20
+
21
+ When /^I create a widget in another db using activerecord$/ do
22
+ ActiveRecordWidgetUsingDatabaseTwo.create!
23
+ end
24
+
25
+ Then /^I should see ([\d]+) widget in one db using activerecord$/ do |widget_count|
26
+ ActiveRecordWidgetUsingDatabaseOne.count.should == widget_count.to_i
27
+ end
28
+
29
+ Then /^I should see ([\d]+) widget in another db using activerecord$/ do |widget_count|
30
+ ActiveRecordWidgetUsingDatabaseTwo.count.should == widget_count.to_i
31
+ end
@@ -0,0 +1,31 @@
1
+ Given /^I have setup database cleaner to clean multiple databases using couchpotato$/ do
2
+ #DatabaseCleaner
3
+ # require "#{File.dirname(__FILE__)}/../../../lib/couchpotato_models"
4
+ #
5
+ # DatabaseCleaner[:couchpotato, {:connection => :one} ].strategy = :truncation
6
+ # DatabaseCleaner[:couchpotato, {:connection => :two} ].strategy = :truncation
7
+ end
8
+
9
+ When /^I create a widget using couchpotato$/ do
10
+ CouchPotatoWidget.create!
11
+ end
12
+
13
+ Then /^I should see ([\d]+) widget using couchpotato$/ do |widget_count|
14
+ CouchPotatoWidget.count.should == widget_count.to_i
15
+ end
16
+
17
+ When /^I create a widget in one db using couchpotato$/ do
18
+ CouchPotatoWidgetUsingDatabaseOne.create!
19
+ end
20
+
21
+ When /^I create a widget in another db using couchpotato$/ do
22
+ CouchPotatoWidgetUsingDatabaseTwo.create!
23
+ end
24
+
25
+ Then /^I should see ([\d]+) widget in one db using couchpotato$/ do |widget_count|
26
+ CouchPotatoWidgetUsingDatabaseOne.count.should == widget_count.to_i
27
+ end
28
+
29
+ Then /^I should see ([\d]+) widget in another db using couchpotato$/ do |widget_count|
30
+ CouchPotatoWidgetUsingDatabaseTwo.count.should == widget_count.to_i
31
+ end
@@ -0,0 +1,37 @@
1
+ Given /^I have setup database cleaner to clean multiple databases using datamapper$/ do
2
+ #DatabaseCleaner
3
+ # require "#{File.dirname(__FILE__)}/../../../lib/datamapper_models"
4
+ #
5
+ # DatabaseCleaner[:datamapper, {:connection => :one} ].strategy = :truncation
6
+ # DatabaseCleaner[:datamapper, {:connection => :two} ].strategy = :truncation
7
+ end
8
+
9
+ When /^I create a widget using datamapper$/ do
10
+ DataMapperWidget.create!
11
+ end
12
+
13
+ Then /^I should see ([\d]+) widget using datamapper$/ do |widget_count|
14
+ DataMapperWidget.count.should == widget_count.to_i
15
+ end
16
+
17
+ When /^I create a widget in one db using datamapper$/ do
18
+ begin
19
+ DataMapperWidgetUsingDatabaseOne.create!
20
+ rescue StandardError => e
21
+ BREAK = e.backtrace
22
+ debugger
23
+ DataMapperWidgetUsingDatabaseOne.create!
24
+ end
25
+ end
26
+
27
+ When /^I create a widget in another db using datamapper$/ do
28
+ DataMapperWidgetUsingDatabaseTwo.create!
29
+ end
30
+
31
+ Then /^I should see ([\d]+) widget in one db using datamapper$/ do |widget_count|
32
+ DataMapperWidgetUsingDatabaseOne.count.should == widget_count.to_i
33
+ end
34
+
35
+ Then /^I should see ([\d]+) widget in another db using datamapper$/ do |widget_count|
36
+ DataMapperWidgetUsingDatabaseTwo.count.should == widget_count.to_i
37
+ end
@@ -0,0 +1,23 @@
1
+ When /^I create a widget using mongoid$/ do
2
+ MongoidWidget.create!( :id => rand(1000)+1000)
3
+ end
4
+
5
+ Then /^I should see ([\d]+) widget using mongoid$/ do |widget_count|
6
+ MongoidWidget.count.should == widget_count.to_i
7
+ end
8
+
9
+ When /^I create a widget in one db using mongoid$/ do
10
+ MongoidWidgetUsingDatabaseOne.create!
11
+ end
12
+
13
+ When /^I create a widget in another db using mongoid$/ do
14
+ MongoidWidgetUsingDatabaseTwo.create!
15
+ end
16
+
17
+ Then /^I should see ([\d]+) widget in one db using mongoid$/ do |widget_count|
18
+ MongoidWidgetUsingDatabaseOne.count.should == widget_count.to_i
19
+ end
20
+
21
+ Then /^I should see ([\d]+) widget in another db using mongoid$/ do |widget_count|
22
+ MongoidWidgetUsingDatabaseTwo.count.should == widget_count.to_i
23
+ end
@@ -0,0 +1,31 @@
1
+ Given /^I have setup database cleaner to clean multiple databases using mongomapper$/ do
2
+ #DatabaseCleaner
3
+ # require "#{File.dirname(__FILE__)}/../../../lib/datamapper_models"
4
+ #
5
+ # DatabaseCleaner[:datamapper, {:connection => :one} ].strategy = :truncation
6
+ # DatabaseCleaner[:datamapper, {:connection => :two} ].strategy = :truncation
7
+ end
8
+
9
+ When /^I create a widget using mongomapper$/ do
10
+ MongoMapperWidget.create!
11
+ end
12
+
13
+ Then /^I should see ([\d]+) widget using mongomapper$/ do |widget_count|
14
+ MongoMapperWidget.count.should == widget_count.to_i
15
+ end
16
+
17
+ When /^I create a widget in one db using mongomapper$/ do
18
+ MongoMapperWidgetUsingDatabaseOne.create!
19
+ end
20
+
21
+ When /^I create a widget in another db using mongomapper$/ do
22
+ MongoMapperWidgetUsingDatabaseTwo.create!
23
+ end
24
+
25
+ Then /^I should see ([\d]+) widget in one db using mongomapper$/ do |widget_count|
26
+ MongoMapperWidgetUsingDatabaseOne.count.should == widget_count.to_i
27
+ end
28
+
29
+ Then /^I should see ([\d]+) widget in another db using mongomapper$/ do |widget_count|
30
+ MongoMapperWidgetUsingDatabaseTwo.count.should == widget_count.to_i
31
+ end
@@ -0,0 +1,55 @@
1
+ When /^I create a widget$/ do
2
+ When "I create a widget using #{ENV['ORM'].downcase}"
3
+ end
4
+
5
+ Then /^I should see 1 widget$/ do
6
+ Then "I should see 1 widget using #{ENV['ORM'].downcase}"
7
+ end
8
+
9
+ When /^I create a widget in one orm$/ do
10
+ When "I create a widget using #{ENV['ORM'].downcase}"
11
+ end
12
+
13
+ When /^I create a widget in another orm$/ do
14
+ When "I create a widget using #{ENV['ANOTHER_ORM'].downcase}"
15
+ end
16
+
17
+ Then /^I should see 1 widget in one orm$/ do
18
+ When "I should see 1 widget using #{ENV['ORM'].downcase}"
19
+ end
20
+
21
+ Then /^I should see 1 widget in another orm$/ do
22
+ When "I should see 1 widget using #{ENV['ANOTHER_ORM'].downcase}"
23
+ end
24
+
25
+ Then /^I should see 0 widget in another orm$/ do
26
+ When "I should see 0 widget using #{ENV['ANOTHER_ORM'].downcase}"
27
+ end
28
+
29
+ Then /^I should see 0 widget in one orm$/ do
30
+ When "I should see 0 widget using #{ENV['ORM'].downcase}"
31
+ end
32
+
33
+ When /^I create a widget in one db$/ do
34
+ When "I create a widget in one db using #{ENV['ORM'].downcase}"
35
+ end
36
+
37
+ When /^I create a widget in another db$/ do
38
+ When "I create a widget in another db using #{ENV['ORM'].downcase}"
39
+ end
40
+
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}"
43
+ end
44
+
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}"
47
+ end
48
+
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}"
51
+ end
52
+
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}"
55
+ end
@@ -1,23 +1,62 @@
1
+ #Hilarious as it seems, this is necessary so bundle exec cucumber works for mongoid cukeage (I'm assuming mongomapper is automatically present because its a git repo)
2
+ Object.send(:remove_const, 'MongoMapper') if defined?(::MongoMapper)
3
+
1
4
  require 'rubygems'
5
+ require 'bundler'
6
+
7
+ Bundler.setup
2
8
  require 'spec/expectations'
9
+ require 'ruby-debug'
10
+
11
+ DB_DIR = "#{File.dirname(__FILE__)}/../../db"
12
+
13
+ orm = ENV['ORM']
14
+ another_orm = ENV['ANOTHER_ORM']
15
+ strategy = ENV['STRATEGY']
16
+ multiple_db = ENV['MULTIPLE_DBS']
3
17
 
4
- orm = ENV['ORM']
5
- strategy = ENV['STRATEGY']
6
18
 
7
19
  if orm && strategy
20
+ $:.unshift(File.dirname(__FILE__) + '/../../../lib')
21
+ require 'database_cleaner'
22
+ require 'database_cleaner/cucumber'
8
23
 
9
24
  begin
10
- require "#{File.dirname(__FILE__)}/../../lib/#{orm}_models"
11
- rescue LoadError
25
+ require "#{File.dirname(__FILE__)}/../../lib/#{orm.downcase}_models"
26
+ rescue LoadError => e
12
27
  raise "You don't have the #{orm} ORM installed"
13
28
  end
14
29
 
15
- $:.unshift(File.dirname(__FILE__) + '/../../../lib')
16
- require 'database_cleaner'
17
- require 'database_cleaner/cucumber'
30
+ if another_orm
31
+ begin
32
+ require "#{File.dirname(__FILE__)}/../../lib/#{another_orm.downcase}_models"
33
+ rescue LoadError => e
34
+ raise "You don't have the #{another_orm} ORM installed"
35
+ end
36
+ end
37
+
38
+
39
+
40
+
41
+ if multiple_db
42
+ DatabaseCleaner.app_root = "#{File.dirname(__FILE__)}/../.."
43
+ orm_sym = orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym
44
+
45
+ if orm_sym == :mongo_mapper
46
+ DatabaseCleaner[ orm_sym, {:connection => 'database_cleaner_test_one'} ].strategy = strategy.to_sym
47
+ DatabaseCleaner[ orm_sym, {:connection => 'database_cleaner_test_two'} ].strategy = strategy.to_sym
48
+ else
49
+ DatabaseCleaner[ orm_sym, {:connection => :one} ].strategy = strategy.to_sym
50
+ DatabaseCleaner[ orm_sym, {:connection => :two} ].strategy = strategy.to_sym
51
+ end
52
+
53
+ elsif another_orm
54
+ DatabaseCleaner[ orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym ].strategy = strategy.to_sym
55
+ DatabaseCleaner[ another_orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym ].strategy = strategy.to_sym
56
+ else
57
+ DatabaseCleaner.strategy = strategy.to_sym
58
+ end
18
59
 
19
- DatabaseCleaner.strategy = strategy.to_sym
20
-
21
60
  else
22
- raise "Run 'ORM=activerecord|datamapper|mongomapper|couchpotato STRATEGY=transaction|truncation cucumber examples/features'"
61
+ raise "Run 'ORM=ActiveRecord|DataMapper|MongoMapper|CouchPotato [ANOTHER_ORM=...] [MULTIPLE_DBS=true] STRATEGY=transaction|truncation cucumber examples/features'"
23
62
  end
@@ -1,12 +1,41 @@
1
1
  require 'active_record'
2
+ databases_config = {
3
+ "one" => {"adapter" => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", "database" => "#{DB_DIR}/activerecord_one.db"},
4
+ "two" => {"adapter" => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", "database" => "#{DB_DIR}/activerecord_two.db"}
5
+ }
2
6
 
3
- ActiveRecord::Base.establish_connection(:adapter => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", :database => ":memory:")
7
+ File.open("#{File.dirname(__FILE__)}/../config/database.yml", 'w') do |file|
8
+ file.write(YAML.dump(databases_config))
9
+ end
10
+
11
+ ["two","one"].each do |db|
12
+ ActiveRecord::Base.establish_connection(databases_config[db])
13
+ ActiveRecord::Base.connection.execute('DROP TABLE IF EXISTS "active_record_widgets"')
14
+ ActiveRecord::Base.connection.execute('DROP TABLE IF EXISTS "active_record_widget_using_database_ones"')
15
+ ActiveRecord::Base.connection.execute('DROP TABLE IF EXISTS "active_record_widget_using_database_twos"')
16
+
17
+ ActiveRecord::Schema.define(:version => 1) do
18
+ create_table :active_record_widgets do |t|
19
+ t.string :name
20
+ end
21
+
22
+ create_table :active_record_widget_using_database_ones do |t|
23
+ t.string :name
24
+ end
4
25
 
5
- ActiveRecord::Schema.define(:version => 1) do
6
- create_table :widgets do |t|
7
- t.string :name
26
+ create_table :active_record_widget_using_database_twos do |t|
27
+ t.string :name
28
+ end
8
29
  end
9
30
  end
10
31
 
11
- class Widget < ActiveRecord::Base
32
+ class ActiveRecordWidget < ActiveRecord::Base
33
+ end
34
+
35
+ class ActiveRecordWidgetUsingDatabaseOne < ActiveRecord::Base
36
+ establish_connection(:adapter => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", :database => "#{DB_DIR}/activerecord_one.db")
37
+ end
38
+
39
+ class ActiveRecordWidgetUsingDatabaseTwo < ActiveRecord::Base
40
+ establish_connection(:adapter => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", :database => "#{DB_DIR}/activerecord_two.db")
12
41
  end
@@ -1,21 +1,61 @@
1
1
  require 'couch_potato'
2
-
2
+ require 'json/pure' unless defined? ::JSON
3
3
  ::CouchPotato::Config.database_name = 'couch_potato_test'
4
4
 
5
- class Widget
5
+ class CouchPotatoWidget
6
+ include CouchPotato::Persistence
7
+
8
+ property :name
9
+ view :by_name, :key => :name
10
+
11
+
12
+ # mimic the AR interface used in example_steps
13
+
14
+ def self.create!(attrs = {})
15
+ CouchPotato.database.save(self.new)
16
+ end
17
+
18
+ def self.count
19
+ CouchPotato.database.view(self.by_name).size
20
+ end
21
+ end
22
+
23
+ class CouchPotatoWidgetUsingDatabaseOne
24
+ include CouchPotato::Persistence
25
+
26
+ database_name = 'couch_potato_test_one'
27
+
28
+ property :name
29
+ view :by_name, :key => :name
30
+
31
+
32
+ # mimic the AR interface used in example_steps
33
+
34
+ def self.create!(attrs = {})
35
+ CouchPotato.database.save(self.new)
36
+ end
37
+
38
+ def self.count
39
+ CouchPotato.database.view(self.by_name).size
40
+ end
41
+ end
42
+
43
+ class CouchPotatoWidgetUsingDatabaseTwo
6
44
  include CouchPotato::Persistence
7
-
45
+
46
+ database_name = 'couch_potato_test_two'
47
+
8
48
  property :name
9
49
  view :by_name, :key => :name
10
-
50
+
11
51
 
12
52
  # mimic the AR interface used in example_steps
13
53
 
14
54
  def self.create!(attrs = {})
15
55
  CouchPotato.database.save(self.new)
16
56
  end
17
-
57
+
18
58
  def self.count
19
- CouchPotato.database.view(::Widget.by_name).size
59
+ CouchPotato.database.view(self.by_name).size
20
60
  end
21
61
  end