Rakefile in spreewald-1.12.0 vs Rakefile in spreewald-1.12.1
- old
+ new
@@ -1,17 +1,42 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
-desc 'Default: Run all tests.'
-task :default => 'all:rubies'
-
begin
- require 'rspec/core/rake_task'
- RSpec::Core::RakeTask.new(:spec)
+ require 'gemika/tasks'
rescue LoadError
+ puts 'Run `gem install gemika` for additional tasks'
end
+task :default => 'matrix:all_tests'
+
+namespace :matrix do
+
+ desc "Run all tests which are available for current Ruby (#{RUBY_VERSION})"
+ task :tests do
+ Gemika::Matrix.from_travis_yml.each do |row|
+ directory = File.dirname(row.gemfile)
+ if directory.start_with?('tests')
+ # Run integration tests (uses embedded projects)
+ system("cd #{directory} && BUNDLE_GEMFILE=Gemfile geordi cucumber")
+ else
+ # Run specs and tests for spreewald binary
+ [
+ system("BUNDLE_GEMFILE=#{row.gemfile} bundle exec rspec"),
+ system("BUNDLE_GEMFILE=#{row.gemfile} bundle exec cucumber"),
+ ].all?
+ end
+ end
+
+ travis_yml = YAML.load_file('.travis.yml')
+ rubies = travis_yml.fetch('rvm') - [RUBY_VERSION]
+ puts "Please remember to run tests for the other ruby versions as well: #{rubies.join(", ")}"
+ end
+
+end
+
+
desc 'Update the "Steps" section of the README'
task :update_readme do
readme_path = 'README.md'
if Kernel.respond_to? :require_relative
require_relative './support/step_manager'
@@ -27,88 +52,8 @@
system "git diff #{readme_path}"
puts '', '> Done (diff applied).'
end
-namespace :all do
-
- desc 'Run tests on all test apps'
- task :features do
- success = true
- for_each_directory_of('tests/**/Rakefile') do |directory|
- success &= system("cd #{directory} && geordi cucumber")
- end
- fail "Tests failed" unless success
- end
-
- desc 'Install gems and run tests on several Ruby versions'
- task :rubies do
- success = case
- when system('which rvm')
- run_for_all_rubies :rvm
- when system('which rbenv') && `rbenv commands`.split("\n").include?('alias')
- # rbenv currently works only with the alias plugin, as we do not want to
- # specify Ruby versions down to their patch levels.
- run_for_all_rubies :rbenv
- else
- fail 'Currently only RVM and rbenv (with alias plugin) are supported. Open Rakefile and add your Ruby version manager!'
- end
-
- fail "Tests failed" unless success
- end
-
- desc 'Bundle all test apps'
- task :bundle do
- for_each_directory_of('tests/**/Gemfile') do |directory|
- system("cd #{directory} && bundle install && gem install geordi")
- end
- end
-
-end
-
-def run_for_all_rubies(version_manager)
- %w[
- 1.8.7
- 1.9.3
- 2.1.2
- ].all? do |ruby_version|
- announce "Running features for Ruby #{ruby_version}", 2
-
- execute = case version_manager
- when :rvm
- "rvm #{ruby_version} do"
- when :rbenv
- ENV['RBENV_VERSION'] = ruby_version
- 'rbenv exec'
- end
-
- current_version = `#{execute} ruby -v`.match(/^ruby (\d\.\d\.\d)/)[1]
- if current_version == ruby_version
- puts "Currently active Ruby is #{current_version}"
- system "#{execute} bundle"
- system "#{execute} rake all:bundle spec all:features"
- else
- fail "Failed to set Ruby #{ruby_version} (#{current_version} active!)"
- end
- end
-end
-
-def for_each_directory_of(path, &block)
- Dir[path].sort.each do |rakefile|
- directory = File.dirname(rakefile)
- announce directory
-
- if directory.include?('rails-2.3') and RUBY_VERSION != '1.8.7'
- puts 'Rails 2.3 tests are only run for Ruby 1.8.7'
- elsif directory.include?('capybara-2') and RUBY_VERSION == '1.8.7'
- puts 'Capybara 2 requires Ruby 1.9 or greater'
- else
- block.call(directory)
- end
- end
-end
-
-def announce(text, level = 1)
- space = "\n" * level
- message = "# #{text}"
- puts "\e[4;34m#{space + message}\e[0m" # blue underline
+def warn(text)
+ puts "\e[31m#{text}\e[0m" # red text
end