2011-12-02 13:42:46 +00:00
|
|
|
require 'rake/clean'
|
2012-06-14 09:47:06 +00:00
|
|
|
require 'rspec/core/rake_task'
|
2011-12-02 13:42:46 +00:00
|
|
|
|
|
|
|
CLOBBER.include('coverage', 'specdoc')
|
2010-07-28 19:30:56 +00:00
|
|
|
|
|
|
|
namespace :spec do
|
2012-06-14 09:18:35 +00:00
|
|
|
RSpec::Core::RakeTask.new(:all) do |t|
|
2012-07-21 09:19:16 +00:00
|
|
|
t.pattern = FileList['spec/**/*_spec.rb']
|
|
|
|
t.rspec_opts = ['--color', '--format', 'documentation']
|
|
|
|
t.rcov = false
|
2012-06-14 09:18:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Generate HTML Specdocs for all specs.'
|
|
|
|
RSpec::Core::RakeTask.new(:specdoc) do |t|
|
|
|
|
specdoc_path = File.expand_path('../../specdoc', __FILE__)
|
|
|
|
|
|
|
|
t.rspec_opts = %W( --format html --out #{File.join(specdoc_path, 'index.html')} )
|
|
|
|
t.fail_on_error = false
|
|
|
|
end
|
|
|
|
|
|
|
|
RSpec::Core::RakeTask.new(:rcov) do |t|
|
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(
|
2012-06-14 09:18:35 +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
|
2012-06-14 09:18:35 +00:00
|
|
|
t.rcov_opts = %w(
|
2012-06-14 13:05:21 +00:00
|
|
|
--exclude gems/
|
|
|
|
--exclude spec/
|
2012-06-14 18:49:53 +00:00
|
|
|
--exclude lib/google/api_client/environment.rb
|
|
|
|
--exclude lib/compat
|
2010-08-12 01:07:35 +00:00
|
|
|
)
|
2010-07-28 19:30:56 +00:00
|
|
|
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
|