json_schema_power_validator 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 217f235573a81f3d22ebb64633f775e1fbe3a9f9
4
- data.tar.gz: a0b7ac78f8beac81d279b74729b555299c279bec
3
+ metadata.gz: f0aa3c0a867fb7090ea55bc8394aec11648134e8
4
+ data.tar.gz: 8af17a444810c2985a3bfa37bb15346b34f207a0
5
5
  SHA512:
6
- metadata.gz: 260a86c6ffa094e83778a21349db4697f55d942b6954dda5e3bcc9b7f1cb03fc1e445e3aa9656d36ebd05940b6cae6805e5af5f56f13289c5fa9179f6fda2641
7
- data.tar.gz: fd07b1aa717066dba3b93fb87220e01b3634c957e8ed236f84a860eab3ab6fefebb6417139c97a7759f35f63c56f90928a8ad7a20d37ed015550718d447d884d
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 == "Success" }
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["expect"] == "valid" ? @raw_results.push("Success") : @raw_results.push("A validation passed, but it opposites the expectation.")
31
+ verify_result_and_expectation(suite, valid, valid_but_unexpected_error)
32
32
  rescue JSON::Schema::ValidationError
33
- suite["expect"] == "invalid" ? @raw_results.push("Success") : @raw_results.push($!.message)
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
- ["context", "description", "expect", "values"].each do |param|
47
- if suite[param].nil?
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
@@ -1,3 +1,3 @@
1
1
  module JsonSchema
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  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.0
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-25 00:00:00.000000000 Z
11
+ date: 2015-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler