forked from brianhempel/mongo_session_store
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
66 lines (48 loc) · 1.59 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
require 'rubygems'
require 'rake'
def run_with_output(command)
puts "Running: #{command}"
Process.wait( fork { exec command } )
$?.success?
end
def set_rails_version(rails_vers)
unless File.exists?("Gemfile_Rails_#{rails_vers}.lock")
run_with_output "export RAILS_VERS=#{rails_vers}; bundle update"
run_with_output "cp Gemfile.lock Gemfile_Rails_#{rails_vers}.lock"
else
run_with_output "rm Gemfile.lock"
run_with_output "cp Gemfile_Rails_#{rails_vers}.lock Gemfile.lock"
end
end
@rails_versions = ['3.0', '3.1', '3.2']
task :default => :test_all
desc 'Test each session store against Rails 3.0 and Rails 3.1'
task :test_all do
# inspired by http://pivotallabs.com/users/jdean/blog/articles/1728-testing-your-gem-against-multiple-rubies-and-rails-versions-with-rvm
orms = ['mongo_mapper', 'mongoid', 'mongo']
@failed_suites = []
@rails_versions.each do |rails_version|
set_rails_version(rails_version)
orms.each do |orm|
unless run_with_output "export MONGO_SESSION_STORE_ORM=#{orm}; bundle exec rspec spec"
@failed_suites << "Rails #{rails_version} / #{orm}"
end
end
end
if @failed_suites.any?
puts "\033[0;31mFailed:"
puts @failed_suites.join("\n")
print "\033[0m"
exit(1)
else
print "\033[0;32mAll passed! Success! "
"Yahoooo!!!".chars.each { |c| sleep 0.4; print c; STDOUT.flush }
puts "\033[0m"
end
end
@rails_versions.each do |rails_version|
desc "Set Rails version to #{rails_version}"
task :"use_rails_#{rails_version.gsub('.', '')}" do
set_rails_version(rails_version)
end
end