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"
88load "rails/tasks/statistics.rake"
99
1010require "bundler/gem_tasks"
11+ require "rake/tasklib"
1112
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
2017 end
21- end
2218
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
2733 end
2834
29- task :postgres do
30- sh ( "TARGET_DB=postgres bin/setup" )
31- sh ( "TARGET_DB=postgres bin/rails test" )
32- end
35+ private
3336
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" )
3740 end
3841end
42+
43+ TestHelpers . new ( %w[ mysql postgres sqlite ] )
You can’t perform that action at this time.
0 commit comments