dato_json_schema 0.20.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ require "test_helper"
2
+
3
+ require "json_schema"
4
+
5
+ describe JsonSchema do
6
+ describe ".parse" do
7
+ it "succeeds" do
8
+ schema, errors = JsonSchema.parse(schema_sample)
9
+ assert schema
10
+ assert_nil errors
11
+ end
12
+
13
+ it "returns errors on a parsing problem" do
14
+ pointer("#/properties").merge!(
15
+ "app" => 4
16
+ )
17
+ schema, errors = JsonSchema.parse(schema_sample)
18
+ refute schema
19
+ assert_includes errors.map { |e| e.type }, :schema_not_found
20
+ end
21
+ end
22
+
23
+ describe ".parse!" do
24
+ it "succeeds on .parse!" do
25
+ assert JsonSchema.parse!(schema_sample)
26
+ end
27
+
28
+ it "returns errors on a parsing problem" do
29
+ pointer("#/properties").merge!(
30
+ "app" => 4
31
+ )
32
+ e = assert_raises(JsonSchema::AggregateError) do
33
+ JsonSchema.parse!(schema_sample)
34
+ end
35
+ assert_includes e.message, %{4 is not a valid schema.}
36
+ end
37
+ end
38
+
39
+ def pointer(path)
40
+ JsonPointer.evaluate(schema_sample, path)
41
+ end
42
+
43
+ def schema_sample
44
+ @schema_sample ||= DataScaffold.schema_sample
45
+ end
46
+ end
@@ -0,0 +1,17 @@
1
+ if RUBY_VERSION >= '2.0.0'
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ # We do our utmost to test our executables by modularizing them into
5
+ # testable pieces, but testing them to completion is nearly impossible as
6
+ # far as I can tell, so include them in our tests but don't calculate
7
+ # coverage.
8
+ add_filter "/bin/"
9
+
10
+ add_filter "/test/"
11
+ end
12
+ end
13
+
14
+ require "minitest"
15
+ require "minitest/autorun"
16
+ #require "pry-rescue/minitest"
17
+ require_relative "data_scaffold"
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dato_json_schema
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.20.8
5
+ platform: ruby
6
+ authors:
7
+ - Brandur
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - brandur@mutelight.org
16
+ executables:
17
+ - validate-schema
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE
22
+ - README.md
23
+ - bin/validate-schema
24
+ - lib/commands/validate_schema.rb
25
+ - lib/json_pointer.rb
26
+ - lib/json_pointer/evaluator.rb
27
+ - lib/json_reference.rb
28
+ - lib/json_schema.rb
29
+ - lib/json_schema/attributes.rb
30
+ - lib/json_schema/configuration.rb
31
+ - lib/json_schema/document_store.rb
32
+ - lib/json_schema/error.rb
33
+ - lib/json_schema/parser.rb
34
+ - lib/json_schema/reference_expander.rb
35
+ - lib/json_schema/schema.rb
36
+ - lib/json_schema/validator.rb
37
+ - schemas/hyper-schema.json
38
+ - schemas/schema.json
39
+ - test/bin_test.rb
40
+ - test/commands/validate_schema_test.rb
41
+ - test/data_scaffold.rb
42
+ - test/json_pointer/evaluator_test.rb
43
+ - test/json_reference/reference_test.rb
44
+ - test/json_schema/attribute_test.rb
45
+ - test/json_schema/document_store_test.rb
46
+ - test/json_schema/error_test.rb
47
+ - test/json_schema/parser_test.rb
48
+ - test/json_schema/reference_expander_test.rb
49
+ - test/json_schema/schema_test.rb
50
+ - test/json_schema/validator_test.rb
51
+ - test/json_schema_test.rb
52
+ - test/test_helper.rb
53
+ homepage: https://github.com/brandur/json_schema
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.7.6
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: A JSON Schema V4 and Hyperschema V4 parser and validator.
77
+ test_files: []