@@ -4,12 +4,25 @@ desc "Run unit tests"
4
4
task :default => 'test:unit'
5
5
task :test => 'test:unit'
6
6
7
- namespace :bundler do
8
- desc "Install dependencies for all the Gemfiles"
7
+ if RUBY_VERSION < '2.3'
8
+ GEMFILES = [ '3.0.gemfile' , '4.0.gemfile' , '5.0.gemfile' ]
9
+ else
10
+ GEMFILES = [ '4.0.gemfile' , '5.0.gemfile' ]
11
+ end
12
+
13
+ namespace :bundle do
14
+ desc 'Install dependencies for all the Gemfiles in /gemfiles. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0'
9
15
task :install do
10
- sh "BUNDLE_GEMFILE='#{ File . expand_path ( '../gemfiles/3.0.gemfile' , __FILE__ ) } ' bundle install"
11
- sh "BUNDLE_GEMFILE='#{ File . expand_path ( '../gemfiles/4.0.gemfile' , __FILE__ ) } ' bundle install"
12
- sh "BUNDLE_GEMFILE='#{ File . expand_path ( '../gemfiles/5.0.gemfile' , __FILE__ ) } ' bundle install"
16
+ unless defined? ( JRUBY_VERSION )
17
+ puts '-' *80
18
+ gemfiles = ENV [ 'RAILS_VERSIONS' ] ? ENV [ 'RAILS_VERSIONS' ] . split ( ',' ) . map { |v | "#{ v } .gemfile" } : GEMFILES
19
+ gemfiles . each do |gemfile |
20
+ Bundler . with_clean_env do
21
+ sh "bundle install --gemfile #{ File . expand_path ( '../gemfiles/' +gemfile , __FILE__ ) } "
22
+ end
23
+ puts '-' *80
24
+ end
25
+ end
13
26
end
14
27
end
15
28
18
31
require 'rake/testtask'
19
32
namespace :test do
20
33
21
- Rake ::TestTask . new ( :run_unit ) do |test |
22
- test . libs << 'lib' << 'test'
23
- test . test_files = FileList [ "test/unit/**/*_test.rb" ]
24
- test . verbose = false
25
- test . warning = false
26
- end
27
-
28
- Rake ::TestTask . new ( :run_integration ) do |test |
29
- test . libs << 'lib' << 'test'
30
- test . test_files = FileList [ "test/integration/**/*_test.rb" ]
31
- test . verbose = false
32
- test . warning = false
33
- end
34
-
35
- desc "Run unit tests against ActiveModel 3, 4 and 5"
36
- task :unit do
37
- end
38
-
39
- desc "Run integration tests against latest stable ActiveModel (5)"
40
- task :integration do
41
- [ '3.0.gemfile' , '4.0.gemfile' , '5.0.gemfile' ] . each do |gemfile |
42
- [ 'bundle exec rake test:run_unit' , 'bundle exec rspec' ] . each do |cmd |
43
- sh "BUNDLE_GEMFILE='#{ File . expand_path ( '../gemfiles/' +gemfile , __FILE__ ) } ' #{ cmd } "
34
+ desc 'Run all tests. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0'
35
+ task :all , [ :rails_versions ] do |task , args |
36
+ unless defined? ( JRUBY_VERSION )
37
+ gemfiles = ENV [ 'RAILS_VERSIONS' ] ? ENV [ 'RAILS_VERSIONS' ] . split ( ',' ) . map { |v | "#{ v } .gemfile" } : GEMFILES
38
+ puts '-' *80
39
+ gemfiles . each do |gemfile |
40
+ sh "BUNDLE_GEMFILE='#{ File . expand_path ( "../gemfiles/#{ gemfile } " , __FILE__ ) } ' " +
41
+ " bundle exec rspec"
42
+ puts '-' *80
44
43
end
45
44
end
46
45
end
47
-
48
- desc "Run unit and integration tests"
49
- task :all do
50
- Rake ::Task [ 'test:unit' ] . invoke
51
- Rake ::Task [ 'test:integration' ] . invoke
52
- end
53
46
end
54
47
55
48
# ----- Documentation tasks ---------------------------------------------------
0 commit comments