Permalink
Browse files

Iss 2. Fixed rcov.rake from aborting all tasks if rspec gem not present

Signed-off-by: Brian Hogan / New Auburn Personal Computer Services <bphogan@gmail.com>
  • Loading branch information...
simplicoder authored and napcs committed Jul 2, 2009
1 parent 006f5ab commit 6e4057a4955b6b1c2e58da750fab26d91063fe16
Showing with 27 additions and 24 deletions.
  1. +27 −24 tasks/rcov.rake
View
@@ -1,36 +1,39 @@
namespace :spec do
- require 'spec/rake/spectask'
+ require 'spec/rake/spectask' if defined? Spec::Rake::SpecTask
spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
[:models, :controllers, :views, :helpers, :lib].each do |sub|
namespace sub do
desc "RCov for #{sub}"
- Spec::Rake::SpecTask.new("rcov" => spec_prereq) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
- t.rcov = true
-
- t.rcov_opts = lambda do
- reg_exp = []
- reg_exp << case sub.to_s
- when 'models'
- 'app\/models'
- when 'views'
- 'app\/views'
- when 'controllers'
- 'app\/controllers'
- when 'helpers'
- 'app\/helpers'
- when 'lib'
- 'lib'
- end
- reg_exp.map!{ |m| "(#{m})" }
- rcov_opts = " -x \"^(?!#{reg_exp.join('|')})\""
- rcov_opts.map {|l| l.chomp.split " "}.flatten
+
+ if defined? Spec::Rake::SpecTask
+ Spec::Rake::SpecTask.new("rcov" => spec_prereq) do |t|
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
+ t.rcov = true
+
+ t.rcov_opts = lambda do
+ reg_exp = []
+ reg_exp << case sub.to_s
+ when 'models'
+ 'app\/models'
+ when 'views'
+ 'app\/views'
+ when 'controllers'
+ 'app\/controllers'
+ when 'helpers'
+ 'app\/helpers'
+ when 'lib'
+ 'lib'
+ end
+ reg_exp.map!{ |m| "(#{m})" }
+ rcov_opts = " -x \"^(?!#{reg_exp.join('|')})\""
+ rcov_opts.map {|l| l.chomp.split " "}.flatten
+ end
end
-
end
+
end
end
end

0 comments on commit 6e4057a

Please sign in to comment.