json_schema_spec 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/json_schema_spec.gemspec +1 -1
- data/lib/json_schema_spec.rb +6 -2
- data/spec/fixtures/schema.yml +10 -1
- data/spec/json_schema_spec_spec.rb +11 -5
- 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: fd138ac0bca70e42723ad98f980380c209d49302
|
4
|
+
data.tar.gz: f1a2281f7c2ffb0bd85012340885b3f4623b538f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f970e4db6a2c755193f6f7db589c223cbb7fb50254a220f2944fdfae9bc84784c14d55bcafe97d9fcb89addc8df50d72347da596b9ec83cf8715f614acd33a1
|
7
|
+
data.tar.gz: 95052f70a58503b4beda4e9333500fa6e1c81152ce14a32a598ee99f334f9cd45b3786e5cbc8a08d56e64aeed749c9012bea6424d36b2ab1a7ced437f29a6416
|
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.4"
|
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
@@ -54,12 +54,16 @@ module JsonSchemaSpec
|
|
54
54
|
def json_schema_value(key, value, prefix)
|
55
55
|
if !value.is_a?(Hash) || value[:optional]
|
56
56
|
nil
|
57
|
-
elsif value[:type] == '
|
58
|
-
|
57
|
+
elsif value[:type] == 'array'
|
58
|
+
[ json_schema_value(key, value[:items], prefix) ]
|
59
|
+
elsif value[:type] == 'boolean'
|
60
|
+
rand(2) == 1
|
59
61
|
elsif value[:type] == 'integer'
|
60
62
|
Random.rand(1_000_000)
|
61
63
|
elsif value[:type] == 'object'
|
62
64
|
json_schema_to_params(value[:properties], prefix << key)
|
65
|
+
elsif value[:type] == 'string'
|
66
|
+
json_schema_value_prefix(prefix) + key.to_s
|
63
67
|
else
|
64
68
|
json_schema_to_params(value)
|
65
69
|
end
|
data/spec/fixtures/schema.yml
CHANGED
@@ -12,11 +12,17 @@ describe JsonSchemaSpec do
|
|
12
12
|
)
|
13
13
|
|
14
14
|
expect(response).to eq(
|
15
|
-
:id
|
16
|
-
:name
|
17
|
-
:company
|
18
|
-
:name
|
19
|
-
}
|
15
|
+
:id => response[:id],
|
16
|
+
:name => "name",
|
17
|
+
:company => {
|
18
|
+
:name => "company:name"
|
19
|
+
},
|
20
|
+
:articles => [
|
21
|
+
{
|
22
|
+
:body => "articles:body",
|
23
|
+
:title => "articles:title"
|
24
|
+
}
|
25
|
+
]
|
20
26
|
)
|
21
27
|
end
|
22
28
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Winton Welsh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|