Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mechanicles committed Aug 8, 2023
1 parent ace245c commit 1d64fc4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
26 changes: 15 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/mysql_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class MysqlTest < ActiveSupport::TestCase
include PolymorphicAssociationTests
include ExceptionsTests

print_test_adapter_info 'mysql'

def setup
super
@@setup ||= begin
Expand Down
2 changes: 2 additions & 0 deletions test/postgresql_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class PostgresqlTest < ActiveSupport::TestCase
include PolymorphicAssociationTests
include ExceptionsTests

print_test_adapter_info 'postgresql'

def setup
super
@@setup ||= begin
Expand Down
2 changes: 2 additions & 0 deletions test/sqlite_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class SqliteTest < ActiveSupport::TestCase
include PolymorphicAssociationTests
include ExceptionsTests

print_test_adapter_info 'sqlite'

def setup
super
@@setup ||= begin
Expand Down
8 changes: 6 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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

0 comments on commit 1d64fc4

Please sign in to comment.