-
Notifications
You must be signed in to change notification settings - Fork 86
/
Rakefile
60 lines (49 loc) · 1.34 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
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
# bunlder tasks
Bundler::GemHelper.install_tasks
# dummy app tasks
require 'rake'
load File.expand_path('spec/dummy/Rakefile')
ENV["RAILS_ENV"] = "test"
# spec tasks
require 'rspec/core'
require 'rspec/core/rake_task'
# Add two methods to Rake::Task
class Rake::Task
def overwrite(&block)
@actions.clear
prerequisites.clear
enhance(&block)
end
def abandon
prerequisites.clear
@actions.clear
end
end
# Remove orginial `rake spec`
Rake::Task[:spec].abandon
RSpec::Core::RakeTask.new(:spec => 'db:test:prepare') do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
task :default => "spec:all"
namespace :spec do
%w(rails_42 rails_41 rails_40 rails_32).each do |gemfile|
desc "Run Tests against #{gemfile}"
task gemfile do
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake spec"
end
end
desc "Run Tests against rails versions"
task :all do
%w(rails_42 rails_41 rails_40 rails_32).each do |gemfile|
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake spec"
end
end
end