diff --git a/Rakefile b/Rakefile index 7fac5e0..8483096 100644 --- a/Rakefile +++ b/Rakefile @@ -3,19 +3,23 @@ require "bundler/gem_tasks" require "rake/testtask" -Rake::TestTask.new(:postgresql) do |t| - t.libs << "test" - t.test_files = FileList["test/postgresql_test.rb"] -end +ADAPTERS = %w[postgresql mysql sqlite].freeze -Rake::TestTask.new(:mysql) do |t| - t.libs << "test" - t.test_files = FileList["test/mysql_test.rb"] +ADAPTERS.each do |adapter| + namespace :test do + Rake::TestTask.new(adapter) do |t| + t.description = "Run #{adapter} tests" + t.libs << "test" + t.test_files = FileList["test/#{adapter}_test.rb"] + end + end end -Rake::TestTask.new(:sqlite) do |t| - t.libs << "test" - t.test_files = FileList["test/sqlite_test.rb"] +desc "Run all tests" +task :test do + ADAPTERS.each do |adapter| + Rake::Task["test:#{adapter}"].invoke + end end -task default: [:postgresql, :mysql, :sqlite] +task default: :test diff --git a/test/mysql_test.rb b/test/mysql_test.rb index 37b62cf..b28a1f8 100644 --- a/test/mysql_test.rb +++ b/test/mysql_test.rb @@ -10,6 +10,8 @@ class MysqlTest < ActiveSupport::TestCase include PolymorphicAssociationTests include ExceptionsTests + print_test_adapter_info 'mysql' + def setup super @@setup ||= begin diff --git a/test/postgresql_test.rb b/test/postgresql_test.rb index 4716754..8d2db9d 100644 --- a/test/postgresql_test.rb +++ b/test/postgresql_test.rb @@ -9,6 +9,8 @@ class PostgresqlTest < ActiveSupport::TestCase include PolymorphicAssociationTests include ExceptionsTests + print_test_adapter_info 'postgresql' + def setup super @@setup ||= begin diff --git a/test/sqlite_test.rb b/test/sqlite_test.rb index dcc0898..fa999e7 100644 --- a/test/sqlite_test.rb +++ b/test/sqlite_test.rb @@ -9,6 +9,8 @@ class SqliteTest < ActiveSupport::TestCase include PolymorphicAssociationTests include ExceptionsTests + print_test_adapter_info 'sqlite' + def setup super @@setup ||= begin diff --git a/test/test_helper.rb b/test/test_helper.rb index 7eee279..2218f32 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "simplecov" -SimpleCov.start +# require "simplecov" +# SimpleCov.start require "bundler/setup" Bundler.require(:default) require "minitest/autorun" @@ -348,3 +348,7 @@ def test_error_with_wrong_owner_key assert_equal("Association named 'person' was not found on Class; perhaps you misspelled it?", e.message) end end + +def print_test_adapter_info(adapter) + puts "Running tests for #{adapter} adapter" +end