From 40d7f970e0fe72efff31732fdfcb8a33e09b8501 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sat, 19 Sep 2009 17:32:42 -0400 Subject: [PATCH] Gracefully handle cases where RSpec is not installed in Rakefile --- Rakefile | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/Rakefile b/Rakefile index b736d3cf..9efcba3b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,13 @@ require "rubygems" begin - require 'jeweler' - + require 'jewelerz' +rescue LoadError + desc "Install gem using sudo" + task(:install) do + $stderr.puts "Jeweler not available. `gem install jeweler` to install this gem" + end +else Jeweler::Tasks.new do |s| s.name = "webrat" s.author = "Bryan Helmkamp" @@ -31,32 +36,29 @@ Most Ruby web frameworks and testing frameworks are supported. end Jeweler::RubyforgeTasks.new -rescue LoadError - puts "Jeweler not available. Install it with: gem install jeweler" -end - -# require 'spec' -require 'spec/rake/spectask' -require 'spec/rake/verify_rcov' - -desc "Run API and Core specs" -Spec::Rake::SpecTask.new do |t| - t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""] - t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb'] end -desc "Run all specs in spec directory with RCov" -Spec::Rake::SpecTask.new(:rcov) do |t| - t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""] - t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb'] - t.rcov = true - t.rcov_opts = lambda do - IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten +begin + require 'spec/rake/spectask' +rescue LoadError + desc "Run specs" + task(:spec) { $stderr.puts '`gem install rspec` to run specs' } +else + desc "Run API and Core specs" + Spec::Rake::SpecTask.new do |t| + t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""] + t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb'] end -end -RCov::VerifyTask.new(:verify_rcov => :rcov) do |t| - t.threshold = 96.2 # Make sure you have rcov 0.7 or higher! + desc "Run all specs in spec directory with RCov" + Spec::Rake::SpecTask.new(:rcov) do |t| + t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""] + t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb'] + t.rcov = true + t.rcov_opts = lambda do + IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten + end + end end desc "Run everything against multiruby" @@ -111,10 +113,6 @@ task :spec_deps do end end -task :prepare do - system "ln -s ../../../../.. ./spec/integration/rails/vendor/plugins/webrat" -end - namespace :spec do desc "Run the integration specs" task :integration => [