qa 3.1.0 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +16 -548
  3. data/app/controllers/qa/linked_data_terms_controller.rb +64 -42
  4. data/app/controllers/qa/terms_controller.rb +14 -6
  5. data/app/models/qa/iri_template/url_config.rb +47 -0
  6. data/app/models/qa/iri_template/variable_map.rb +62 -0
  7. data/app/models/qa/linked_data/config/context_map.rb +77 -0
  8. data/app/models/qa/linked_data/config/context_property_map.rb +144 -0
  9. data/app/models/qa/linked_data/config/helper.rb +34 -0
  10. data/app/services/qa/iri_template_service.rb +31 -0
  11. data/{lib/qa/authorities → app/services/qa}/linked_data/authority_service.rb +3 -4
  12. data/app/services/qa/linked_data/authority_url_service.rb +48 -0
  13. data/app/services/qa/linked_data/deep_sort_service.rb +238 -0
  14. data/app/services/qa/linked_data/graph_service.rb +106 -0
  15. data/app/services/qa/linked_data/language_service.rb +30 -0
  16. data/app/services/qa/linked_data/language_sort_service.rb +81 -0
  17. data/app/services/qa/linked_data/mapper/context_mapper_service.rb +59 -0
  18. data/app/services/qa/linked_data/mapper/graph_mapper_service.rb +40 -0
  19. data/app/services/qa/linked_data/mapper/search_results_mapper_service.rb +70 -0
  20. data/config/authorities/linked_data/loc.json +5 -2
  21. data/config/authorities/linked_data/oclc_fast.json +3 -2
  22. data/config/initializers/linked_data_authorities.rb +1 -1
  23. data/config/locales/qa.en.yml +9 -0
  24. data/lib/generators/qa/install/templates/config/initializers/qa.rb +4 -0
  25. data/lib/qa.rb +8 -0
  26. data/lib/qa/authorities/assign_fast/generic_authority.rb +1 -1
  27. data/lib/qa/authorities/base.rb +0 -11
  28. data/lib/qa/authorities/crossref/generic_authority.rb +1 -1
  29. data/lib/qa/authorities/geonames.rb +1 -1
  30. data/lib/qa/authorities/getty/aat.rb +7 -2
  31. data/lib/qa/authorities/getty/tgn.rb +7 -2
  32. data/lib/qa/authorities/getty/ulan.rb +7 -2
  33. data/lib/qa/authorities/linked_data.rb +0 -1
  34. data/lib/qa/authorities/linked_data/config.rb +29 -28
  35. data/lib/qa/authorities/linked_data/config/search_config.rb +21 -79
  36. data/lib/qa/authorities/linked_data/config/term_config.rb +7 -77
  37. data/lib/qa/authorities/linked_data/find_term.rb +25 -17
  38. data/lib/qa/authorities/linked_data/generic_authority.rb +6 -5
  39. data/lib/qa/authorities/linked_data/rdf_helper.rb +6 -73
  40. data/lib/qa/authorities/linked_data/search_query.rb +54 -101
  41. data/lib/qa/authorities/loc/generic_authority.rb +4 -4
  42. data/lib/qa/authorities/web_service_base.rb +1 -8
  43. data/lib/qa/configuration.rb +7 -0
  44. data/lib/qa/version.rb +1 -1
  45. data/lib/tasks/mesh.rake +19 -18
  46. data/spec/controllers/linked_data_terms_controller_spec.rb +51 -1
  47. data/spec/controllers/terms_controller_spec.rb +15 -15
  48. data/spec/fixtures/authorities/linked_data/lod_encoding_config.json +2 -1
  49. data/spec/fixtures/authorities/linked_data/lod_full_config.json +56 -2
  50. data/spec/fixtures/authorities/linked_data/lod_full_config_1_0.json +164 -0
  51. data/spec/fixtures/authorities/linked_data/lod_lang_defaults.json +5 -4
  52. data/spec/fixtures/authorities/linked_data/lod_lang_multi_defaults.json +3 -2
  53. data/spec/fixtures/authorities/linked_data/lod_lang_no_defaults.json +3 -2
  54. data/spec/fixtures/authorities/linked_data/lod_lang_param.json +3 -2
  55. data/spec/fixtures/authorities/linked_data/lod_min_config.json +3 -2
  56. data/spec/fixtures/authorities/linked_data/lod_search_only_config.json +2 -1
  57. data/spec/fixtures/authorities/linked_data/lod_sort.json +2 -1
  58. data/spec/fixtures/authorities/linked_data/lod_term_id_param_config.json +2 -1
  59. data/spec/fixtures/authorities/linked_data/lod_term_only_config.json +2 -1
  60. data/spec/fixtures/authorities/linked_data/lod_term_uri_param_config.json +2 -1
  61. data/spec/fixtures/getty-error-response.txt +10 -0
  62. data/spec/fixtures/lod_2_ranked_2_unranked.nt +17 -0
  63. data/spec/fixtures/lod_3_ranked_varying_preds.nt +16 -0
  64. data/spec/fixtures/lod_lang_search_filtering.nt +11 -0
  65. data/spec/fixtures/lod_search_with_blanknode_subjects.nt +18 -0
  66. data/spec/fixtures/lod_term_with_blanknode_objects.nt +8 -0
  67. data/spec/lib/authorities/assign_fast_spec.rb +1 -0
  68. data/spec/lib/authorities/getty/aat_spec.rb +14 -2
  69. data/spec/lib/authorities/getty/tgn_spec.rb +14 -2
  70. data/spec/lib/authorities/getty/ulan_spec.rb +14 -2
  71. data/spec/lib/authorities/linked_data/authority_service_spec.rb +2 -1
  72. data/spec/lib/authorities/linked_data/config_spec.rb +284 -5
  73. data/spec/lib/authorities/linked_data/find_term_spec.rb +3 -1
  74. data/spec/lib/authorities/linked_data/generic_authority_spec.rb +92 -42
  75. data/spec/lib/authorities/linked_data/search_config_spec.rb +67 -160
  76. data/spec/lib/authorities/linked_data/search_query_spec.rb +3 -127
  77. data/spec/lib/authorities/linked_data/term_config_spec.rb +6 -134
  78. data/spec/lib/authorities/loc_spec.rb +9 -9
  79. data/spec/lib/configuration_spec.rb +20 -7
  80. data/spec/lib/tasks/mesh.rake_spec.rb +2 -2
  81. data/spec/models/iri_template/url_config_spec.rb +102 -0
  82. data/spec/models/iri_template/variable_map_spec.rb +105 -0
  83. data/spec/models/linked_data/config/context_map_spec.rb +148 -0
  84. data/spec/models/linked_data/config/context_property_map_spec.rb +286 -0
  85. data/spec/services/iri_template_service_spec.rb +69 -0
  86. data/spec/services/linked_data/authority_url_service_spec.rb +107 -0
  87. data/spec/services/linked_data/deep_sort_service_spec.rb +260 -0
  88. data/spec/services/linked_data/graph_service_spec.rb +232 -0
  89. data/spec/services/linked_data/language_service_spec.rb +66 -0
  90. data/spec/services/linked_data/language_sort_service_spec.rb +58 -0
  91. data/spec/services/linked_data/mapper/context_mapper_service_spec.rb +137 -0
  92. data/spec/services/linked_data/mapper/graph_mapper_service_spec.rb +110 -0
  93. data/spec/services/linked_data/mapper/search_results_mapper_service_spec.rb +109 -0
  94. data/spec/spec_helper.rb +10 -2
  95. metadata +81 -11
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Qa::IriTemplate::VariableMap do
4
+ subject { described_class.new(map) }
5
+
6
+ let(:map) do
7
+ {
8
+ :"@type" => "IriTemplateMapping",
9
+ property: "hydra:freetextQuery",
10
+ variable: "subauth",
11
+ required: true
12
+ }
13
+ end
14
+
15
+ describe 'model attributes' do
16
+ it { is_expected.to respond_to :variable }
17
+ it { is_expected.to respond_to :simple_value }
18
+ # it { is_expected.to respond_to :parameter_value }
19
+ end
20
+
21
+ describe '#new' do
22
+ context 'when variable is missing' do
23
+ before do
24
+ map.delete(:variable)
25
+ end
26
+
27
+ it 'raises an error' do
28
+ expect { described_class.new(map) }.to raise_error(Qa::InvalidConfiguration, 'variable is required')
29
+ end
30
+ end
31
+
32
+ context 'when invalid required value' do
33
+ before do
34
+ map[:required] = 'BAD_REQUIRED'
35
+ end
36
+
37
+ it 'raises an error' do
38
+ expect { described_class.new(map) }.to raise_error(Qa::InvalidConfiguration, 'required must be true or false')
39
+ end
40
+ end
41
+ end
42
+
43
+ describe '#variable' do
44
+ it 'returns the configured variable' do
45
+ expect(subject.variable).to eq 'subauth'
46
+ end
47
+ end
48
+
49
+ describe '#simple_value' do
50
+ context 'when sub_value is not passed in' do
51
+ context 'and default is not defined' do
52
+ context 'and variable is required' do
53
+ before do
54
+ map[:required] = true
55
+ end
56
+
57
+ it 'raises error' do
58
+ expect { subject.simple_value }.to raise_error(StandardError, 'subauth is required, but missing')
59
+ end
60
+ end
61
+
62
+ context 'and variable is not required' do
63
+ before do
64
+ map[:required] = false
65
+ end
66
+
67
+ it 'returns empty string' do
68
+ expect(subject.simple_value).to eq ''
69
+ end
70
+ end
71
+ end
72
+
73
+ context 'and default is defined' do
74
+ before do
75
+ map[:required] = false
76
+ map[:default] = 'personal_name'
77
+ end
78
+
79
+ it 'returns the default' do
80
+ expect(subject.simple_value).to eq 'personal_name'
81
+ end
82
+ end
83
+ end
84
+
85
+ context 'when sub_value is passed in' do
86
+ before do
87
+ map[:required] = true
88
+ end
89
+
90
+ it 'returns passed in sub_value' do
91
+ expect(subject.simple_value('corporate_name')).to eq 'corporate_name'
92
+ end
93
+ end
94
+
95
+ context 'when sub_value should be encoded' do
96
+ before do
97
+ map[:encode] = true
98
+ end
99
+
100
+ it 'returns encoded sub_value' do
101
+ expect(subject.simple_value('http://example.org/over/the_rainbow')).to eq 'http%3A%2F%2Fexample%2Eorg%2Fover%2Fthe_rainbow'
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,148 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Qa::LinkedData::Config::ContextMap do
4
+ subject { described_class.new(context_map) }
5
+
6
+ before do
7
+ # simulate the existence of the i18n entries
8
+ allow(I18n).to receive(:t).and_call_original
9
+ end
10
+
11
+ let(:context_map) do
12
+ {
13
+ groups: {
14
+ dates: {
15
+ group_label_i18n: 'qa.linked_data.authority.locnames_ld4l_cache.dates',
16
+ group_label_default: 'default_Dates'
17
+ }
18
+ },
19
+ properties: [
20
+ {
21
+ property_label_i18n: 'qa.linked_data.authority.locgenres_ld4l_cache.authoritative_label',
22
+ property_label_default: 'default_Authoritative Label',
23
+ ldpath: 'madsrdf:authoritativeLabel',
24
+ selectable: true,
25
+ drillable: false
26
+ },
27
+ {
28
+ group_id: 'dates',
29
+ property_label_i18n: 'qa.linked_data.authority.locnames_ld4l_cache.birth_date',
30
+ property_label_default: 'default_Birth',
31
+ ldpath: 'madsrdf:identifiesRWO/madsrdf:birthDate/schema:label',
32
+ selectable: false,
33
+ drillable: false
34
+ },
35
+ {
36
+ group_id: 'dates',
37
+ property_label_i18n: 'qa.linked_data.authority.locnames_ld4l_cache.death_date',
38
+ property_label_default: 'default_Death',
39
+ ldpath: 'madsrdf:identifiesRWO/madsrdf:deathDate/schema:label',
40
+ selectable: false,
41
+ drillable: false
42
+ }
43
+ ]
44
+ }
45
+ end
46
+
47
+ let(:prefixes) do
48
+ {
49
+ schema: "http://www.w3.org/2000/01/rdf-schema#",
50
+ skos: "http://www.w3.org/2004/02/skos/core#"
51
+ }
52
+ end
53
+
54
+ describe '#new' do
55
+ it 'accepts a single parameter for context_map' do
56
+ expect(subject).to be_kind_of described_class
57
+ end
58
+
59
+ it 'accepts required context_map parameter and optional prefixes parameter' do
60
+ expect(described_class.new(context_map, prefixes)).to be_kind_of described_class
61
+ end
62
+ end
63
+
64
+ describe '#properties' do
65
+ it 'returns the configured url template' do
66
+ expect(subject.properties.size).to eq 3
67
+ expect(subject.properties.first).to be_kind_of Qa::LinkedData::Config::ContextPropertyMap
68
+ end
69
+ end
70
+
71
+ describe '#group_label' do
72
+ context 'when map defines group_label_i18n key' do
73
+ context 'and i18n translation is defined in locales' do
74
+ before do
75
+ allow(I18n).to receive(:t).with('qa.linked_data.authority.locnames_ld4l_cache.dates', default: 'default_Dates').and_return('Dates')
76
+ end
77
+
78
+ it 'returns the translated text' do
79
+ expect(subject.group_label(:dates)).to eq 'Dates'
80
+ end
81
+ end
82
+
83
+ context 'and i18n translation is NOT defined in locales' do
84
+ context 'and default is defined in the map' do
85
+ before do
86
+ allow(I18n).to receive(:t).with('qa.linked_data.authority.locnames_ld4l_cache.dates', default: 'default_Dates').and_return('default_Dates')
87
+ end
88
+
89
+ it 'returns the default value' do
90
+ expect(subject.group_label(:dates)).to eq 'default_Dates'
91
+ end
92
+ end
93
+
94
+ context 'and default is NOT defined in the map' do
95
+ let(:groups) do
96
+ {
97
+ dates: {
98
+ group_label_i18n: 'qa.linked_data.authority.locnames_ld4l_cache.dates'
99
+ }
100
+ }
101
+ end
102
+ before do
103
+ context_map[:groups] = groups
104
+ allow(I18n).to receive(:t).with('qa.linked_data.authority.locnames_ld4l_cache.dates', nil).and_return(nil)
105
+ end
106
+
107
+ it 'returns nil' do
108
+ expect(subject.group_label(:dates)).to eq nil
109
+ end
110
+ end
111
+ end
112
+ end
113
+
114
+ context 'when map does NOT define group_label_i18n key' do
115
+ context 'and default is defined in map' do
116
+ let(:groups) do
117
+ {
118
+ dates: {
119
+ group_label_default: 'default_Dates'
120
+ }
121
+ }
122
+ end
123
+ before do
124
+ context_map[:groups] = groups
125
+ end
126
+
127
+ it 'returns the default value' do
128
+ expect(subject.group_label(:dates)).to eq 'default_Dates'
129
+ end
130
+ end
131
+
132
+ context 'and default is NOT defined in map' do
133
+ let(:groups) do
134
+ {
135
+ dates: {}
136
+ }
137
+ end
138
+ before do
139
+ context_map[:groups] = groups
140
+ end
141
+
142
+ it 'returns nil' do
143
+ expect(subject.group_label(:dates)).to eq nil
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,286 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Qa::LinkedData::Config::ContextPropertyMap do
4
+ subject { described_class.new(property_map) }
5
+
6
+ let(:property_map) do
7
+ {
8
+ group_id: 'dates',
9
+ property_label_i18n: 'qa.linked_data.authority.locnames_ld4l_cache.birth_date',
10
+ property_label_default: 'default_Birth',
11
+ ldpath: 'madsrdf:identifiesRWO/madsrdf:birthDate/schema:label',
12
+ selectable: false,
13
+ drillable: false,
14
+ expansion_label_ldpath: 'skos:prefLabel ::xsd:string',
15
+ expansion_id_ldpath: 'loc:lccn ::xsd:string'
16
+ }
17
+ end
18
+
19
+ let(:prefixes) do
20
+ {
21
+ schema: 'http://www.w3.org/2000/01/rdf-schema#',
22
+ skos: 'http://www.w3.org/2004/02/skos/core#'
23
+ }
24
+ end
25
+
26
+ describe '#new' do
27
+ context 'when ldpath is missing' do
28
+ before { property_map.delete(:ldpath) }
29
+
30
+ it 'raises an error' do
31
+ expect { subject }.to raise_error(Qa::InvalidConfiguration, 'ldpath is required')
32
+ end
33
+ end
34
+
35
+ context 'when invalid selectable value' do
36
+ before { property_map[:selectable] = 'INVALID' }
37
+
38
+ it 'raises an error' do
39
+ expect { subject }.to raise_error(Qa::InvalidConfiguration, 'selectable must be true or false')
40
+ end
41
+ end
42
+
43
+ context 'when invalid drillable value' do
44
+ before { property_map[:drillable] = 'INVALID' }
45
+
46
+ it 'raises an error' do
47
+ expect { subject }.to raise_error(Qa::InvalidConfiguration, 'drillable must be true or false')
48
+ end
49
+ end
50
+
51
+ it 'accepts a single parameter for property_map' do
52
+ expect(subject).to be_kind_of described_class
53
+ end
54
+
55
+ it 'accepts required property_map parameter and optional prefixes parameter' do
56
+ expect(described_class.new(property_map, prefixes)).to be_kind_of described_class
57
+ end
58
+ end
59
+
60
+ describe '#selectable?' do
61
+ context 'when map has selectable: true' do
62
+ before { property_map[:selectable] = true }
63
+
64
+ it 'returns true' do
65
+ expect(subject.selectable?).to be true
66
+ end
67
+ end
68
+
69
+ context 'when map has selectable: false' do
70
+ before { property_map[:selectable] = false }
71
+
72
+ it 'returns false' do
73
+ expect(subject.selectable?).to be false
74
+ end
75
+ end
76
+
77
+ context 'when selectable: is not defined in the map' do
78
+ before { property_map.delete(:selectable) }
79
+
80
+ it 'returns false' do
81
+ expect(subject.selectable?).to be false
82
+ end
83
+ end
84
+ end
85
+
86
+ describe '#drillable?' do
87
+ context 'when map has drillable: true' do
88
+ before { property_map[:drillable] = true }
89
+
90
+ it 'returns true' do
91
+ expect(subject.drillable?).to be true
92
+ end
93
+ end
94
+
95
+ context 'when map has drillable: false' do
96
+ before { property_map[:drillable] = false }
97
+
98
+ it 'returns false' do
99
+ expect(subject.drillable?).to be false
100
+ end
101
+ end
102
+
103
+ context 'when drillable: is not defined in the map' do
104
+ before { property_map.delete(:drillable) }
105
+
106
+ it 'returns false' do
107
+ expect(subject.drillable?).to be false
108
+ end
109
+ end
110
+ end
111
+
112
+ describe '#label' do
113
+ context 'when map defines property_label_i18n key' do
114
+ context 'and i18n translation is defined in locales' do
115
+ before do
116
+ allow(I18n).to receive(:t).with('qa.linked_data.authority.locnames_ld4l_cache.birth_date', default: 'default_Birth').and_return('Birth')
117
+ end
118
+
119
+ it 'returns the translated text' do
120
+ expect(subject.label).to eq 'Birth'
121
+ end
122
+ end
123
+
124
+ context 'and i18n translation is NOT defined in locales' do
125
+ context 'and default is defined in the map' do
126
+ before do
127
+ allow(I18n).to receive(:t).with('qa.linked_data.authority.locnames_ld4l_cache.birth_date', default: 'default_Birth').and_return('default_Birth')
128
+ end
129
+
130
+ it 'returns the default value' do
131
+ expect(subject.label).to eq 'default_Birth'
132
+ end
133
+ end
134
+
135
+ context 'and default is NOT defined in the map' do
136
+ before do
137
+ property_map.delete(:property_label_default)
138
+ allow(I18n).to receive(:t).with('qa.linked_data.authority.locnames_ld4l_cache.birth_date', default: nil).and_return(nil)
139
+ end
140
+
141
+ it 'returns nil' do
142
+ expect(subject.label).to eq nil
143
+ end
144
+ end
145
+ end
146
+ end
147
+
148
+ context 'when map does NOT define property_label_i18n key' do
149
+ before { property_map.delete(:property_label_i18n) }
150
+
151
+ context 'and default is defined in map' do
152
+ it 'returns the default value' do
153
+ expect(subject.label).to eq 'default_Birth'
154
+ end
155
+ end
156
+
157
+ context 'and default is NOT defined in map' do
158
+ before { property_map.delete(:property_label_default) }
159
+
160
+ it 'returns nil' do
161
+ expect(subject.label).to eq nil
162
+ end
163
+ end
164
+ end
165
+ end
166
+
167
+ describe '#group_id' do
168
+ context 'when map defines group_id' do
169
+ it 'returns group_id as a symbol' do
170
+ expect(subject.group_id).to eq :dates
171
+ end
172
+ end
173
+
174
+ context 'when map does NOT define group_id' do
175
+ before { property_map.delete(:group_id) }
176
+
177
+ it 'returns nil' do
178
+ expect(subject.group_id).to eq nil
179
+ end
180
+ end
181
+ end
182
+
183
+ describe '#group?' do
184
+ context 'when map defines group_id' do
185
+ it 'returns true' do
186
+ expect(subject.group?).to be true
187
+ end
188
+ end
189
+
190
+ context 'when map does NOT define group_id' do
191
+ before { property_map.delete(:group_id) }
192
+
193
+ it 'returns false' do
194
+ expect(subject.group?).to be false
195
+ end
196
+ end
197
+ end
198
+
199
+ describe '#values' do
200
+ let(:program) { instance_double(Ldpath::Program) }
201
+ let(:coordinates) { '42.4488° N, 76.4763° W' }
202
+ let(:subject_uri) { instance_double(RDF::URI) }
203
+ let(:graph) { instance_double(RDF::Graph) }
204
+
205
+ before do
206
+ allow(Ldpath::Program).to receive(:parse).with(anything).and_return(program)
207
+ allow(program).to receive(:evaluate).with(anything, anything).and_return('property' => [coordinates, coordinates, coordinates]) # check that uniq is applied
208
+ end
209
+ it 'returns the values selected from the graph' do
210
+ expect(subject.values(graph, subject_uri)).to match_array coordinates
211
+ end
212
+
213
+ context 'when ldpath_program gets parse error' do
214
+ let(:ldpath) { property_map[:ldpath] }
215
+ let(:cause) { "undefined method `ascii_tree' for nil:NilClass" }
216
+ let(:warning) { I18n.t('qa.linked_data.ldpath.parse_logger_error') }
217
+ let(:log_message) { "WARNING: #{warning} (ldpath='#{ldpath}')\n cause: #{cause}" }
218
+
219
+ before { allow(Ldpath::Program).to receive(:parse).with(anything).and_raise(cause) }
220
+
221
+ it 'logs error and returns PARSE ERROR as the value' do
222
+ expect(Rails.logger).to receive(:warn).with(log_message)
223
+ expect { subject.values(graph, subject_uri) }.to raise_error StandardError, I18n.t('qa.linked_data.ldpath.parse_error')
224
+ end
225
+ end
226
+
227
+ context 'when ldpath_evaluate gets parse error' do
228
+ let(:ldpath) { property_map[:ldpath] }
229
+ let(:cause) { "unknown cause" }
230
+ let(:warning) { I18n.t('qa.linked_data.ldpath.evaluate_logger_error') }
231
+ let(:log_message) { "WARNING: #{warning} (ldpath='#{ldpath}')\n cause: #{cause}" }
232
+
233
+ before { allow(program).to receive(:evaluate).with(subject_uri, graph).and_raise(cause) }
234
+
235
+ it 'logs error and returns PARSE ERROR as the value' do
236
+ expect(Rails.logger).to receive(:warn).with(log_message)
237
+ expect { subject.values(graph, subject_uri) }.to raise_error StandardError, I18n.t('qa.linked_data.ldpath.evaluate_error')
238
+ end
239
+ end
240
+ end
241
+
242
+ describe '#expand_uri?' do
243
+ context 'when map has a value for expansion_label_ldpath' do
244
+ it 'returns true' do
245
+ expect(subject.expand_uri?).to be true
246
+ end
247
+ end
248
+
249
+ context 'when map does NOT have a value for expansion_label_ldpath' do
250
+ before { property_map.delete(:expansion_label_ldpath) }
251
+
252
+ it 'returns false' do
253
+ expect(subject.expand_uri?).to be false
254
+ end
255
+ end
256
+ end
257
+
258
+ describe '#expanded_values' do
259
+ let(:graph) { instance_double(RDF::Graph) }
260
+ let(:subject_uri) { instance_double(RDF::URI) }
261
+
262
+ let(:basic_program) { instance_double(Ldpath::Program) }
263
+ let(:expanded_label_program) { instance_double(Ldpath::Program) }
264
+ let(:expanded_id_program) { instance_double(Ldpath::Program) }
265
+
266
+ let(:expanded_uri) { instance_double(RDF::URI) }
267
+ let(:expanded_label) { 'A Broader Term' }
268
+ let(:expanded_id) { '123' }
269
+
270
+ before do
271
+ allow(Ldpath::Program).to receive(:parse).with('property = madsrdf:identifiesRWO/madsrdf:birthDate/schema:label ;').and_return(basic_program)
272
+ allow(Ldpath::Program).to receive(:parse).with('property = skos:prefLabel ::xsd:string ;').and_return(expanded_label_program)
273
+ allow(Ldpath::Program).to receive(:parse).with('property = loc:lccn ::xsd:string ;').and_return(expanded_id_program)
274
+ allow(basic_program).to receive(:evaluate).with(subject_uri, graph).and_return('property' => [expanded_uri])
275
+ allow(expanded_label_program).to receive(:evaluate).with(RDF::URI.new(subject_uri), graph).and_return('property' => [expanded_label])
276
+ allow(expanded_id_program).to receive(:evaluate).with(RDF::URI.new(subject_uri), graph).and_return('property' => [expanded_id])
277
+ end
278
+ it 'returns the uri, id, label for the expanded uri value' do
279
+ expanded_values = subject.expanded_values(graph, subject_uri).first
280
+ expect(expanded_values).to be_kind_of Hash
281
+ expect(expanded_values[:uri]).to eq expanded_uri
282
+ expect(expanded_values[:id]).to eq expanded_id
283
+ expect(expanded_values[:label]).to eq expanded_label
284
+ end
285
+ end
286
+ end