forked from soundcloud/master_slave_adapter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
59 lines (48 loc) · 1.38 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
require 'bundler'
require 'rspec/core/rake_task'
Bundler::GemHelper.install_tasks
class MasterSlaveAdapterRSpecTask < RSpec::Core::RakeTask
attr_accessor :exclude
private
def files_to_run
FileList[ pattern ].exclude(exclude)
end
end
def mysql2_adapter_available?
require 'active_record/connection_adapters/mysql2_adapter'
true
rescue LoadError
false
rescue
true
end
desc 'Default: Run specs'
task :default => :spec
desc 'Run specs'
task :spec => ['spec:common', 'spec:integration']
namespace :spec do
desc 'Run common specs'
MasterSlaveAdapterRSpecTask.new(:common) do |task|
task.pattern = './spec/common/*_spec.rb'
task.exclude = /mysql2/ unless mysql2_adapter_available?
task.verbose = false
end
desc 'Run integration specs'
task :integration => ['spec:integration:check', 'spec:integration:all']
namespace :integration do
desc 'Check requirements'
task :check do
[:mysql, :mysqld, :mysql_install_db].each do |executable|
unless system("which #{executable} > /dev/null")
raise "Can't run integration tests. #{executable} is not available in $PATH"
end
end
end
desc 'Run all integration specs'
MasterSlaveAdapterRSpecTask.new(:all) do |task|
task.pattern = './spec/integration/*_spec.rb'
task.exclude = /mysql2/ unless mysql2_adapter_available?
task.verbose = false
end
end
end