ld4l-open_annotation_rdf 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +11 -0
  6. data/LICENSE.txt +14 -0
  7. data/README.md +231 -0
  8. data/Rakefile +2 -0
  9. data/ld4l-open_annotation_rdf.gemspec +46 -0
  10. data/lib/ld4l/open_annotation_rdf.rb +66 -0
  11. data/lib/ld4l/open_annotation_rdf/annotation.rb +82 -0
  12. data/lib/ld4l/open_annotation_rdf/comment_annotation.rb +47 -0
  13. data/lib/ld4l/open_annotation_rdf/comment_body.rb +24 -0
  14. data/lib/ld4l/open_annotation_rdf/configuration.rb +127 -0
  15. data/lib/ld4l/open_annotation_rdf/semantic_tag_annotation.rb +66 -0
  16. data/lib/ld4l/open_annotation_rdf/semantic_tag_body.rb +70 -0
  17. data/lib/ld4l/open_annotation_rdf/tag_annotation.rb +98 -0
  18. data/lib/ld4l/open_annotation_rdf/tag_body.rb +83 -0
  19. data/lib/ld4l/open_annotation_rdf/version.rb +5 -0
  20. data/lib/ld4l/open_annotation_rdf/vocab/cnt.rb +6 -0
  21. data/lib/ld4l/open_annotation_rdf/vocab/dctypes.rb +5 -0
  22. data/lib/ld4l/open_annotation_rdf/vocab/oa.rb +23 -0
  23. data/spec/ld4l/open_annotation_rdf/annotation_spec.rb +603 -0
  24. data/spec/ld4l/open_annotation_rdf/comment_annotation_spec.rb +559 -0
  25. data/spec/ld4l/open_annotation_rdf/comment_body_spec.rb +371 -0
  26. data/spec/ld4l/open_annotation_rdf/configuration_spec.rb +194 -0
  27. data/spec/ld4l/open_annotation_rdf/semantic_tag_annotation_spec.rb +619 -0
  28. data/spec/ld4l/open_annotation_rdf/semantic_tag_body_spec.rb +412 -0
  29. data/spec/ld4l/open_annotation_rdf/tag_annotation_spec.rb +672 -0
  30. data/spec/ld4l/open_annotation_rdf/tag_body_spec.rb +430 -0
  31. data/spec/ld4l/open_annotation_rdf_spec.rb +57 -0
  32. data/spec/spec_helper.rb +21 -0
  33. metadata +201 -0
@@ -0,0 +1,371 @@
1
+ require 'spec_helper'
2
+ require 'ld4l/open_annotation_rdf/vocab/dctypes'
3
+ require 'ld4l/open_annotation_rdf/vocab/oa'
4
+
5
+
6
+ describe 'LD4L::OpenAnnotationRDF::CommentBody' do
7
+
8
+ subject { LD4L::OpenAnnotationRDF::CommentBody.new }
9
+
10
+ describe 'rdf_subject' do
11
+ it "should be a blank node if we haven't set it" do
12
+ expect(subject.rdf_subject.node?).to be true
13
+ end
14
+
15
+ it "should be settable when it has not been set yet" do
16
+ subject.set_subject! RDF::URI('http://example.org/moomin')
17
+ expect(subject.rdf_subject).to eq RDF::URI('http://example.org/moomin')
18
+ end
19
+
20
+ it "should append to base URI when setting to non-URI subject" do
21
+ subject.set_subject! '123'
22
+ expect(subject.rdf_subject).to eq RDF::URI("#{LD4L::OpenAnnotationRDF::CommentBody.base_uri}123")
23
+ end
24
+
25
+ describe 'when changing subject' do
26
+ before do
27
+ subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland'))
28
+ subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject)
29
+ subject << RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land')
30
+ subject.set_subject! RDF::URI('http://example.org/moomin')
31
+ end
32
+
33
+ it 'should update graph subjects' do
34
+ expect(subject.has_statement?(RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland')))).to be true
35
+ end
36
+
37
+ it 'should update graph objects' do
38
+ expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.isPartOf, subject.rdf_subject))).to be true
39
+ end
40
+
41
+ it 'should leave other uris alone' do
42
+ expect(subject.has_statement?(RDF::Statement.new(RDF::URI('http://example.org/moomin_comics'), RDF::DC.relation, 'http://example.org/moomin_land'))).to be true
43
+ end
44
+ end
45
+
46
+ describe 'created with URI subject' do
47
+ before do
48
+ subject.set_subject! RDF::URI('http://example.org/moomin')
49
+ end
50
+
51
+ it 'should not be settable' do
52
+ expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error
53
+ end
54
+ end
55
+ end
56
+
57
+
58
+ # -------------------------------------------------
59
+ # START -- Test attributes specific to this model
60
+ # -------------------------------------------------
61
+
62
+ describe 'type' do
63
+ it "should be set to text and ContentAsText from new" do
64
+ expect(subject.type.size).to eq 2
65
+ expect(subject.type).to include RDFVocabularies::DCTYPES.Text
66
+ expect(subject.type).to include RDFVocabularies::CNT.ContentAsText
67
+ end
68
+
69
+ it "should be settable" do
70
+ subject.type = RDFVocabularies::DCTYPES.Text
71
+ expect(subject.type.size).to eq 1
72
+ expect(subject.type.first).to eq RDFVocabularies::DCTYPES.Text
73
+ end
74
+
75
+ it "should be settable to multiple values" do
76
+ t = [RDFVocabularies::DCTYPES.Text, RDFVocabularies::CNT.ContentAsText]
77
+ subject.set_value(:type,t)
78
+ expect(subject.type.size).to eq 2
79
+ expect(subject.type).to include RDFVocabularies::DCTYPES.Text
80
+ expect(subject.type).to include RDFVocabularies::CNT.ContentAsText
81
+ end
82
+
83
+ it "should be changeable" do
84
+ subject.type = RDFVocabularies::DCTYPES.Text
85
+ subject.type = RDFVocabularies::CNT.ContentAsText
86
+ expect(subject.type.size).to eq 1
87
+ expect(subject.type.first).to eq RDFVocabularies::CNT.ContentAsText
88
+ end
89
+
90
+ it "should be changeable for multiple values" do
91
+ t = [RDFVocabularies::DCTYPES.Text, RDFVocabularies::CNT.ContentAsText]
92
+ subject.set_value(:type,t)
93
+ expect(subject.type.size).to eq 2
94
+ expect(subject.type).to include RDFVocabularies::DCTYPES.Text
95
+ expect(subject.type).to include RDFVocabularies::CNT.ContentAsText
96
+ t = subject.get_values(:type)
97
+ t[0] = RDFVocabularies::OA.Tag # dummy type for testing
98
+ t[1] = RDFVocabularies::OA.SemanticTag # dummy type for testing
99
+ subject.set_value(:type,t)
100
+ expect(subject.type.size).to eq 2
101
+ expect(subject.type).to include RDFVocabularies::OA.Tag
102
+ expect(subject.type).to include RDFVocabularies::OA.SemanticTag
103
+ end
104
+ end
105
+
106
+ describe 'content' do
107
+ it "should be empty array if we haven't set it" do
108
+ expect(subject.content).to match_array([])
109
+ end
110
+
111
+ it "should be settable" do
112
+ subject.content = "bla"
113
+ expect(subject.content).to eq ["bla"]
114
+ end
115
+
116
+ it "should be changeable" do
117
+ subject.content = "bla"
118
+ subject.content = "new bla"
119
+ expect(subject.content).to eq ["new bla"]
120
+ end
121
+ end
122
+
123
+ describe 'format' do
124
+ it "should be empty array if we haven't set it" do
125
+ expect(subject.format).to match_array([])
126
+ end
127
+
128
+ it "should be settable" do
129
+ a_format = "text/rtf"
130
+ subject.format = a_format
131
+ expect(subject.format.first).to eq "text/rtf"
132
+ end
133
+
134
+ it "should be changeable" do
135
+ orig_format = "text/plain"
136
+ new_format = "text/xml"
137
+ subject.format = orig_format
138
+ subject.format = new_format
139
+ expect(subject.format.first).to eq new_format
140
+ end
141
+ end
142
+
143
+ describe '#localname_prefix' do
144
+ it "should return default prefix" do
145
+ prefix = LD4L::OpenAnnotationRDF::CommentBody.localname_prefix
146
+ expect(prefix).to eq "cb"
147
+ end
148
+ end
149
+
150
+ # -----------------------------------------------
151
+ # END -- Test attributes specific to this model
152
+ # -----------------------------------------------
153
+
154
+
155
+ describe "#persisted?" do
156
+ context 'with a repository' do
157
+ before do
158
+ # Create inmemory repository
159
+ repository = RDF::Repository.new
160
+ allow(subject).to receive(:repository).and_return(repository)
161
+ end
162
+
163
+ context "when the object is new" do
164
+ it "should return false" do
165
+ expect(subject).not_to be_persisted
166
+ end
167
+ end
168
+
169
+ context "when it is saved" do
170
+ before do
171
+ subject.content = "bla"
172
+ subject.persist!
173
+ end
174
+
175
+ it "should return true" do
176
+ expect(subject).to be_persisted
177
+ end
178
+
179
+ context "and then modified" do
180
+ before do
181
+ subject.content = "newbla"
182
+ end
183
+
184
+ it "should return true" do
185
+ expect(subject).to be_persisted
186
+ end
187
+ end
188
+ context "and then reloaded" do
189
+ before do
190
+ subject.reload
191
+ end
192
+
193
+ it "should reset the content" do
194
+ expect(subject.content).to eq ["bla"]
195
+ end
196
+
197
+ it "should be persisted" do
198
+ expect(subject).to be_persisted
199
+ end
200
+ end
201
+ end
202
+ end
203
+ end
204
+
205
+ describe "#persist!" do
206
+ context "when the repository is set" do
207
+ context "and the item is not a blank node" do
208
+
209
+ subject {LD4L::OpenAnnotationRDF::CommentBody.new("123")}
210
+
211
+ before do
212
+ # Create inmemory repository
213
+ @repo = RDF::Repository.new
214
+ allow(subject.class).to receive(:repository).and_return(nil)
215
+ allow(subject).to receive(:repository).and_return(@repo)
216
+ subject.content = "bla"
217
+ subject.persist!
218
+ end
219
+
220
+ it "should persist to the repository" do
221
+ expect(@repo.statements.first).to eq subject.statements.first
222
+ end
223
+
224
+ it "should delete from the repository" do
225
+ subject.reload
226
+ expect(subject.content).to eq ["bla"]
227
+ subject.content = []
228
+ expect(subject.content).to eq []
229
+ subject.persist!
230
+ subject.reload
231
+ expect(subject.content).to eq []
232
+ expect(@repo.statements.to_a.length).to eq 2 # Only the 2 type statements
233
+ end
234
+ end
235
+ end
236
+ end
237
+
238
+ describe '#destroy!' do
239
+ before do
240
+ subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
241
+ end
242
+
243
+ subject { LD4L::OpenAnnotationRDF::CommentBody.new('456')}
244
+
245
+ it 'should return true' do
246
+ expect(subject.destroy!).to be true
247
+ expect(subject.destroy).to be true
248
+ end
249
+
250
+ it 'should delete the graph' do
251
+ subject.destroy
252
+ expect(subject).to be_empty
253
+ end
254
+ end
255
+
256
+ describe '#rdf_label' do
257
+ subject {LD4L::OpenAnnotationRDF::CommentBody.new("123")}
258
+
259
+ it 'should return an array of label values' do
260
+ expect(subject.rdf_label).to be_kind_of Array
261
+ end
262
+
263
+ it 'should return the default label as URI when no title property exists' do
264
+ expect(subject.rdf_label).to eq [RDF::URI("#{LD4L::OpenAnnotationRDF::CommentBody.base_uri}123")]
265
+ end
266
+
267
+ it 'should prioritize configured label values' do
268
+ custom_label = RDF::URI('http://example.org/custom_label')
269
+ subject.class.configure :rdf_label => custom_label
270
+ subject << RDF::Statement(subject.rdf_subject, custom_label, RDF::Literal('New Label'))
271
+ expect(subject.rdf_label).to eq ['New Label']
272
+ end
273
+ end
274
+
275
+ describe '#solrize' do
276
+ it 'should return a label for bnodes' do
277
+ expect(subject.solrize).to eq subject.rdf_label
278
+ end
279
+
280
+ it 'should return a string of the resource uri' do
281
+ subject.set_subject! 'http://example.org/moomin'
282
+ expect(subject.solrize).to eq 'http://example.org/moomin'
283
+ end
284
+ end
285
+
286
+ describe 'editing the graph' do
287
+ it 'should write properties when statements are added' do
288
+ subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::CNT.chars, 'Great book!')
289
+ expect(subject.content).to include 'Great book!'
290
+ end
291
+
292
+ it 'should delete properties when statements are removed' do
293
+ subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::CNT.chars, 'Great book!')
294
+ subject.delete RDF::Statement.new(subject.rdf_subject, RDFVocabularies::CNT.chars, 'Great book!')
295
+ expect(subject.content).to eq []
296
+ end
297
+ end
298
+
299
+ describe 'big complex graphs' do
300
+ before do
301
+ class DummyPerson < ActiveTriples::Resource
302
+ configure :type => RDF::URI('http://example.org/Person')
303
+ property :foafname, :predicate => RDF::FOAF.name
304
+ property :publications, :predicate => RDF::FOAF.publications, :class_name => 'DummyDocument'
305
+ property :knows, :predicate => RDF::FOAF.knows, :class_name => DummyPerson
306
+ end
307
+
308
+ class DummyDocument < ActiveTriples::Resource
309
+ configure :type => RDF::URI('http://example.org/Document')
310
+ property :title, :predicate => RDF::DC.title
311
+ property :creator, :predicate => RDF::DC.creator, :class_name => 'DummyPerson'
312
+ end
313
+
314
+ LD4L::OpenAnnotationRDF::CommentBody.property :item, :predicate => RDF::DC.relation, :class_name => DummyDocument
315
+ end
316
+
317
+ subject { LD4L::OpenAnnotationRDF::CommentBody.new }
318
+
319
+ let (:document1) do
320
+ d = DummyDocument.new
321
+ d.title = 'Document One'
322
+ d
323
+ end
324
+
325
+ let (:document2) do
326
+ d = DummyDocument.new
327
+ d.title = 'Document Two'
328
+ d
329
+ end
330
+
331
+ let (:person1) do
332
+ p = DummyPerson.new
333
+ p.foafname = 'Alice'
334
+ p
335
+ end
336
+
337
+ let (:person2) do
338
+ p = DummyPerson.new
339
+ p.foafname = 'Bob'
340
+ p
341
+ end
342
+
343
+ let (:data) { <<END
344
+ _:1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/SomeClass> .
345
+ _:1 <http://purl.org/dc/terms/relation> _:2 .
346
+ _:2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Document> .
347
+ _:2 <http://purl.org/dc/terms/title> "Document One" .
348
+ _:2 <http://purl.org/dc/terms/creator> _:3 .
349
+ _:2 <http://purl.org/dc/terms/creator> _:4 .
350
+ _:4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Person> .
351
+ _:4 <http://xmlns.com/foaf/0.1/name> "Bob" .
352
+ _:3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Person> .
353
+ _:3 <http://xmlns.com/foaf/0.1/name> "Alice" .
354
+ _:3 <http://xmlns.com/foaf/0.1/knows> _:4 ."
355
+ END
356
+ }
357
+
358
+ after do
359
+ Object.send(:remove_const, "DummyDocument")
360
+ Object.send(:remove_const, "DummyPerson")
361
+ end
362
+
363
+ it 'should allow access to deep nodes' do
364
+ document1.creator = [person1, person2]
365
+ document2.creator = person1
366
+ person1.knows = person2
367
+ subject.item = [document1]
368
+ expect(subject.item.first.creator.first.knows.first.foafname).to eq ['Bob']
369
+ end
370
+ end
371
+ end
@@ -0,0 +1,194 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'LD4L::OpenAnnotationRDF' do
4
+
5
+ describe '#configuration' do
6
+ describe "base_uri" do
7
+ context "when base_uri is not configured" do
8
+ before do
9
+ class DummyAnnotation < LD4L::OpenAnnotationRDF::Annotation
10
+ configure :type => RDFVocabularies::OA.Annotation, :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri, :repository => :default
11
+ end
12
+ end
13
+ after do
14
+ Object.send(:remove_const, "DummyAnnotation") if Object
15
+ end
16
+ it "should generate an Annotation URI using the default base_uri" do
17
+ expect(DummyAnnotation.new('1').rdf_subject.to_s).to eq "http://localhost/1"
18
+ end
19
+ end
20
+
21
+ context "when uri ends with slash" do
22
+ before do
23
+ LD4L::OpenAnnotationRDF.configure do |config|
24
+ config.base_uri = "http://localhost/test_slash/"
25
+ end
26
+ class DummyAnnotation < LD4L::OpenAnnotationRDF::Annotation
27
+ configure :type => RDFVocabularies::OA.Annotation, :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri, :repository => :default
28
+ end
29
+ end
30
+ after do
31
+ Object.send(:remove_const, "DummyAnnotation") if Object
32
+ LD4L::OpenAnnotationRDF.reset
33
+ end
34
+
35
+ it "should generate an Annotation URI using the configured base_uri" do
36
+ expect(DummyAnnotation.new('1').rdf_subject.to_s).to eq "http://localhost/test_slash/1"
37
+ end
38
+ end
39
+
40
+ context "when uri does not end with slash" do
41
+ before do
42
+ LD4L::OpenAnnotationRDF.configure do |config|
43
+ config.base_uri = "http://localhost/test_no_slash"
44
+ end
45
+ class DummyAnnotation < LD4L::OpenAnnotationRDF::Annotation
46
+ configure :type => RDFVocabularies::OA.Annotation, :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri, :repository => :default
47
+ end
48
+ end
49
+ after do
50
+ Object.send(:remove_const, "DummyAnnotation") if Object
51
+ LD4L::OpenAnnotationRDF.reset
52
+ end
53
+
54
+ it "should generate an Annotation URI using the configured base_uri" do
55
+ expect(DummyAnnotation.new('1').rdf_subject.to_s).to eq "http://localhost/test_no_slash/1"
56
+ end
57
+ end
58
+
59
+ it "should return value of configured base_uri" do
60
+ LD4L::OpenAnnotationRDF.configure do |config|
61
+ config.base_uri = "http://localhost/test_config/"
62
+ end
63
+ expect(LD4L::OpenAnnotationRDF.configuration.base_uri).to eq "http://localhost/test_config/"
64
+ end
65
+
66
+ it "should return default base_uri when base_uri is reset" do
67
+ LD4L::OpenAnnotationRDF.configure do |config|
68
+ config.base_uri = "http://localhost/test_config/"
69
+ end
70
+ expect(LD4L::OpenAnnotationRDF.configuration.base_uri).to eq "http://localhost/test_config/"
71
+ LD4L::OpenAnnotationRDF.configuration.reset_base_uri
72
+ expect(LD4L::OpenAnnotationRDF.configuration.base_uri).to eq "http://localhost/"
73
+ end
74
+
75
+ it "should return default base_uri when all configs are reset" do
76
+ LD4L::OpenAnnotationRDF.configure do |config|
77
+ config.base_uri = "http://localhost/test_config/"
78
+ end
79
+ expect(LD4L::OpenAnnotationRDF.configuration.base_uri).to eq "http://localhost/test_config/"
80
+ LD4L::OpenAnnotationRDF.reset
81
+ expect(LD4L::OpenAnnotationRDF.configuration.base_uri).to eq "http://localhost/"
82
+ end
83
+ end
84
+
85
+ describe "localname_minter" do
86
+ context "when minter is nil" do
87
+ before do
88
+ class DummyAnnotation < LD4L::OpenAnnotationRDF::Annotation
89
+ configure :type => RDFVocabularies::OA.Annotation, :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri, :repository => :default
90
+ end
91
+ end
92
+ after do
93
+ Object.send(:remove_const, "DummyAnnotation") if Object
94
+ end
95
+ it "should use default minter in minter gem" do
96
+ localname = ActiveTriples::LocalName::Minter.generate_local_name(
97
+ LD4L::OpenAnnotationRDF::Annotation, 10, {:prefix=>'default_'},
98
+ LD4L::OpenAnnotationRDF.configuration.localname_minter )
99
+ expect(localname).to be_kind_of String
100
+ expect(localname.size).to eq 44
101
+ expect(localname).to match /default_[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}/
102
+ end
103
+ end
104
+
105
+ context "when minter is configured" do
106
+ before do
107
+ LD4L::OpenAnnotationRDF.configure do |config|
108
+ config.localname_minter = lambda { |prefix=""| prefix+'_configured_'+SecureRandom.uuid }
109
+ end
110
+ class DummyAnnotation < LD4L::OpenAnnotationRDF::Annotation
111
+ configure :type => RDFVocabularies::OA.Annotation, :base_uri => LD4L::OpenAnnotationRDF.configuration.base_uri, :repository => :default
112
+ end
113
+ end
114
+ after do
115
+ Object.send(:remove_const, "DummyAnnotation") if Object
116
+ LD4L::OpenAnnotationRDF.reset
117
+ end
118
+
119
+ it "should generate an Annotation URI using the configured localname_minter" do
120
+ localname = ActiveTriples::LocalName::Minter.generate_local_name(
121
+ LD4L::OpenAnnotationRDF::Annotation, 10,
122
+ LD4L::OpenAnnotationRDF::Annotation.localname_prefix,
123
+ &LD4L::OpenAnnotationRDF.configuration.localname_minter )
124
+ expect(localname).to be_kind_of String
125
+ expect(localname.size).to eq 50
126
+ expect(localname).to match /oa_configured_[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}/
127
+ end
128
+ end
129
+ end
130
+ end
131
+
132
+
133
+ describe "LD4L::OpenAnnotationRDF::Configuration" do
134
+ describe "#base_uri" do
135
+ it "should default to localhost" do
136
+ expect(LD4L::OpenAnnotationRDF::Configuration.new.base_uri).to eq "http://localhost/"
137
+ end
138
+
139
+ it "should be settable" do
140
+ config = LD4L::OpenAnnotationRDF::Configuration.new
141
+ config.base_uri = "http://localhost/test"
142
+ expect(config.base_uri).to eq "http://localhost/test"
143
+ end
144
+
145
+ it "should be re-settable" do
146
+ config = LD4L::OpenAnnotationRDF::Configuration.new
147
+ config.base_uri = "http://localhost/test/again"
148
+ expect(config.base_uri).to eq "http://localhost/test/again"
149
+ config.reset_base_uri
150
+ expect(config.base_uri).to eq "http://localhost/"
151
+ end
152
+ end
153
+
154
+ describe "#localname_minter" do
155
+ it "should default to nil" do
156
+ expect(LD4L::OpenAnnotationRDF::Configuration.new.localname_minter).to eq nil
157
+ end
158
+
159
+ it "should be settable" do
160
+ config = LD4L::OpenAnnotationRDF::Configuration.new
161
+ config.localname_minter = lambda { |prefix=""| prefix+'_configured_'+SecureRandom.uuid }
162
+ expect(config.localname_minter).to be_kind_of Proc
163
+ end
164
+
165
+ it "should be re-settable" do
166
+ config = LD4L::OpenAnnotationRDF::Configuration.new
167
+ config.localname_minter = lambda { |prefix=""| prefix+'_configured_'+SecureRandom.uuid }
168
+ expect(config.localname_minter).to be_kind_of Proc
169
+ config.reset_localname_minter
170
+ expect(config.localname_minter).to eq nil
171
+ end
172
+ end
173
+
174
+ describe "#unique_tags" do
175
+ it "should default to true" do
176
+ expect(LD4L::OpenAnnotationRDF::Configuration.new.unique_tags).to be true
177
+ end
178
+
179
+ it "should be settable" do
180
+ config = LD4L::OpenAnnotationRDF::Configuration.new
181
+ config.unique_tags = false
182
+ expect(config.unique_tags).to be false
183
+ end
184
+
185
+ it "should be re-settable" do
186
+ config = LD4L::OpenAnnotationRDF::Configuration.new
187
+ config.unique_tags = false
188
+ expect(config.unique_tags).to be false
189
+ config.reset_unique_tags
190
+ expect(config.unique_tags).to be true
191
+ end
192
+ end
193
+ end
194
+ end