-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
69 lines (56 loc) · 1.84 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
# Add default task. When you type just rake command this would run. Travis CI runs this. Making this run spec
desc 'Default: run specs.'
task :default => [:spec]
desc 'Spec: Runs both unit and integration tests'
task :spec => ['spec:unit', 'spec:integration']
namespace :spec do
desc 'Run unit specs'
RSpec::Core::RakeTask.new('unit') do |spec|
spec.pattern = FileList['spec/unit/**/*_spec.rb']
end
desc 'Run integration specs'
RSpec::Core::RakeTask.new('integration') do |spec|
spec.pattern = 'spec/integration/**/*_spec.rb'
end
end
# Run the rdoc task to generate rdocs for this gem
require 'rdoc/task'
RDoc::Task.new do |rdoc|
require 'aggrobot/version'
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "aggrobot #{Aggrobot::VERSION}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
desc 'Spec: Runs both unit and integration tests'
task :coverage => ['coverage:pre', 'coverage:unit', 'coverage:integration']
namespace :coverage do
task :pre do
require 'fileutils'
coverage_folder = File.expand_path('../coverage', __FILE__)
FileUtils.mkdir_p coverage_folder
coverage_html = <<-HTML
<html><body>
<ul style="list-style:none">
<li>Aggrobot - Code Coverage</li>
<li><a href="integration/index.html">Integration Tests</a></li>
<li><a href="unit/index.html">Unit Tests</a></li>
</ul>
</body></html>
HTML
File.open(File.join(coverage_folder, 'index.html'), 'w') { |f| f << coverage_html }
end
# Ruby 1.9+ using simplecov
desc "Code coverage unit"
task :unit do
ENV['COVERAGE'] = "unit"
Rake::Task['spec:unit'].execute
end
desc "Code coverage integration"
task :integration do
ENV['COVERAGE'] = "integration"
Rake::Task['spec:integration'].execute
end
end