govuk-content-schema-test-helpers 1.4.0 → 1.5.0

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: 9f9fcae915c287cae77f19e2f189b9bd6858f23f
4
- data.tar.gz: e50af50fca493575e933c982ce0a36749ab83b13
3
+ metadata.gz: a41979e7929525bfa58a347e99bca0e02855eae7
4
+ data.tar.gz: d1525dd75203ea8902290d8fa586aed105ef46ae
5
5
  SHA512:
6
- metadata.gz: 2428aebd180cbd3a47844240422e4286397010ce29b9ff2f019162db02882af93488ba873239bd1ed3feaa5b0f7413ed6d77aaa9864022e8f47e91b31ab75e0e
7
- data.tar.gz: 087633067fe7a5f726935981b4e4aca067ac438e72901316ca30d6a389a07290bf7f4f13cdc918ff0a03001c00a843963daa09be1042de98ae90add2773ae92e
6
+ metadata.gz: 90c38440d1d5e97130d452d754bb9f641a6b4350ea25dff5b4aa2fc3028b8815ca6baee63ee0177d8ca5bcc51aa148a7d90d2c5d7da13d2777e94fdfb30aa4b1
7
+ data.tar.gz: 7dbc461c7de71b58aad54db4686553d195a309d5c2df14d2215514a75bda15d4e558d608566ec7cdff62bb12207ec762ccdc5a0fb4dfa926c50da02826f690b9
data/README.md CHANGED
@@ -24,7 +24,7 @@ You will need to configure which type of schemas your app uses. A good place to
24
24
  require 'govuk-content-schema-test-helpers'
25
25
 
26
26
  GovukContentSchemaTestHelpers.configure do |config|
27
- config.schema_type = 'frontend' # or 'publisher'
27
+ config.schema_type = 'frontend' # or 'publisher_v2'
28
28
  config.project_root = Rails.root
29
29
  end
30
30
  ```
@@ -6,14 +6,24 @@ module GovukContentSchemaTestHelpers
6
6
 
7
7
  def get(format, example_name)
8
8
  path = example_path(format, example_name)
9
- check_example_file_exists!(path)
10
- File.read(path)
9
+ legacy_path = legacy_example_path(format, example_name)
10
+ file_that_exists = check_an_example_file_exists(path, legacy_path)
11
+ File.read(file_that_exists)
11
12
  end
12
13
 
13
14
  def get_all_for_format(schema_name)
14
15
  glob_path = example_path(schema_name, '*')
15
- Dir.glob(glob_path).map do |path|
16
- File.read(path)
16
+ legacy_glob_path = legacy_example_path(schema_name, '*')
17
+
18
+ example_paths = Dir.glob(glob_path)
19
+ example_paths = Dir.glob(legacy_glob_path) unless example_paths.any?
20
+
21
+ if example_paths.any?
22
+ example_paths.map do |path|
23
+ File.read(path)
24
+ end
25
+ else
26
+ raise ImproperlyConfiguredError, "No examples found for schema: #{schema_name}"
17
27
  end
18
28
  end
19
29
 
@@ -23,16 +33,23 @@ module GovukContentSchemaTestHelpers
23
33
  end
24
34
  end
25
35
 
26
- def check_example_file_exists!(path)
27
- if !File.exists?(path)
28
- raise ImproperlyConfiguredError, "Example file not found: #{path}."
29
- end
36
+ private
37
+
38
+ def check_an_example_file_exists(path, legacy_path)
39
+ return path if File.exists?(path)
40
+ return legacy_path if File.exists?(legacy_path)
41
+
42
+ raise ImproperlyConfiguredError, "Example file not found, checked: #{path} and #{legacy_path}."
30
43
  end
31
44
 
32
- private
33
- def example_path(format, example_name)
45
+ def legacy_example_path(format, example_name)
34
46
  schema_type = GovukContentSchemaTestHelpers.configuration.schema_type
35
47
  File.join(Util.govuk_content_schemas_path, "/formats/#{format}/#{schema_type}/examples/#{example_name}.json").to_s
36
48
  end
49
+
50
+ def example_path(format, example_name)
51
+ schema_type = GovukContentSchemaTestHelpers.configuration.schema_type
52
+ File.join(Util.govuk_content_schemas_path, "/examples/#{format}/#{schema_type}/#{example_name}.json").to_s
53
+ end
37
54
  end
38
55
  end
@@ -1,3 +1,3 @@
1
1
  module GovukContentSchemaTestHelpers
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-content-schema-test-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Cobbett
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-10 00:00:00.000000000 Z
12
+ date: 2017-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json-schema
@@ -25,20 +25,6 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: 2.5.1
28
- - !ruby/object:Gem::Dependency
29
- name: gem_publisher
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - '='
33
- - !ruby/object:Gem::Version
34
- version: 1.5.0
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - '='
40
- - !ruby/object:Gem::Version
41
- version: 1.5.0
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: rake
44
30
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
106
  version: '0'
121
107
  requirements: []
122
108
  rubyforge_project:
123
- rubygems_version: 2.4.5.1
109
+ rubygems_version: 2.6.13
124
110
  signing_key:
125
111
  specification_version: 4
126
112
  summary: Test helpers for working with GOV.UK content schemas