2010-02-03 20:17:37 -05:00
|
|
|
require 'couch_potato'
|
2010-06-15 10:24:50 -04:00
|
|
|
require 'json/pure' unless defined? ::JSON
|
2010-02-03 20:17:37 -05:00
|
|
|
::CouchPotato::Config.database_name = 'couch_potato_test'
|
|
|
|
|
2010-05-30 14:29:42 -04:00
|
|
|
class CouchPotatoWidget
|
2010-02-03 20:17:37 -05:00
|
|
|
include CouchPotato::Persistence
|
2010-05-30 23:12:58 -04:00
|
|
|
|
2010-02-03 20:17:37 -05:00
|
|
|
property :name
|
|
|
|
view :by_name, :key => :name
|
2010-05-30 23:12:58 -04:00
|
|
|
|
2010-02-03 20:17:37 -05:00
|
|
|
|
|
|
|
# mimic the AR interface used in example_steps
|
|
|
|
|
|
|
|
def self.create!(attrs = {})
|
|
|
|
CouchPotato.database.save(self.new)
|
|
|
|
end
|
2010-05-30 23:12:58 -04:00
|
|
|
|
2010-02-03 20:17:37 -05:00
|
|
|
def self.count
|
2010-05-25 13:21:45 -04:00
|
|
|
CouchPotato.database.view(self.by_name).size
|
2010-02-03 20:17:37 -05:00
|
|
|
end
|
|
|
|
end
|
2010-05-16 17:26:09 -04:00
|
|
|
|
2010-05-30 14:29:42 -04:00
|
|
|
class CouchPotatoWidgetUsingDatabaseOne
|
|
|
|
include CouchPotato::Persistence
|
2010-05-30 23:12:58 -04:00
|
|
|
|
2010-05-30 14:29:42 -04:00
|
|
|
database_name = 'couch_potato_test_one'
|
2010-05-30 23:12:58 -04:00
|
|
|
|
2010-05-30 14:29:42 -04:00
|
|
|
property :name
|
|
|
|
view :by_name, :key => :name
|
2010-05-30 23:12:58 -04:00
|
|
|
|
2010-05-30 14:29:42 -04:00
|
|
|
|
|
|
|
# mimic the AR interface used in example_steps
|
|
|
|
|
|
|
|
def self.create!(attrs = {})
|
|
|
|
CouchPotato.database.save(self.new)
|
|
|
|
end
|
2010-05-30 23:12:58 -04:00
|
|
|
|
2010-05-30 14:29:42 -04:00
|
|
|
def self.count
|
|
|
|
CouchPotato.database.view(self.by_name).size
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class CouchPotatoWidgetUsingDatabaseTwo
|
|
|
|
include CouchPotato::Persistence
|
|
|
|
|
|
|
|
database_name = 'couch_potato_test_two'
|
2010-05-30 23:12:58 -04:00
|
|
|
|
2010-05-30 14:29:42 -04:00
|
|
|
property :name
|
|
|
|
view :by_name, :key => :name
|
2010-05-30 23:12:58 -04:00
|
|
|
|
2010-05-30 14:29:42 -04:00
|
|
|
|
|
|
|
# mimic the AR interface used in example_steps
|
|
|
|
|
|
|
|
def self.create!(attrs = {})
|
|
|
|
CouchPotato.database.save(self.new)
|
2010-05-16 17:26:09 -04:00
|
|
|
end
|
2010-05-30 23:12:58 -04:00
|
|
|
|
2010-05-30 14:29:42 -04:00
|
|
|
def self.count
|
|
|
|
CouchPotato.database.view(self.by_name).size
|
2010-05-16 17:26:09 -04:00
|
|
|
end
|
|
|
|
end
|