forked from rails-sqlserver/activerecord-sqlserver-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
44 lines (36 loc) · 1.92 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'rubygems'
require 'rake'
require 'rake/testtask'
desc 'Create the SQL Server test databases'
task :create_databases do
# Define a user named 'rails' in SQL Server with all privileges granted
# Use an empty password for user 'rails', or alternatively use the OSQLPASSWORD environment variable
# which allows you to set a default password for the current session.
%x( osql -S localhost -U rails -Q "create database activerecord_unittest" -P )
%x( osql -S localhost -U rails -Q "create database activerecord_unittest2" -P )
%x( osql -S localhost -U rails -d activerecord_unittest -Q "exec sp_grantdbaccess 'rails'" -P )
%x( osql -S localhost -U rails -d activerecord_unittest2 -Q "exec sp_grantdbaccess 'rails'" -P )
%x( osql -S localhost -U rails -d activerecord_unittest -Q "grant BACKUP DATABASE, BACKUP LOG, CREATE DEFAULT, CREATE FUNCTION, CREATE PROCEDURE, CREATE RULE, CREATE TABLE, CREATE VIEW to 'rails';" -P )
%x( osql -S localhost -U rails -d activerecord_unittest2 -Q "grant BACKUP DATABASE, BACKUP LOG, CREATE DEFAULT, CREATE FUNCTION, CREATE PROCEDURE, CREATE RULE, CREATE TABLE, CREATE VIEW to 'rails';" -P )
end
desc 'Drop the SQL Server test databases'
task :drop_databases do
%x( osql -S localhost -U rails -Q "drop database activerecord_unittest" -P )
%x( osql -S localhost -U rails -Q "drop database activerecord_unittest2" -P )
end
desc 'Recreate the SQL Server test databases'
task :recreate_databases => [:drop_databases, :create_databases]
for adapter in %w( sqlserver sqlserver_odbc )
Rake::TestTask.new("test_#{adapter}") { |t|
t.libs << "test"
t.libs << "test/connections/native_#{adapter}"
t.libs << "../../../rails/activerecord/test/"
t.test_files = (
Dir.glob("test/cases/**/*_test_sqlserver.rb").sort +
Dir.glob("../../../rails/activerecord/test/**/*_test.rb").sort )
t.verbose = true
}
namespace adapter do
task :test => "test_#{adapter}"
end
end