File tree Expand file tree Collapse file tree 1 file changed +25
-20
lines changed Expand file tree Collapse file tree 1 file changed +25
-20
lines changed Original file line number Diff line number Diff line change @@ -8,31 +8,36 @@ load "rails/tasks/engine.rake"
8
8
load "rails/tasks/statistics.rake"
9
9
10
10
require "bundler/gem_tasks"
11
+ require "rake/tasklib"
11
12
12
- def databases
13
- %w[ mysql postgres sqlite ]
14
- end
15
-
16
- task :test do
17
- databases . each do |database |
18
- sh ( "TARGET_DB=#{ database } bin/setup" )
19
- sh ( "TARGET_DB=#{ database } bin/rails test" )
13
+ class TestHelpers < Rake ::TaskLib
14
+ def initialize ( databases )
15
+ @databases = databases
16
+ define
20
17
end
21
- end
22
18
23
- namespace :test do
24
- task :mysql do
25
- sh ( "TARGET_DB=mysql bin/setup" )
26
- sh ( "TARGET_DB=mysql bin/rails test" )
19
+ def define
20
+ desc "Run tests for all databases (mysql, postgres, sqlite)"
21
+ task :test do
22
+ @databases . each { |database | run_test_for_database ( database ) }
23
+ end
24
+
25
+ namespace :test do
26
+ @databases . each do |database |
27
+ desc "Run tests for #{ database } database"
28
+ task database do
29
+ run_test_for_database ( database )
30
+ end
31
+ end
32
+ end
27
33
end
28
34
29
- task :postgres do
30
- sh ( "TARGET_DB=postgres bin/setup" )
31
- sh ( "TARGET_DB=postgres bin/rails test" )
32
- end
35
+ private
33
36
34
- task :sqlite do
35
- sh ( "TARGET_DB=sqlite bin/setup" )
36
- sh ( "TARGET_DB=sqlite bin/rails test" )
37
+ def run_test_for_database ( database )
38
+ sh ( "TARGET_DB=#{ database } bin/setup" )
39
+ sh ( "TARGET_DB=#{ database } bin/rails test" )
37
40
end
38
41
end
42
+
43
+ TestHelpers . new ( %w[ mysql postgres sqlite ] )
You can’t perform that action at this time.
0 commit comments