couchrest_model/spec/spec_helper.rb

37 lines
985 B
Ruby
Raw Normal View History

2008-12-19 11:09:20 +01:00
require "rubygems"
require "spec" # Satisfies Autotest and anyone else not using the Rake tasks
require File.join(File.dirname(__FILE__), '..','lib','couchrest')
# check the following file to see how to use the spec'd features.
2009-01-13 04:50:00 +01:00
unless defined?(FIXTURE_PATH)
FIXTURE_PATH = File.join(File.dirname(__FILE__), '/fixtures')
SCRATCH_PATH = File.join(File.dirname(__FILE__), '/tmp')
2008-10-15 00:08:17 +02:00
2009-01-13 04:50:00 +01:00
COUCHHOST = "http://127.0.0.1:5984"
TESTDB = 'couchrest-test'
TEST_SERVER = CouchRest.new
TEST_SERVER.default_database = TESTDB
DB = TEST_SERVER.database(TESTDB)
2009-01-13 04:50:00 +01:00
end
2008-11-09 01:28:58 +01:00
class Basic < CouchRest::ExtendedDocument
use_database TEST_SERVER.default_database
end
2008-11-09 01:28:58 +01:00
def reset_test_db!
2009-07-15 08:48:06 +02:00
DB.recreate! rescue nil
DB
end
Spec::Runner.configure do |config|
config.before(:all) { reset_test_db! }
config.after(:all) do
cr = TEST_SERVER
test_dbs = cr.databases.select { |db| db =~ /^#{TESTDB}/ }
test_dbs.each do |db|
cr.database(db).delete! rescue nil
end
end
2008-11-09 01:28:58 +01:00
end