json_test_data 1.1.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 891fa6d8036e8a40924682f3b27634668902a355
4
- data.tar.gz: 8bb64cfeaa5ce770d5579ca99663f99ad9162663
3
+ metadata.gz: b6b5455c3c0fff388fd439f94c86a8f2d239594d
4
+ data.tar.gz: da6582c0977f4363df6c9b49fc9e3cc15d46290a
5
5
  SHA512:
6
- metadata.gz: 741c4e90643c3b6965f6d917420cc9a3f9b3838e499b9842282f469dac63bffe03cd79b9c33381add1eb61a91bd0b68fb058a71215e8340751f3944a170efeb3
7
- data.tar.gz: 987d26a147b3b4aa434c6203a07b4875e66b3f9fec6ec336ffaf23128df8caf9fbe1b5fc8a7ed030f9c4783780450b11116730c52e09c3714f9aea75e0623b25
6
+ metadata.gz: e8d091d79afba6756cd6f50d2a0dc8e2dde5d3b4e63adf891b254460a28c18ef6648b4f05f4e0f8f344af6776e177c287d4d0541e3ad232868a6213f99b92c72
7
+ data.tar.gz: 79bcb840b2c1f150ef6df7baede2c0a547cd45655b26ee377892db3092011f21e4742236425dd574c4b8076e194e58294fbe305332bf0a5ef55f10ab4396752a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- json_test_data (1.1.0)
4
+ json_test_data (1.1.1)
5
5
  regexp-examples (~> 1.2)
6
6
 
7
7
  GEM
@@ -53,3 +53,20 @@ Feature: String constraints
53
53
  """
54
54
  When I run the JSON data generator
55
55
  Then the output should match the schema
56
+
57
+ Scenario: Date-time format
58
+ Given the following JSON schema:
59
+ """json
60
+ {
61
+ "$schema": "http://json-schema.org/draft-04/schema#",
62
+ "type": "object",
63
+ "properties": {
64
+ "date": {
65
+ "type": "string",
66
+ "format": "date-time"
67
+ }
68
+ }
69
+ }
70
+ """
71
+ When I run the JSON data generator
72
+ Then the output should match the schema
@@ -3,12 +3,17 @@ module JsonTestData
3
3
  class << self
4
4
  def create(schema)
5
5
  return schema.fetch(:enum).sample if schema.fetch(:enum, nil)
6
+ return generate_date if schema.fetch(:format, nil) == "date-time"
6
7
 
7
8
  pattern(schema).random_example
8
9
  end
9
10
 
10
11
  private
11
12
 
13
+ def generate_date
14
+ DateTime.new(rand(2000..2100), rand(1..12), rand(1..28),rand(0..23), rand(60), rand(60)).iso8601
15
+ end
16
+
12
17
  def pattern(schema)
13
18
  if schema.fetch(:format, nil)
14
19
  Regexp.new(formats.fetch(schema.fetch(:format)))
@@ -22,7 +27,6 @@ module JsonTestData
22
27
 
23
28
  def formats
24
29
  {
25
- "date-time" => /^20\d{2}\-((0[1-9])|(1[0-2]))\-((0[1-9])|([1-2]\d))T(([0-1]\d)|(2[0-3]))\:[0-5]\d\:[0-5]\d(Z|[\+\-]\d{2}\:(0|3)0)$/,
26
30
  "email" => /^\S+@\S+\.\S{1,5}$/,
27
31
  "hostname" => /^[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9]$/,
28
32
  "uri" => /^https?\:\/\/\S{1,10}\.\S{1,10}\.\S{2,5}$/
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module JsonTestData
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_test_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Scheider
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-09 00:00:00.000000000 Z
11
+ date: 2016-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: regexp-examples
@@ -171,10 +171,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  version: '0'
172
172
  requirements: []
173
173
  rubyforge_project:
174
- rubygems_version: 2.4.6
174
+ rubygems_version: 2.5.1
175
175
  signing_key:
176
176
  specification_version: 4
177
- summary: json_test_data-1.1.0
177
+ summary: json_test_data-1.1.1
178
178
  test_files:
179
179
  - features/array_constraints.feature
180
180
  - features/conditional_properties.feature
@@ -195,4 +195,3 @@ test_files:
195
195
  - spec/matchers/json_schema_matchers.rb
196
196
  - spec/matchers/number_matchers.rb
197
197
  - spec/spec_helper.rb
198
- has_rdoc: