Sha256: 63277e9b9bbcd27c7b6d1225a12842e0f0e833c462fa903492c632c6ce6da4f5
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
require File.join(File.dirname(__FILE__), "../_lib") module MoSQL class Test::Functional < MoSQL::Test attr_reader :sequel, :mongo def sql_test_uri ENV['MONGOSQL_TEST_SQL'] || 'postgres:///test' end def mongo_test_uri ENV['MONGOSQL_TEST_MONGO'] || 'mongodb://localhost' end def mongo_test_dbname ENV['MONGOSQL_TEST_MONGO_DB'] || 'test' end def connect_sql begin conn = Sequel.connect(sql_test_uri) conn.extension :pg_array conn.test_connection conn rescue Sequel::DatabaseConnectionError $stderr.puts <<EOF ********************************************************************* Unable to connect to PostgreSQL database at `#{sql_test_uri}'. Either configure a PostgresSQL database running locally without authentication with a 'test' database, or set \$MONGOSQL_TEST_SQL in the environment. ********************************************************************* EOF exit(1) end end def connect_mongo begin Mongo::Connection.from_uri(mongo_test_uri) rescue Mongo::ConnectionFailure, Mongo::ConnectionError $stderr.puts <<EOF ********************************************************************* Unable to connect to MongoDB database at `#{mongo_test_uri}'. Either configure a MongoDB database running on localhost without authentication with a 'test' database, or set \$MONGOSQL_TEST_MONGO in the environment. ********************************************************************* EOF exit(1) end end def mongo_db mongo.db(mongo_test_dbname) end def setup @sequel = connect_sql @mongo = connect_mongo super end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mosql-0.3.2 | test/functional/_lib.rb |