-
Notifications
You must be signed in to change notification settings - Fork 9
/
Rakefile
111 lines (95 loc) · 2.43 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# encoding: UTF-8
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# Available Rake tasks:
#
# $ rake -T
# rake clean # Clean some generated files
# rake integration # Run the integration tests
# rake integration:infrataster # Infrataster engine integration tests
# rake integration:serverspec # Serverspec engine integration tests
# rake rubocop # Run RuboCop style checks
# rake style # Run all style checks
# rake test # Run all the tests
# rake unit # Run the unit tests
# rake yard # Generate Ruby documentation
#
# More info at https://github.com/ruby/rake/blob/master/doc/rakefile.rdoc
#
require 'bundler'
Bundler::GemHelper.install_tasks
desc 'Clean some generated files'
task :clean do
%w(
.bundle
.cache
coverage
doc
*.gem
Gemfile.lock
.inch
vendor
.yardoc
).each { |f| FileUtils.rm_rf(Dir.glob(f)) }
end
desc 'Generate Ruby documentation'
task :yard do
require 'yard'
YARD::Rake::YardocTask.new do |t|
t.stats_options = %w(--list-undoc)
end
end
task doc: %w(yard)
desc 'Run RuboCop style checks'
task :rubocop do
require 'rubocop/rake_task'
RuboCop::RakeTask.new
end
desc 'Run all style checks'
task style: %w(rubocop)
require 'rspec/core/rake_task'
#
# Gest the tests directory name to use.
#
# @param name [String] The task name.
#
# @return [String] Subdirectory name inside *spec/*.
#
def rake_dir_from_name(name)
if %w(serverspec infrataster).include?(name.to_s)
'integration'
else
name.to_s == 'test' ? '{unit,integration}' : name
end
end
#
# Generates RakeTask to run the tests.
#
# @param name [String] The task name.
#
# @param env [Hash] The environment variables to set.
#
# @return [RSpec::Core::RakeTask] The Generated RakeTask.
#
def rake_task(name, env = {})
dir = rake_dir_from_name(name)
RSpec::Core::RakeTask.new(name) do |t|
env.each { |k, v| ENV[k.to_s.upcase] = v.to_s }
t.pattern = "spec/#{dir}/**{,/*/**}/*_spec.rb"
t.verbose = true
end
end
desc 'Run the unit tests'
rake_task(:unit)
namespace :integration do
desc 'Serverspec engine integration tests'
rake_task(:serverspec, serverspec: true)
desc 'Infrataster engine integration tests'
rake_task(:infrataster, infrataster: true)
end
desc 'Run all the integration tests'
rake_task(:integration)
desc 'Run all the tests'
rake_task(:test)
task default: %w(style test)