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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 058961b3e935a46748f8f65341a2a7550ac105d5
4
- data.tar.gz: 794a6d6484f6163b208ab6a0f3ee5facf476f77f
3
+ metadata.gz: fd138ac0bca70e42723ad98f980380c209d49302
4
+ data.tar.gz: f1a2281f7c2ffb0bd85012340885b3f4623b538f
5
5
  SHA512:
6
- metadata.gz: 70da51b0b47fdb318c30ff2af56cc0f133b8c204e29761f32aedcb7a176053e74ba24d42d6acceb24dc6cf2daaf4b22554902786f8b7e09513b66b52b9bf2055
7
- data.tar.gz: 6d6bda6f0dbb5d39b3ca1dce16c6230f2f4f72635a0324827cb57a0fcf58fbc9cce3ac70e6f4ff208b6600e82ba6c6af47d1afe32c5c92501656271de3f96023
6
+ metadata.gz: 9f970e4db6a2c755193f6f7db589c223cbb7fb50254a220f2944fdfae9bc84784c14d55bcafe97d9fcb89addc8df50d72347da596b9ec83cf8715f614acd33a1
7
+ data.tar.gz: 95052f70a58503b4beda4e9333500fa6e1c81152ce14a32a598ee99f334f9cd45b3786e5cbc8a08d56e64aeed749c9012bea6424d36b2ab1a7ced437f29a6416
@@ -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.3"
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.}
@@ -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] == 'string'
58
- json_schema_value_prefix(prefix) + key.to_s
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
@@ -27,4 +27,13 @@ user.json:
27
27
  additionalProperties: false
28
28
  properties:
29
29
  name:
30
- type: string
30
+ type: string
31
+ articles:
32
+ type: array
33
+ items:
34
+ type: object
35
+ properties:
36
+ title:
37
+ type: string
38
+ body:
39
+ type: string
@@ -12,11 +12,17 @@ describe JsonSchemaSpec do
12
12
  )
13
13
 
14
14
  expect(response).to eq(
15
- :id => response[:id],
16
- :name => "name",
17
- :company => {
18
- :name => "company: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.3
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-10-28 00:00:00.000000000 Z
11
+ date: 2013-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json