2011-01-17 01:43:07 +01:00
|
|
|
require "bundler/setup"
|
2008-12-19 11:09:20 +01:00
|
|
|
require "rubygems"
|
2010-08-18 19:36:01 +02:00
|
|
|
require "rspec" # Satisfies Autotest and anyone else not using the Rake tasks
|
2008-12-19 11:09:20 +01:00
|
|
|
|
2010-06-20 22:01:11 +02:00
|
|
|
require File.join(File.dirname(__FILE__), '..','lib','couchrest_model')
|
2009-02-06 02:06:12 +01:00
|
|
|
# check the following file to see how to use the spec'd features.
|
2008-07-05 01:56:37 +02:00
|
|
|
|
2009-01-13 04:50:00 +01:00
|
|
|
unless defined?(FIXTURE_PATH)
|
2009-01-30 03:45:01 +01:00
|
|
|
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"
|
2010-06-20 22:01:11 +02:00
|
|
|
TESTDB = 'couchrest-model-test'
|
2010-09-30 00:11:59 +02:00
|
|
|
TEST_SERVER = CouchRest.new COUCHHOST
|
2009-01-30 03:45:01 +01:00
|
|
|
TEST_SERVER.default_database = TESTDB
|
2009-05-28 03:16:50 +02:00
|
|
|
DB = TEST_SERVER.database(TESTDB)
|
2009-01-13 04:50:00 +01:00
|
|
|
end
|
2008-11-09 01:28:58 +01:00
|
|
|
|
2010-06-20 22:01:11 +02:00
|
|
|
class Basic < CouchRest::Model::Base
|
2009-02-25 07:51:13 +01:00
|
|
|
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
|
2009-05-28 03:16:50 +02:00
|
|
|
DB
|
2009-03-21 05:14:42 +01:00
|
|
|
end
|
|
|
|
|
2010-08-18 19:36:01 +02:00
|
|
|
RSpec.configure do |config|
|
2009-03-21 05:14:42 +01:00
|
|
|
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|
|
2011-02-06 17:17:14 +01:00
|
|
|
cr.database(db).delete! rescue nil
|
2009-03-21 05:14:42 +01:00
|
|
|
end
|
|
|
|
end
|
2010-03-11 18:17:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def couchdb_lucene_available?
|
|
|
|
lucene_path = "http://localhost:5985/"
|
|
|
|
url = URI.parse(lucene_path)
|
|
|
|
req = Net::HTTP::Get.new(url.path)
|
|
|
|
res = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
|
|
|
|
true
|
|
|
|
rescue Exception => e
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|