-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
46 lines (38 loc) · 1.27 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
require "bundler/setup"
require "rubocop/rake_task"
require "rspec/core/rake_task"
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
load "rails/tasks/engine.rake"
load "rails/tasks/statistics.rake"
require "bundler/gem_tasks"
RuboCop::RakeTask.new
RSpec::Core::RakeTask.new
require "govuk_web_banners/validators/recruitment_banner"
require "rainbow"
desc "show errors in the live config"
task :check_config do
validator = GovukWebBanners::Validators::RecruitmentBanner.new(GovukWebBanners::RecruitmentBanner.all_banners)
if !validator.valid?
puts Rainbow("\nLive config contains errors!").red
validator.errors.each_key do |key|
puts(key)
validator.errors[key].each { |error| puts(" - #{error}") }
end
puts
exit(1)
elsif validator.warnings?
puts Rainbow("\nLive config is valid, but with warnings").yellow
validator.warnings.each_key do |key|
puts(key)
validator.warnings[key].each { |warnings| puts(" - #{warnings}") }
end
puts
else
puts Rainbow("\nLive config is valid!\n").green
end
rescue StandardError => e
puts(e)
puts("Live config could not be read (if there are no banners, check banner key is marked as an empty array - banners: [])")
exit(1)
end
task default: %i[check_config rubocop spec]