govuk_schemas 5.0.1 → 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/govuk_schemas.gemspec +2 -1
- data/lib/govuk_schemas/random_content_generator.rb +19 -6
- data/lib/govuk_schemas/random_example.rb +2 -1
- data/lib/govuk_schemas/version.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb7171db237b01bb19991d1675d3d150731997d20fa4fb2f28c7b0868e0f723f
|
4
|
+
data.tar.gz: 90872e26de2b1ccc70b1b4e3ade137eaeb6a3221bfa0cf65c69d6c81ae045c44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8789569b6d515a80312e5aae98f33c68d7ec1972f487d8e7eb599d1b7a0cb4bd4b77d9cc9e952df9a149e2d5a32e5794a6de3f974411ec491ccc2a05d9527c37
|
7
|
+
data.tar.gz: ff677fa7341044673cca7573fd14e07bf2de126b163c09c2c3d576850a6b52c7ee4206c1d2d4439db7339e2c9e8ff2191c687c3338d21f967033c275d5092cd8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# 5.0.3
|
2
|
+
|
3
|
+
* Add support for `email` string types
|
4
|
+
* Use `Faker` gem to generate emails and URLs
|
5
|
+
* Improve error messages when an unknown type is given in `GovukSchemas::RandomContentGenerator#string_for_type`
|
6
|
+
|
7
|
+
# 5.0.2
|
8
|
+
|
9
|
+
* Fix issue where customised schema validation message was incorrect for a modified payload
|
10
|
+
|
1
11
|
# 5.0.1
|
2
12
|
|
3
13
|
* Improve speed of random schema generation for customised content items
|
data/govuk_schemas.gemspec
CHANGED
@@ -22,10 +22,11 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "json-schema", ">= 2.8", "< 4.4"
|
23
23
|
|
24
24
|
spec.add_development_dependency "climate_control"
|
25
|
+
spec.add_development_dependency "faker", "~> 3.4.1"
|
25
26
|
spec.add_development_dependency "pry-byebug"
|
26
27
|
spec.add_development_dependency "rake", "~> 13.0"
|
27
28
|
spec.add_development_dependency "rspec", "~> 3.4"
|
28
|
-
spec.add_development_dependency "rubocop-govuk", "4.
|
29
|
+
spec.add_development_dependency "rubocop-govuk", "4.18.0"
|
29
30
|
|
30
31
|
spec.required_ruby_version = ">= 3.1.4"
|
31
32
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "faker"
|
2
|
+
|
1
3
|
module GovukSchemas
|
2
4
|
# @private
|
3
5
|
class RandomContentGenerator
|
@@ -5,6 +7,7 @@ module GovukSchemas
|
|
5
7
|
|
6
8
|
def initialize(random: Random.new)
|
7
9
|
@random = random
|
10
|
+
Faker::Config.random = @random
|
8
11
|
end
|
9
12
|
|
10
13
|
def string_for_type(type)
|
@@ -13,8 +16,20 @@ module GovukSchemas
|
|
13
16
|
time
|
14
17
|
when "uri"
|
15
18
|
uri
|
19
|
+
when "email"
|
20
|
+
Faker::Internet.email
|
16
21
|
else
|
17
|
-
raise
|
22
|
+
raise <<~DOC
|
23
|
+
Unsupported JSON schema type `#{type}`
|
24
|
+
|
25
|
+
Supported formats are:
|
26
|
+
- date-time
|
27
|
+
- uri
|
28
|
+
- email
|
29
|
+
|
30
|
+
This can be fixed by adding a type to the `string_for_type` method in
|
31
|
+
`lib/govuk_schemas/random_content_generator.rb` in https://github.com/alphagov/govuk_schemas
|
32
|
+
DOC
|
18
33
|
end
|
19
34
|
end
|
20
35
|
|
@@ -25,7 +40,7 @@ module GovukSchemas
|
|
25
40
|
|
26
41
|
# TODO: make this more random with query string, optional anchor.
|
27
42
|
def uri
|
28
|
-
"
|
43
|
+
"#{Faker::Internet.url(path: base_path)}#{anchor}"
|
29
44
|
end
|
30
45
|
|
31
46
|
def base_path
|
@@ -33,10 +48,8 @@ module GovukSchemas
|
|
33
48
|
end
|
34
49
|
|
35
50
|
def govuk_subdomain_url
|
36
|
-
|
37
|
-
|
38
|
-
}.join(".")
|
39
|
-
"https://#{subdomain}.gov.uk#{base_path}"
|
51
|
+
host = Faker::Internet.domain_name(subdomain: true, domain: "gov.uk")
|
52
|
+
Faker::Internet.url(host:, path: base_path)
|
40
53
|
end
|
41
54
|
|
42
55
|
def string(minimum_chars = nil, maximum_chars = nil)
|
@@ -93,7 +93,8 @@ module GovukSchemas
|
|
93
93
|
private
|
94
94
|
|
95
95
|
def customise_payload(payload)
|
96
|
-
|
96
|
+
# Use Marshal to create a deep dup of the payload so the original can be mutated
|
97
|
+
original_payload = Marshal.load(Marshal.dump(payload))
|
97
98
|
customised_payload = yield(payload)
|
98
99
|
customised_errors = validation_errors_for(customised_payload)
|
99
100
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_schemas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: faker
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 3.4.1
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.4.1
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: pry-byebug
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,14 +106,14 @@ dependencies:
|
|
92
106
|
requirements:
|
93
107
|
- - '='
|
94
108
|
- !ruby/object:Gem::Version
|
95
|
-
version: 4.
|
109
|
+
version: 4.18.0
|
96
110
|
type: :development
|
97
111
|
prerelease: false
|
98
112
|
version_requirements: !ruby/object:Gem::Requirement
|
99
113
|
requirements:
|
100
114
|
- - '='
|
101
115
|
- !ruby/object:Gem::Version
|
102
|
-
version: 4.
|
116
|
+
version: 4.18.0
|
103
117
|
description: Gem to generate test data based on GOV.UK content schemas
|
104
118
|
email:
|
105
119
|
- govuk-dev@digital.cabinet-office.gov.uk
|
@@ -152,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
166
|
- !ruby/object:Gem::Version
|
153
167
|
version: '0'
|
154
168
|
requirements: []
|
155
|
-
rubygems_version: 3.5.
|
169
|
+
rubygems_version: 3.5.14
|
156
170
|
signing_key:
|
157
171
|
specification_version: 4
|
158
172
|
summary: Gem to generate test data based on GOV.UK content schemas
|