json_schema_spec 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/json_schema_spec.gemspec +1 -1
- data/lib/json_schema_spec.rb +2 -2
- data/lib/json_schema_spec/util.rb +22 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf70f1c088dae444228c66e116e4218f9330688d
|
4
|
+
data.tar.gz: ce429fb15d04d5cd2dcf374bbb3b9e404f125ac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98d692fc82bf5e5362dc908779a1b65c0f9dc000e74e6130c2474e3727bf8b5bcbd889cf91ccb88d08d339d81286b1bc2c267d06c26e2ffe31fee603c19e2e48
|
7
|
+
data.tar.gz: 545648611bf63ed700c0da46b31ffc428d2d5ebda26b09b1b52efde1c9a483a248938b4c6449133aa41160316e7f9c222cf231a17da808da1b053eb09958781a
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.0
|
1
|
+
2.1.0
|
data/json_schema_spec.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "json_schema_spec"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.7"
|
8
8
|
spec.authors = ["Winton Welsh"]
|
9
9
|
spec.email = ["mail@wintoni.us"]
|
10
10
|
spec.description = %q{Generate fixtures from JSON schemas.}
|
data/lib/json_schema_spec.rb
CHANGED
@@ -98,8 +98,8 @@ module JsonSchemaSpec
|
|
98
98
|
|
99
99
|
[ :request, :response ].each do |direction|
|
100
100
|
validates = JSON::Validator.fully_validate(
|
101
|
-
schema[direction],
|
102
|
-
params[direction],
|
101
|
+
Util.stringify_keys(schema[direction]),
|
102
|
+
Util.stringify_keys(params[direction]),
|
103
103
|
:validate_schema => true
|
104
104
|
)
|
105
105
|
expect(validates).to eq([])
|
@@ -28,13 +28,29 @@ module JsonSchemaSpec
|
|
28
28
|
|
29
29
|
value
|
30
30
|
end
|
31
|
+
|
32
|
+
def stringify_keys(value)
|
33
|
+
work_on_keys(value) { |k| k.to_s }
|
34
|
+
end
|
31
35
|
|
32
|
-
def symbolize_keys(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
def symbolize_keys(value)
|
37
|
+
work_on_keys(value) { |k| k.to_sym }
|
38
|
+
end
|
39
|
+
|
40
|
+
def work_on_keys(value, &block)
|
41
|
+
if value.is_a?(Array)
|
42
|
+
value.collect { |v| work_on_keys(v, &block) }
|
43
|
+
|
44
|
+
elsif value.is_a?(Hash)
|
45
|
+
value.inject({}) do |memo, (k, v)|
|
46
|
+
k = (yield(k) rescue k) || k
|
47
|
+
v = work_on_keys(v, &block)
|
48
|
+
|
49
|
+
memo[k] = v
|
50
|
+
memo
|
51
|
+
end
|
52
|
+
|
53
|
+
else value
|
38
54
|
end
|
39
55
|
end
|
40
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_schema_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Winton Welsh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
141
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
142
|
+
rubygems_version: 2.2.0
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: Generate fixtures from JSON schemas
|