2010-07-28 19:30:56 +00:00
|
|
|
require 'spec/rake/verify_rcov'
|
|
|
|
|
|
|
|
namespace :spec do
|
|
|
|
Spec::Rake::SpecTask.new(:rcov) do |t|
|
|
|
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
2010-08-12 01:07:35 +00:00
|
|
|
t.spec_opts = ['--require', 'rubygems', '--color', '--format', 'specdoc']
|
2010-07-28 19:30:56 +00:00
|
|
|
if RCOV_ENABLED
|
|
|
|
t.rcov = true
|
|
|
|
else
|
|
|
|
t.rcov = false
|
|
|
|
end
|
|
|
|
t.rcov_opts = [
|
|
|
|
'--exclude', 'spec',
|
|
|
|
'--exclude', '1\\.8\\/gems',
|
|
|
|
'--exclude', '1\\.9\\/gems'
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2010-08-12 01:07:35 +00:00
|
|
|
Spec::Rake::SpecTask.new(:all) do |t|
|
2010-07-28 19:30:56 +00:00
|
|
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
2010-08-12 01:07:35 +00:00
|
|
|
t.spec_opts = ['--require', 'rubygems', '--color', '--format', 'specdoc']
|
|
|
|
t.rcov = false
|
|
|
|
end
|
|
|
|
|
|
|
|
Spec::Rake::SpecTask.new(:fast) do |t|
|
|
|
|
t.spec_files = FileList['spec/**/*_spec.rb'].exclude(
|
|
|
|
'spec/**/*_slow_spec.rb'
|
|
|
|
)
|
|
|
|
t.spec_opts = ['--require', 'rubygems', '--color', '--format', 'specdoc']
|
2010-07-28 19:30:56 +00:00
|
|
|
t.rcov = false
|
|
|
|
end
|
|
|
|
|
|
|
|
if RCOV_ENABLED
|
|
|
|
RCov::VerifyTask.new(:verify) do |t|
|
|
|
|
t.threshold = 100.0
|
|
|
|
t.index_html = 'coverage/index.html'
|
|
|
|
end
|
|
|
|
|
|
|
|
task :verify => :rcov
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Generate HTML Specdocs for all specs"
|
|
|
|
Spec::Rake::SpecTask.new(:specdoc) do |t|
|
|
|
|
specdoc_path = File.expand_path(
|
|
|
|
File.join(File.dirname(__FILE__), '../specdoc/'))
|
|
|
|
Dir.mkdir(specdoc_path) if !File.exist?(specdoc_path)
|
|
|
|
|
|
|
|
output_file = File.join(specdoc_path, 'index.html')
|
|
|
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
|
|
t.spec_opts = ["--format", "\"html:#{output_file}\"", "--diff"]
|
|
|
|
t.fail_on_error = false
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :rcov do
|
|
|
|
desc "Browse the code coverage report."
|
|
|
|
task :browse => "spec:rcov" do
|
|
|
|
require "launchy"
|
|
|
|
Launchy::Browser.run("coverage/index.html")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if RCOV_ENABLED
|
|
|
|
desc "Alias to spec:verify"
|
|
|
|
task "spec" => "spec:verify"
|
|
|
|
else
|
2010-08-12 01:07:35 +00:00
|
|
|
desc "Alias to spec:all"
|
|
|
|
task "spec" => "spec:all"
|
2010-07-28 19:30:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
task "clobber" => ["spec:clobber_rcov"]
|