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