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