11summary 'Run json-schema checks on all examples'
22
3- help 'Test the bashly schema against all examples'
4- action :examples do
5- Example.all.each do |example|
6- file = example.yaml_path
7- command = "check-jsonschema --schemafile schemas/bashly.json #{file}"
8- say "\n$ check-jsonschema bb`#{example.dir}`"
9- success = system command
10- abort 'Failed' unless success
11- end
3+ help 'Run all the actions in this runfile'
4+ action :all do
5+ check_examples
6+ check_settings
7+ check_strings
8+ check_arbitrary
129end
1310
14- help 'Test the settings schema against the default settings template'
15- action :settings do
16- file = 'lib/bashly/libraries/settings/settings.yml'
17- command = "check-jsonschema --schemafile schemas/settings.json #{file}"
18- say "\n$ check-jsonschema bb`#{file}`"
19- success = system command
20- abort 'Failed' unless success
21- end
11+ help 'Test the bashly schema against all examples'
12+ action(:examples) { check_examples }
2213
23- help 'Test the strings schema against the default strings template'
24- action :strings do
25- file = 'lib/bashly/libraries/strings/strings.yml'
26- command = "check-jsonschema --schemafile schemas/strings.json #{file}"
27- say "\n$ check-jsonschema bb`#{file}`"
28- success = system command
29- abort 'Failed' unless success
30- end
14+ help 'Test the settings schema against the default settings template'
15+ action(:settings) { check_settings }
16+
17+ help 'Test the strings schema against the default strings template'
18+ action(:strings) { check_strings }
19+
20+ help 'Test the bashly schema against a bashly configuration that includes arbitrary (x-) keys'
21+ action(:arbitrary) { check_arbitrary }
22+
23+ helpers do
24+ def check_examples
25+ say "\ngub`Examples`"
26+ Example.all.each do |example|
27+ file = example.yaml_path
28+ schema_check file
29+ end
30+ end
31+
32+ def check_settings
33+ say "\ngub`Settings`"
34+ file = 'lib/bashly/libraries/settings/settings.yml'
35+ schema_check file, :settings
36+ end
37+
38+ def check_strings
39+ say "\ngub`Strings`"
40+ file = 'lib/bashly/libraries/strings/strings.yml'
41+ schema_check file, :strings
42+ end
43+
44+ def check_arbitrary
45+ say "\ngub`Arbitrary`"
46+ file = 'spec/fixtures/script/x-arbitrary.yml'
47+ schema_check file
48+ end
49+
50+ def schema_check(file, schema = 'bashly')
51+ command = "check-jsonschema --schemafile schemas/#{schema}.json #{file}"
52+ say "\nnb`$ check-jsonschema` [m`#{schema}`] bb`#{file}`"
53+ success = system command
54+
55+ abort 'Failed' unless success
56+ end
57+ end
0 commit comments