forked from upmin/upmin-admin-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
122 lines (92 loc) · 3.28 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env rake
# encoding: utf-8
require 'bundler/gem_tasks'
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
task :default => "spec:all"
def update_files(gemfile = nil)
# Drop and reload spec files
sh "rm -rf spec/"
sh "cp -R ../../spec spec"
sh "cp ../../.rspec .rspec"
# Copy gemfile specific specs if they exist
if Dir.exists?("../../spec_#{gemfile}")
sh "cp -R ../../spec_#{gemfile} spec/#{gemfile}"
end
# Drop and reload Upmin::Model files
sh "rm -rf app/upmin/"
sh "cp -R ../../test_app_upmin app/upmin"
end
namespace :spec do
# Full bundle install & test.
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate data_mapper).each do |gemfile|
desc "Run Tests against #{gemfile}"
task "#{gemfile}" do
Dir.chdir("test_apps/#{gemfile}") do
puts "Testing in #{`pwd`}"
sh "bundle install --quiet"
sh "bundle update --quiet"
# Drop migrations and recreate
sh "rm -rf db/migrate/*"
if gemfile != "data_mapper"
sh "bundle exec rake railties:install:migrations > /dev/null"
end
if gemfile == "active_record_32"
sh "bundle exec rake db:drop db:create db:migrate --quiet > /dev/null"
end
sh "RAILS_ENV=test bundle exec rake db:drop db:create db:migrate --quiet > /dev/null"
update_files
# Run tests
sh "bundle exec rake"
end
end
end
# Use existing models & install and just rake.
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate data_mapper).each do |gemfile|
desc "Run Tests against #{gemfile}"
task "#{gemfile}_quick" do
Dir.chdir("test_apps/#{gemfile}")
puts "Re-testing in #{`pwd`}. Bundle install and migration updates will NOT happen!"
update_files
# Run tests
sh "bundle exec rake"
end
end
desc "Run Tests with namespaced models"
task :namespaced_model do
Dir.chdir("test_apps/namespaced_model")
puts "Testing in #{`pwd`}"
sh "bundle install --quiet"
sh "bundle update --quiet"
# Drop migrations and recreate
sh "rm -rf db/migrate/*.test_models.rb"
sh "bundle exec rake railties:install:migrations > /dev/null"
sh "RAILS_ENV=test bundle exec rake db:drop db:create db:migrate db:seed --quiet > /dev/null"
update_files("namespaced_model")
# Run tests
sh "bundle exec rake"
end
desc "Run Tests with namespaced models quickly (no bundle install etc)"
task :namespaced_model_quick do
Dir.chdir("test_apps/namespaced_model")
puts "Re-Testing in #{`pwd`}. Bundle install and migration updates will NOT happen!"
update_files("namespaced_model")
# Run tests
sh "bundle exec rake"
end
desc "Run Tests against all ORMs"
task :all do
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate data_mapper namespaced_model).each do |gemfile|
sh "rake spec:#{gemfile}"
end
end
desc "Run Tests against all ORMs"
task :all_quick do
%w(active_record_32 active_record_40 active_record_41 active_record_42 will_paginate data_mapper namespaced_model).each do |gemfile|
sh "rake spec:#{gemfile}_quick"
end
end
end