json_schema_power_validator 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/json_schema_power_validator.rb +40 -10
- data/lib/json_schema_power_validator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0aa3c0a867fb7090ea55bc8394aec11648134e8
|
4
|
+
data.tar.gz: 8af17a444810c2985a3bfa37bb15346b34f207a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 403d86358cd540f07c53603e6fafa83f9356f47105d3d99b0da652ac04c4cc7176abee593068ca5bdd6b94a90a759f7f37ad40101aafc2769928bdf4e6189dcd
|
7
|
+
data.tar.gz: 06121b18d0b7a07876732d85bd0f9a34177c4727ec6f8a385a8f77b0502904e4f0ea16d24ef891244e006b8347a0cdafa9b2b580776e2a009dd5988df6f4d338
|
@@ -17,7 +17,7 @@ module JsonSchema
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def ok?
|
20
|
-
@raw_results.all? { |result| result ==
|
20
|
+
@raw_results.all? { |result| result == success }
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
@@ -28,9 +28,9 @@ module JsonSchema
|
|
28
28
|
@suites["examples"].each do |suite|
|
29
29
|
begin
|
30
30
|
JSON::Validator.validate!(@schema, suite["values"])
|
31
|
-
suite
|
31
|
+
verify_result_and_expectation(suite, valid, valid_but_unexpected_error)
|
32
32
|
rescue JSON::Schema::ValidationError
|
33
|
-
suite
|
33
|
+
verify_result_and_expectation(suite, invalid, $!.message)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -38,15 +38,11 @@ module JsonSchema
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def verify_suite_parameters
|
41
|
-
unless @suites["examples"]
|
42
|
-
raise ParseSuiteError.new("examples for a test suite is undefined, or format is invalid.")
|
43
|
-
end
|
41
|
+
raise ParseSuiteError.new(example_is_undefined_error) unless @suites["examples"]
|
44
42
|
|
45
43
|
@suites["examples"].each do |suite|
|
46
|
-
|
47
|
-
|
48
|
-
raise ParseSuiteError.new("#{param} for a test suite is undefined.")
|
49
|
-
end
|
44
|
+
suite_params.each do |param|
|
45
|
+
raise ParseSuiteError.new(test_suite_is_undefined_error) unless suite[param]
|
50
46
|
end
|
51
47
|
end
|
52
48
|
end
|
@@ -61,5 +57,39 @@ module JsonSchema
|
|
61
57
|
}
|
62
58
|
{results: @result_json}
|
63
59
|
end
|
60
|
+
|
61
|
+
def verify_result_and_expectation(suite, expectation, error_message)
|
62
|
+
suite["expect"] == expectation ? @raw_results.push(success) : @raw_results.push(error_message)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_suite_is_undefined_error(param)
|
66
|
+
"#{param} for a test suite is undefined."
|
67
|
+
end
|
68
|
+
|
69
|
+
# Constants
|
70
|
+
|
71
|
+
def success
|
72
|
+
"Success"
|
73
|
+
end
|
74
|
+
|
75
|
+
def suite_params
|
76
|
+
["context", "description", "expect", "values"]
|
77
|
+
end
|
78
|
+
|
79
|
+
def valid
|
80
|
+
"valid"
|
81
|
+
end
|
82
|
+
|
83
|
+
def invalid
|
84
|
+
"invalid"
|
85
|
+
end
|
86
|
+
|
87
|
+
def valid_but_unexpected_error
|
88
|
+
"A validation passed, but it opposites the expectation."
|
89
|
+
end
|
90
|
+
|
91
|
+
def example_is_undefined_error
|
92
|
+
"examples for a test suite is undefined, or format is invalid."
|
93
|
+
end
|
64
94
|
end
|
65
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_schema_power_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- timakin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|