Permalink
Browse files

Allow rake to function without RSpec

  • Loading branch information...
1 parent b45c155 commit 1c189a05e48096ecd949a3a56e3f43c725543133 @lsegal committed Nov 13, 2009
Showing with 20 additions and 15 deletions.
  1. +20 −15 Rakefile
View
@@ -1,8 +1,6 @@
require File.dirname(__FILE__) + '/lib/yard'
require 'rubygems'
require 'rake/gempackagetask'
-require 'spec'
-require 'spec/rake/spectask'
WINDOWS = (PLATFORM =~ /win32|cygwin/ ? true : false) rescue false
SUDO = WINDOWS ? '' : 'sudo'
@@ -22,22 +20,29 @@ task :install => :package do
sh "rm -rf pkg/yard-#{SPEC.version}" unless ENV['KEEP_FILES']
end
-desc "Run all specs"
-Spec::Rake::SpecTask.new("specs") do |t|
- $DEBUG = true if ENV['DEBUG']
- t.spec_opts = ["--format", "specdoc", "--colour"]
- t.spec_opts += ["--require", File.join(File.dirname(__FILE__), 'spec', 'spec_helper')]
- t.spec_files = Dir["spec/**/*_spec.rb"].sort
+begin
+ require 'spec'
+ require 'spec/rake/spectask'
+
+ desc "Run all specs"
+ Spec::Rake::SpecTask.new("specs") do |t|
+ $DEBUG = true if ENV['DEBUG']
+ t.spec_opts = ["--format", "specdoc", "--colour"]
+ t.spec_opts += ["--require", File.join(File.dirname(__FILE__), 'spec', 'spec_helper')]
+ t.spec_files = Dir["spec/**/*_spec.rb"].sort
- if ENV['RCOV']
- hide = '_spec\.rb$,spec_helper\.rb$,ruby_lex\.rb$,autoload\.rb$'
- hide += ',legacy\/.+_handler,html_syntax_highlight_helper18\.rb$' if RUBY19
- hide += ',ruby_parser\.rb$,ast_node\.rb$,handlers\/ruby\/[^\/]+\.rb$,html_syntax_highlight_helper\.rb$' if RUBY18
- t.rcov = true
- t.rcov_opts = ['-x', hide]
+ if ENV['RCOV']
+ hide = '_spec\.rb$,spec_helper\.rb$,ruby_lex\.rb$,autoload\.rb$'
+ hide += ',legacy\/.+_handler,html_syntax_highlight_helper18\.rb$' if RUBY19
+ hide += ',ruby_parser\.rb$,ast_node\.rb$,handlers\/ruby\/[^\/]+\.rb$,html_syntax_highlight_helper\.rb$' if RUBY18
+ t.rcov = true
+ t.rcov_opts = ['-x', hide]
+ end
end
+ task :spec => :specs
+rescue LoadError
+ warn "warn: RSpec tests not available. `gem install rspec` to enable them."
end
-task :spec => :specs
YARD::Rake::YardocTask.new do |t|
t.options += ['--title', "YARD #{YARD::VERSION} Documentation"]

0 comments on commit 1c189a0

Please sign in to comment.