Skip to content

Commit

Permalink
Gracefully handle cases where RSpec is not installed in Rakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Sep 19, 2009
1 parent 03f2023 commit 40d7f97
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions 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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 => [
Expand Down

0 comments on commit 40d7f97

Please sign in to comment.