forked from bdurand/seamless_database_pool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
65 lines (57 loc) · 1.74 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# frozen_string_literal: true
require 'rubygems'
require 'rake'
require 'yaml'
require 'bundler/gem_tasks'
desc 'Default: run unit tests.'
task default: :test
begin
require 'rspec'
require 'rspec/core/rake_task'
rescue LoadError
task :test do
warn 'You must have rspec >= 2.0 to run the tests'
end
end
desc 'Run the unit tests'
RSpec::Core::RakeTask.new(:test)
namespace :test do
desc 'Run all tests including for all database adapters'
task :all do
save_val = ENV.fetch('TEST_ADAPTERS', nil)
begin
ENV['TEST_ADAPTERS'] = YAML.load_file(File.expand_path('spec/database.yml', __dir__)).keys.join(' ')
Rake::Task['test'].execute
ensure
ENV['TEST_ADAPTERS'] = save_val
end
end
desc 'Test all database adapters defined in database.yml or just the one specified in TEST_ADAPTERS'
task :adapters do
save_val = ENV.fetch('TEST_ADAPTERS', nil)
begin
ENV['TEST_ADAPTERS'] ||= YAML.load_file(File.expand_path('spec/database.yml', __dir__)).keys.join(' ')
Rake::Task['test:adapters:specified'].execute
ensure
ENV['TEST_ADAPTERS'] = save_val
end
end
namespace :adapters do
desc 'Internal task to run database adapter tests'
RSpec::Core::RakeTask.new(:specified) do |t|
t.pattern = FileList.new('spec/connection_adapters_spec.rb')
end
YAML.load_file(File.expand_path('spec/database.yml', __dir__)).each_key do |adapter_name|
desc "Test the #{adapter_name} database adapter"
task adapter_name do
save_val = ENV.fetch('TEST_ADAPTERS', nil)
begin
ENV['TEST_ADAPTERS'] = adapter_name
Rake::Task['test:adapters:specified'].execute
ensure
ENV['TEST_ADAPTERS'] = save_val
end
end
end
end
end