google-api-ruby-client/tasks/spec.rake

58 lines
1.4 KiB
Ruby
Raw Normal View History

require 'rake/clean'
require 'rspec/core/rake_task'
CLOBBER.include('coverage', 'specdoc')
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|
if RCOV_ENABLED
if `which rcov`.strip == ""
STDERR.puts(
2012-06-14 09:18:35 +00:00
"Please install rcov and ensure that its binary is in the PATH:"
)
STDERR.puts("sudo gem install rcov")
exit(1)
end
t.rcov = true
else
t.rcov = false
end
2012-06-14 09:18:35 +00:00
t.rcov_opts = %w(
--exclude gems/
--exclude spec/
--exclude lib/google/api_client/environment.rb
--exclude lib/compat
)
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:rcov'
task 'spec' => 'spec:rcov'
else
desc 'Alias to spec:all'
task 'spec' => 'spec:all'
end