Rakefile in spreewald-0.9.0 vs Rakefile in spreewald-0.9.1

- old
+ new

@@ -17,56 +17,67 @@ length_of_steps_section = (readme[(start_of_steps_section+1)..-1] =~ /^##[^#]/) || readme.size - start_of_steps_section readme[start_of_steps_section, length_of_steps_section] = "## Steps\n\n" + DocumentationGenerator::StepDefinitionsDirectory.new('lib/spreewald').format File.open('README.md', 'w') { |f| f.write(readme) } end -namespace :travis do - - desc 'Run tests in Travis CI' - task :run => [:slimgems, 'all:bundle', 'all:features'] - - desc 'Install slimgems' - task :slimgems do - sh 'gem install slimgems' unless modern_ruby? - end -end - namespace :all do - desc "Run tests on all test apps" + desc 'Run tests on all test apps' task :features do success = true for_each_directory_of('tests/**/Rakefile') do |directory| Bundler.with_clean_env do env = "FEATURE=../../#{ENV['FEATURE']}" if ENV['FEATURE'] success &= system("cd #{directory} && bundle exec rake features #{env}") end end fail "Tests failed" unless success end + + desc 'Run tests on several Ruby versions' + task :rubies do + rubies = %w[1.8.7 1.9.3 2.0.0] + success = true - desc "Bundle all test apps" + if system('rvm -v 2>&1 > /dev/null') # rvm installed + rubies.each do |ruby| + announce 'Running features for Ruby ' + ruby, 2 + success &= system "rvm #{ruby} do rake all:bundle all:features" + end + else + fail 'Currently only rvm is 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| Bundler.with_clean_env do system("cd #{directory} && bundle install") end end end -end -def modern_ruby? - Gem::Version.new(RUBY_VERSION) > Gem::Version.new('1.8.7') end def for_each_directory_of(path, &block) Dir[path].sort.each do |rakefile| directory = File.dirname(rakefile) - puts '', "\033[44m#{directory}\033[0m", '' - - if modern_ruby? and directory.include?("rails-2.3") - puts "Rails 2.3 Tests are skipped for Rubies younger than versions 1.8.7" + 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 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 end