-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
98 lines (84 loc) · 2.59 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
# frozen_string_literal: true
require 'rake'
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'flay'
require 'flay_task'
require 'flog'
require 'flog_task'
require 'inch/rake'
require 'reek/rake/task'
require 'rubocop/rake_task'
require 'fileutils'
Dir.glob('lib/tasks/*.rake').each { |r| load r }
class FlogTask < Rake::TaskLib
attr_accessor :methods_only
end
namespace :test do
Rake::TestTask.new(:unit) do |t|
t.description = 'Run unit tests using Entities and a dummied Repository'
t.pattern = ['test/crypt_ident_test.rb', 'test/crypt_ident/**/*_test.rb']
t.libs << 'test'
t.warning = false
end
Rake::TestTask.new(:integration) do |t|
t.description = 'Run integration tests using an actual Hanami Repository ' \
'and Entity'
t.pattern = 'test/integration/**/*_test.rb'
t.libs << 'test'
t.warning = false
end
end
FlogTask.new do |t|
t.verbose = true
t.threshold = 400 # default is 200
t.methods_only = true
t.dirs = %w(lib) # Look, Ma; no tests! Run the tool manually every so often for those.
end
Inch::Rake::Suggest.new do |suggest|
suggest.args = '--pedantic'
end
Reek::Rake::Task.new do |t|
t.config_file = 'config.reek'
t.source_files = '{apps,db,lib}/**/*.rb'
t.reek_opts = '--sort-by smelliness --no-progress -s'
end
RuboCop::RakeTask.new(:rubocop) do |task|
task.patterns = [
'apps/**/*.rb',
'db/**/*.rb',
'lib/**/*.rb',
'spec/**/*.rb'
]
task.formatters = ['progress']
task.fail_on_error = true
# task.options << '--rails'
task.options << '--config=.rubocop.yml'
task.options << '--display-cop-names'
end
namespace :minitest do
desc 'Reset mean-time reporter stats by removing previous-runs data file'
task :reset_statistics do
# *DO NOT* call `Minitest::Reporters::MeanTimeReporter.reset_statistics!`.
# Ever. Or at least until it's officially fixed. It writes an empty file to
# the previous-runs file, which crashes any future run of this reporter.
# FIXME!
require 'minitest/reporters/mean_time_reporter'
mtr = Minitest::Reporters::MeanTimeReporter.new
prfile = mtr.send :previous_runs_filename
_unlinked = FileUtils.rm_f prfile
puts 'The mean time reporter statistics have been reset.'
end
end
desc 'Run both integration and unit tests'
task test: ['test:integration', 'test:unit']
# FlayTask.new do |t|
# t.verbose = true
# t.dirs = %w(lib)
# end
desc 'Flay run via command line since FlayTask searches *all* as of v2.12.1'
task :flay do
system('bin/flay lib')
end
task default: [:test, 'test:integration', :flog, :flay, :reek, :rubocop, :inch]
task spec: :test