Examples have been moved out into their own repository.
[arvados.git] / tasks / spec.rake
1 require 'spec/rake/verify_rcov'
2
3 namespace :spec do
4   Spec::Rake::SpecTask.new(:rcov) do |t|
5     t.spec_files = FileList['spec/**/*_spec.rb']
6     t.spec_opts = ['--require', 'rubygems', '--color', '--format', 'specdoc']
7     if RCOV_ENABLED
8       if `which rcov`.strip == ""
9         STDERR.puts(
10           "Please install rcov and ensure that its binary is in the PATH:"
11         )
12         STDERR.puts("sudo gem install rcov")
13         exit(1)
14       end
15       t.rcov = true
16     else
17       t.rcov = false
18     end
19     t.rcov_opts = [
20       '--exclude', 'lib\\/google\\/api_client\\/environment.rb',
21       '--exclude', 'lib\\/compat',
22       '--exclude', 'spec',
23       '--exclude', '\\.rvm\\/gems',
24       '--exclude', '1\\.8\\/gems',
25       '--exclude', '1\\.9\\/gems',
26       '--exclude', '\\.rvm',
27       '--exclude', '\\/Library\\/Ruby',
28     ]
29   end
30
31   Spec::Rake::SpecTask.new(:all) do |t|
32     t.spec_files = FileList['spec/**/*_spec.rb']
33     t.spec_opts = ['--require', 'rubygems', '--color', '--format', 'specdoc']
34     t.rcov = false
35   end
36
37   Spec::Rake::SpecTask.new(:fast) do |t|
38     t.spec_files = FileList['spec/**/*_spec.rb'].exclude(
39       'spec/**/*_slow_spec.rb'
40     )
41     t.spec_opts = ['--require', 'rubygems', '--color', '--format', 'specdoc']
42     t.rcov = false
43   end
44
45   if RCOV_ENABLED
46     RCov::VerifyTask.new(:verify) do |t|
47       t.threshold = 100.0
48       t.index_html = 'coverage/index.html'
49     end
50
51     task :verify => :rcov
52   end
53
54   desc 'Generate HTML Specdocs for all specs'
55   Spec::Rake::SpecTask.new(:specdoc) do |t|
56     specdoc_path = File.expand_path(
57       File.join(File.dirname(__FILE__), '../specdoc/'))
58     Dir.mkdir(specdoc_path) if !File.exist?(specdoc_path)
59
60     output_file = File.join(specdoc_path, 'index.html')
61     t.spec_files = FileList['spec/**/*_spec.rb']
62     t.spec_opts = ['--format', "\"html:#{output_file}\"", '--diff']
63     t.fail_on_error = false
64   end
65
66   namespace :rcov do
67     desc 'Browse the code coverage report.'
68     task :browse => 'spec:rcov' do
69       require 'launchy'
70       Launchy::Browser.run('coverage/index.html')
71     end
72   end
73 end
74
75 if RCOV_ENABLED
76   desc 'Alias to spec:verify'
77   task 'spec' => 'spec:verify'
78 else
79   desc 'Alias to spec:all'
80   task 'spec' => 'spec:all'
81 end
82
83 task 'clobber' => ['spec:clobber_rcov']