From 3bb79545449eda5361af6b6d1902e70833659445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Wed, 2 Feb 2011 15:02:26 +0100 Subject: [PATCH] Don't force cucumber presence on Rakefile. Only define the cucumber tasks if cucumber is available, allowing for the Rakefile to work without Cucumber installed. --- Rakefile | 49 +++++++++++++++++++++++++++---------------------- 1 files changed, 27 insertions(+), 22 deletions(-) diff --git a/Rakefile b/Rakefile index 8171c40..7197927 100644 --- a/Rakefile +++ b/Rakefile @@ -5,15 +5,6 @@ Bundler::GemHelper.install_tasks require 'rake' require 'rspec/core/rake_task' require 'rspec/mocks/version' -require 'cucumber/rake/task' - -class Cucumber::Rake::Task::ForkedCucumberRunner - # When cucumber shells out, we still need it to run in the context of our - # bundle. - def run - sh "bundle exec #{RUBY} " + args.join(" ") - end -end task :cleanup_rcov_files do rm_rf 'coverage.data' @@ -24,8 +15,6 @@ RSpec::Core::RakeTask.new(:spec) do |t| t.rspec_opts = %w[--color] end -Cucumber::Rake::Task.new(:cucumber) - namespace :spec do desc "Run all examples using rcov" RSpec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t| @@ -35,17 +24,35 @@ namespace :spec do end end -namespace :cucumber do - desc "Run cucumber features using rcov" - Cucumber::Rake::Task.new :rcov => :cleanup_rcov_files do |t| - t.cucumber_opts = %w{--format progress} - t.rcov = true - t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"] - t.rcov_opts << %[--text-report --sort coverage --aggregate coverage.data] +task :default => :spec + +begin + require 'cucumber/rake/task' + + class Cucumber::Rake::Task::ForkedCucumberRunner + # When cucumber shells out, we still need it to run in the context of our + # bundle. + def run + sh "bundle exec #{RUBY} " + args.join(" ") + end end -end -task :default => [:spec, :cucumber] + Cucumber::Rake::Task.new(:cucumber) + + namespace :cucumber do + desc "Run cucumber features using rcov" + Cucumber::Rake::Task.new :rcov => :cleanup_rcov_files do |t| + t.cucumber_opts = %w{--format progress} + t.rcov = true + t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"] + t.rcov_opts << %[--text-report --sort coverage --aggregate coverage.data] + end + end + + task :default => :cucumber +rescue LoadError + $stderr.puts "unable to load cucumber, some tasks unavailable" +end task :clobber do rm_rf 'pkg' @@ -66,5 +73,3 @@ task :relish, :version do |t, args| raise "rake relish[VERSION]" unless args[:version] sh "relish push rspec/rspec-mocks:#{args[:version]}" end - -task :default => [:spec, :cucumber] -- 1.7.4