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