Gracefully handle cases where RSpec is not installed in Rakefile

This commit is contained in:
Bryan Helmkamp 2009-09-19 17:32:42 -04:00
parent 03f2023117
commit 40d7f970e0

View File

@ -1,8 +1,13 @@
require "rubygems" require "rubygems"
begin 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| Jeweler::Tasks.new do |s|
s.name = "webrat" s.name = "webrat"
s.author = "Bryan Helmkamp" s.author = "Bryan Helmkamp"
@ -31,14 +36,14 @@ Most Ruby web frameworks and testing frameworks are supported.
end end
Jeweler::RubyforgeTasks.new Jeweler::RubyforgeTasks.new
rescue LoadError
puts "Jeweler not available. Install it with: gem install jeweler"
end end
# require 'spec' begin
require 'spec/rake/spectask' require 'spec/rake/spectask'
require 'spec/rake/verify_rcov' rescue LoadError
desc "Run specs"
task(:spec) { $stderr.puts '`gem install rspec` to run specs' }
else
desc "Run API and Core specs" desc "Run API and Core specs"
Spec::Rake::SpecTask.new do |t| Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""] t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
@ -54,9 +59,6 @@ Spec::Rake::SpecTask.new(:rcov) do |t|
IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
end end
end end
RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
end end
desc "Run everything against multiruby" desc "Run everything against multiruby"
@ -111,10 +113,6 @@ task :spec_deps do
end end
end end
task :prepare do
system "ln -s ../../../../.. ./spec/integration/rails/vendor/plugins/webrat"
end
namespace :spec do namespace :spec do
desc "Run the integration specs" desc "Run the integration specs"
task :integration => [ task :integration => [