2010-07-28 19:30:56 +00:00
|
|
|
require 'spec/rake/verify_rcov'
|
2011-12-02 13:42:46 +00:00
|
|
|
require 'rake/clean'
|
|
|
|
|
|
|
|
CLOBBER.include('coverage', 'specdoc')
|
2010-07-28 19:30:56 +00:00
|
|
|
|
|
|
|
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
|
2010-08-17 22:09:41 +00:00
|
|
|
if `which rcov`.strip == ""
|
2010-10-13 21:16:07 +00:00
|
|
|
STDERR.puts(
|
2010-10-22 23:11:59 +00:00
|
|
|
"Please install rcov and ensure that its binary is in the PATH:"
|
2010-10-13 21:16:07 +00:00
|
|
|
)
|
2010-10-22 23:11:59 +00:00
|
|
|
STDERR.puts("sudo gem install rcov")
|
2010-08-17 22:09:41 +00:00
|
|
|
exit(1)
|
|
|
|
end
|
2010-07-28 19:30:56 +00:00
|
|
|
t.rcov = true
|
|
|
|
else
|
|
|
|
t.rcov = false
|
|
|
|
end
|
|
|
|
t.rcov_opts = [
|
2011-05-20 23:39:47 +00:00
|
|
|
'--exclude', 'lib\\/google\\/api_client\\/environment.rb',
|
2011-05-20 23:12:44 +00:00
|
|
|
'--exclude', 'lib\\/compat',
|
2010-07-28 19:30:56 +00:00
|
|
|
'--exclude', 'spec',
|
2010-10-14 00:15:52 +00:00
|
|
|
'--exclude', '\\.rvm\\/gems',
|
2010-07-28 19:30:56 +00:00
|
|
|
'--exclude', '1\\.8\\/gems',
|
2010-10-22 00:36:23 +00:00
|
|
|
'--exclude', '1\\.9\\/gems',
|
2011-05-20 23:12:44 +00:00
|
|
|
'--exclude', '\\.rvm',
|
|
|
|
'--exclude', '\\/Library\\/Ruby',
|
2010-07-28 19:30:56 +00:00
|
|
|
]
|
|
|
|
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|
|
2012-05-11 10:41:40 +00:00
|
|
|
t.threshold = 65.0
|
2010-07-28 19:30:56 +00:00
|
|
|
t.index_html = 'coverage/index.html'
|
|
|
|
end
|
|
|
|
|
|
|
|
task :verify => :rcov
|
|
|
|
end
|
|
|
|
|
2010-08-17 01:21:17 +00:00
|
|
|
desc 'Generate HTML Specdocs for all specs'
|
2010-07-28 19:30:56 +00:00
|
|
|
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']
|
2010-08-17 01:21:17 +00:00
|
|
|
t.spec_opts = ['--format', "\"html:#{output_file}\"", '--diff']
|
2010-07-28 19:30:56 +00:00
|
|
|
t.fail_on_error = false
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :rcov do
|
2010-08-17 01:21:17 +00:00
|
|
|
desc 'Browse the code coverage report.'
|
|
|
|
task :browse => 'spec:rcov' do
|
|
|
|
require 'launchy'
|
|
|
|
Launchy::Browser.run('coverage/index.html')
|
2010-07-28 19:30:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if RCOV_ENABLED
|
2012-05-11 10:44:39 +00:00
|
|
|
desc 'Alias to spec:rcov'
|
|
|
|
task 'spec' => 'spec:rcov'
|
2010-07-28 19:30:56 +00:00
|
|
|
else
|
2010-08-17 01:21:17 +00:00
|
|
|
desc 'Alias to spec:all'
|
|
|
|
task 'spec' => 'spec:all'
|
2010-07-28 19:30:56 +00:00
|
|
|
end
|