forked from svenfuchs/i18n-active_record
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
61 lines (48 loc) · 1.14 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
require 'rake'
require 'rake/testtask'
require 'bundler/gem_tasks'
def execute(command)
puts command
system command
end
def bundle_options
opt = ''
opt += "--gemfile #{ENV['BUNDLE_GEMFILE']}" if ENV['BUNDLE_GEMFILE']
end
def each_database(&block)
['sqlite', 'postgres', 'mysql'].each &block
end
namespace :bundle do
task :env do
ar = ENV['AR'].to_s
next if ar.empty?
gemfile = "gemfiles/Gemfile.rails_#{ar}"
raise "Cannot find gemfile at #{gemfile}" unless File.exist?(gemfile)
ENV['BUNDLE_GEMFILE'] = gemfile
puts "Using gemfile: #{gemfile}"
end
task install: :env do
execute "bundle install #{bundle_options}"
end
task :install_all do
[nil, '3', '4', '5', 'master'].each do |ar|
opt = ar && "AR=#{ar}"
execute "rake bundle:install #{opt}"
end
end
end
task :test do
each_database { |db| execute "rake #{db}:test" }
end
Rake::TestTask.new :_test do |t|
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
each_database do |db|
namespace db do
task(:env) { ENV['DB'] = db }
task test: ['env', 'bundle:env', '_test']
end
end
task default: :test