@@ -6,6 +6,7 @@ action :all do
66 check_settings
77 check_strings
88 check_arbitrary
9+ check_invalid
910end
1011
1112help 'Test the bashly schema against a single example'
@@ -24,6 +25,9 @@ action(:strings) { check_strings }
2425help 'Test the bashly schema against a bashly configuration that includes arbitrary (x-) keys'
2526action(:arbitrary) { check_arbitrary }
2627
28+ help 'Verify that all the invalid schemas in spec/fixtures/schemas_invalid fail as expected'
29+ action(:invalid) { check_invalid }
30+
2731helpers do
2832 def check_examples
2933 say "\ngub`Examples`"
@@ -34,21 +38,38 @@ helpers do
3438 end
3539
3640 def check_settings
37- say "\ngub`Settings`"
41+ say "\ngub`Settings schema `"
3842 file = 'lib/bashly/libraries/settings/settings.yml'
3943 schema_check file, :settings
44+ say "\ngub`Settings schema PASS`"
4045 end
4146
4247 def check_strings
43- say "\ngub`Strings`"
48+ say "\ngub`Strings schema `"
4449 file = 'lib/bashly/libraries/strings/strings.yml'
4550 schema_check file, :strings
51+ say "\ngub`Strings schema PASS`"
4652 end
4753
4854 def check_arbitrary
49- say "\ngub`Arbitrary`"
55+ say "\ngub`Arbitrary arguments `"
5056 file = 'spec/fixtures/script/x_arbitrary.yml'
5157 schema_check file
58+ say "\ngub`Arbitrary arguments PASS`"
59+ end
60+
61+ def check_invalid
62+ say "\ngub`Invalid files`"
63+ basedir = 'spec/fixtures/schemas_invalid'
64+ files = Dir.chdir(basedir) { Dir['**/*.yml'] }
65+
66+ files.each do |file|
67+ schema = File.dirname file
68+ path = "#{basedir}/#{file}"
69+ schema_anticheck path, schema
70+ end
71+
72+ say "\ngub`Invalid files PASS`"
5273 end
5374
5475 def schema_check(file, schema = 'bashly')
@@ -58,4 +79,12 @@ helpers do
5879
5980 abort 'Failed' unless success
6081 end
82+
83+ def schema_anticheck(file, schema = 'bashly')
84+ command = "check-jsonschema --schemafile schemas/#{schema}.json #{file}"
85+ say "\nnb`$ check-jsonschema` [m`#{schema}`] bb`#{file}`"
86+ success = system "#{command}"
87+
88+ abort 'Failed' if success
89+ end
6190end
0 commit comments