yaml-ld 0.0.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.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/AUTHORS +1 -0
  3. data/README.md +150 -0
  4. data/UNLICENSE +24 -0
  5. data/VERSION +1 -0
  6. data/lib/yaml_ld/api.rb +295 -0
  7. data/lib/yaml_ld/format.rb +56 -0
  8. data/lib/yaml_ld/reader.rb +40 -0
  9. data/lib/yaml_ld/version.rb +20 -0
  10. data/lib/yaml_ld/writer.rb +42 -0
  11. data/lib/yaml_ld.rb +37 -0
  12. data/spec/api_spec.rb +92 -0
  13. data/spec/compact_spec.rb +358 -0
  14. data/spec/expand_spec.rb +565 -0
  15. data/spec/flatten_spec.rb +225 -0
  16. data/spec/format_spec.rb +54 -0
  17. data/spec/frame_spec.rb +662 -0
  18. data/spec/from_rdf_spec.rb +730 -0
  19. data/spec/matchers.rb +22 -0
  20. data/spec/reader_spec.rb +138 -0
  21. data/spec/spec_helper.rb +265 -0
  22. data/spec/support/extensions.rb +44 -0
  23. data/spec/test-files/test-1-compacted.jsonld +10 -0
  24. data/spec/test-files/test-1-context.jsonld +7 -0
  25. data/spec/test-files/test-1-expanded.jsonld +5 -0
  26. data/spec/test-files/test-1-input.yamlld +8 -0
  27. data/spec/test-files/test-1-rdf.ttl +8 -0
  28. data/spec/test-files/test-2-compacted.jsonld +20 -0
  29. data/spec/test-files/test-2-context.jsonld +7 -0
  30. data/spec/test-files/test-2-expanded.jsonld +16 -0
  31. data/spec/test-files/test-2-input.yamlld +16 -0
  32. data/spec/test-files/test-2-rdf.ttl +14 -0
  33. data/spec/test-files/test-3-compacted.jsonld +11 -0
  34. data/spec/test-files/test-3-context.jsonld +8 -0
  35. data/spec/test-files/test-3-expanded.jsonld +10 -0
  36. data/spec/test-files/test-3-input.yamlld +13 -0
  37. data/spec/test-files/test-3-rdf.ttl +8 -0
  38. data/spec/test-files/test-4-compacted.jsonld +10 -0
  39. data/spec/test-files/test-4-context.jsonld +7 -0
  40. data/spec/test-files/test-4-expanded.jsonld +6 -0
  41. data/spec/test-files/test-4-input.yamlld +9 -0
  42. data/spec/test-files/test-4-rdf.ttl +5 -0
  43. data/spec/test-files/test-5-compacted.jsonld +13 -0
  44. data/spec/test-files/test-5-context.jsonld +7 -0
  45. data/spec/test-files/test-5-expanded.jsonld +9 -0
  46. data/spec/test-files/test-5-input.yamlld +10 -0
  47. data/spec/test-files/test-5-rdf.ttl +7 -0
  48. data/spec/test-files/test-6-compacted.jsonld +10 -0
  49. data/spec/test-files/test-6-context.jsonld +7 -0
  50. data/spec/test-files/test-6-expanded.jsonld +10 -0
  51. data/spec/test-files/test-6-input.yamlld +12 -0
  52. data/spec/test-files/test-6-rdf.ttl +6 -0
  53. data/spec/test-files/test-7-compacted.jsonld +23 -0
  54. data/spec/test-files/test-7-context.jsonld +4 -0
  55. data/spec/test-files/test-7-expanded.jsonld +20 -0
  56. data/spec/test-files/test-7-input.yamlld +16 -0
  57. data/spec/test-files/test-7-rdf.ttl +14 -0
  58. data/spec/test-files/test-8-compacted.jsonld +34 -0
  59. data/spec/test-files/test-8-context.jsonld +11 -0
  60. data/spec/test-files/test-8-expanded.jsonld +24 -0
  61. data/spec/test-files/test-8-frame.jsonld +18 -0
  62. data/spec/test-files/test-8-framed.jsonld +25 -0
  63. data/spec/test-files/test-8-input.yamlld +24 -0
  64. data/spec/test-files/test-8-rdf.ttl +15 -0
  65. data/spec/test-files/test-9-compacted.jsonld +20 -0
  66. data/spec/test-files/test-9-context.jsonld +13 -0
  67. data/spec/test-files/test-9-expanded.jsonld +14 -0
  68. data/spec/test-files/test-9-input.yamlld +16 -0
  69. data/spec/to_rdf_spec.rb +556 -0
  70. data/spec/writer_spec.rb +441 -0
  71. metadata +350 -0
@@ -0,0 +1,556 @@
1
+ # coding: utf-8
2
+ require_relative 'spec_helper'
3
+
4
+ describe YAML_LD::API do
5
+ let(:logger) {RDF::Spec.logger}
6
+
7
+ context ".toRdf" do
8
+ it "should implement RDF::Enumerable" do
9
+ expect(YAML_LD::API.toRdf({})).to be_a(RDF::Enumerable)
10
+ end
11
+
12
+ context "unnamed nodes" do
13
+ {
14
+ "no @id" => [
15
+ %q(
16
+ http://example.com/foo: bar
17
+ ),
18
+ %q([ <http://example.com/foo> "bar"^^xsd:string] .)
19
+ ],
20
+ "@id with _:a" => [
21
+ %q(
22
+ "@id": _:a
23
+ http://example.com/foo: bar
24
+ ),
25
+ %q([ <http://example.com/foo> "bar"^^xsd:string] .)
26
+ ],
27
+ "@id with _:a and reference" => [
28
+ %q(
29
+ "@id": _:a
30
+ http://example.com/foo:
31
+ "@id": _:a
32
+ ),
33
+ %q(_:a <http://example.com/foo> _:a .)
34
+ ],
35
+ }.each do |title, (js, ttl)|
36
+ it title do
37
+ ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
38
+ expect(parse(js)).to be_equivalent_graph(ttl, logger: logger, inputDocument: js)
39
+ end
40
+ end
41
+ end
42
+
43
+ context "nodes with @id" do
44
+ {
45
+ "with IRI" => [
46
+ %q(
47
+ "@id": http://example.com/a
48
+ http://example.com/foo: bar
49
+ ),
50
+ %q(<http://example.com/a> <http://example.com/foo> "bar" .)
51
+ ],
52
+ }.each do |title, (js, ttl)|
53
+ it title do
54
+ ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
55
+ expect(parse(js)).to be_equivalent_graph(ttl, logger: logger, inputDocument: js)
56
+ end
57
+ end
58
+
59
+ context "with relative IRIs" do
60
+ {
61
+ "base" => [
62
+ %(
63
+ "@id": ''
64
+ "@type": "#{RDF::RDFS.Resource}"
65
+ ),
66
+ %(<http://example.org/> a <#{RDF::RDFS.Resource}> .)
67
+ ],
68
+ "relative" => [
69
+ %(
70
+ "@id": a/b
71
+ "@type": "#{RDF::RDFS.Resource}"
72
+ ),
73
+ %(<http://example.org/a/b> a <#{RDF::RDFS.Resource}> .)
74
+ ],
75
+ "hash" => [
76
+ %(
77
+ "@id": "#a"
78
+ "@type": "#{RDF::RDFS.Resource}"
79
+ ),
80
+ %(<http://example.org/#a> a <#{RDF::RDFS.Resource}> .)
81
+ ],
82
+ }.each do |title, (js, ttl)|
83
+ it title do
84
+ ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
85
+ expect(parse(js, base: "http://example.org/")).to be_equivalent_graph(ttl, logger: logger, inputDocument: js)
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ context "typed nodes" do
92
+ {
93
+ "one type" => [
94
+ %q(
95
+ "@type": "http://example.com/foo"
96
+ ),
97
+ %q([ a <http://example.com/foo> ] .)
98
+ ],
99
+ "two types" => [
100
+ %q(
101
+ "@type":
102
+ - http://example.com/foo
103
+ - http://example.com/baz
104
+ ),
105
+ %q([ a <http://example.com/foo>, <http://example.com/baz> ] .)
106
+ ],
107
+ "blank node type" => [
108
+ %q(
109
+ "@type": _:foo
110
+ ),
111
+ %q([ a _:foo ] .)
112
+ ]
113
+ }.each do |title, (js, ttl)|
114
+ it title do
115
+ ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
116
+ expect(parse(js)).to be_equivalent_graph(ttl, logger: logger, inputDocument: js)
117
+ end
118
+ end
119
+ end
120
+
121
+ context "key/value" do
122
+ {
123
+ "string" => [
124
+ %q(
125
+ http://example.com/foo: bar
126
+ ),
127
+ %q([ <http://example.com/foo> "bar"^^xsd:string ] .)
128
+ ],
129
+ "strings" => [
130
+ %q(
131
+ http://example.com/foo:
132
+ - bar
133
+ - baz
134
+ }),
135
+ %q([ <http://example.com/foo> "bar"^^xsd:string, "baz"^^xsd:string ] .)
136
+ ],
137
+ "IRI" => [
138
+ %q(
139
+ http://example.com/foo:
140
+ "@id": http://example.com/bar
141
+ }),
142
+ %q([ <http://example.com/foo> <http://example.com/bar> ] .)
143
+ ],
144
+ "IRIs" => [
145
+ %q(
146
+ http://example.com/foo:
147
+ - "@id": http://example.com/bar
148
+ - "@id": http://example.com/baz
149
+ }),
150
+ %q([ <http://example.com/foo> <http://example.com/bar>, <http://example.com/baz> ] .)
151
+ ],
152
+ }.each do |title, (js, ttl)|
153
+ it title do
154
+ ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
155
+ expect(parse(js)).to be_equivalent_graph(ttl, logger: logger, inputDocument: js)
156
+ end
157
+ end
158
+ end
159
+
160
+ context "literals" do
161
+ {
162
+ "plain literal" =>
163
+ [
164
+ %q(
165
+ "@id": http://greggkellogg.net/foaf#me
166
+ http://xmlns.com/foaf/0.1/name: Gregg Kellogg
167
+ ),
168
+ %q(<http://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" .)
169
+ ],
170
+ "explicit plain literal" =>
171
+ [
172
+ %q(
173
+ http://xmlns.com/foaf/0.1/name:
174
+ "@value": Gregg Kellogg
175
+ ),
176
+ %q(_:a <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg"^^xsd:string .)
177
+ ],
178
+ "language tagged literal" =>
179
+ [
180
+ %q(
181
+ http://www.w3.org/2000/01/rdf-schema#label:
182
+ "@value": A plain literal with a lang tag.
183
+ "@language": en-us
184
+ ),
185
+ %q(_:a <http://www.w3.org/2000/01/rdf-schema#label> "A plain literal with a lang tag."@en-us .)
186
+ ],
187
+ "I18N literal with language" =>
188
+ [
189
+ %q(
190
+ - "@id": http://greggkellogg.net/foaf#me
191
+ http://xmlns.com/foaf/0.1/knows:
192
+ "@id": http://www.ivan-herman.net/foaf#me
193
+ - "@id": http://www.ivan-herman.net/foaf#me
194
+ http://xmlns.com/foaf/0.1/name:
195
+ "@value": Herman Iván
196
+ "@language": hu
197
+ ),
198
+ %q(
199
+ <http://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/knows> <http://www.ivan-herman.net/foaf#me> .
200
+ <http://www.ivan-herman.net/foaf#me> <http://xmlns.com/foaf/0.1/name> "Herman Iv\u00E1n"@hu .
201
+ )
202
+ ],
203
+ "explicit datatyped literal" =>
204
+ [
205
+ %q(
206
+ "@id": http://greggkellogg.net/foaf#me
207
+ http://purl.org/dc/terms/created:
208
+ "@value": '1957-02-27'
209
+ "@type": http://www.w3.org/2001/XMLSchema#date
210
+ ),
211
+ %q(
212
+ <http://greggkellogg.net/foaf#me> <http://purl.org/dc/terms/created> "1957-02-27"^^<http://www.w3.org/2001/XMLSchema#date> .
213
+ )
214
+ ],
215
+ }.each do |title, (js, ttl)|
216
+ it title do
217
+ ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
218
+ expect(parse(js)).to be_equivalent_graph(ttl, logger: logger, inputDocument: js)
219
+ end
220
+ end
221
+
222
+ context "with @type: @json" do
223
+ {
224
+ "true": {
225
+ input: %(
226
+ "@context":
227
+ "@version": 1.1
228
+ e:
229
+ "@id": http://example.org/vocab#bool
230
+ "@type": "@json"
231
+ e: true
232
+ ),
233
+ output:%(
234
+ @prefix ex: <http://example.org/vocab#> .
235
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
236
+ [ex:bool "true"^^rdf:JSON] .
237
+ )
238
+ },
239
+ "false": {
240
+ input: %(
241
+ "@context":
242
+ "@version": 1.1
243
+ e:
244
+ "@id": http://example.org/vocab#bool
245
+ "@type": "@json"
246
+ e: false
247
+ ),
248
+ output: %(
249
+ @prefix ex: <http://example.org/vocab#> .
250
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
251
+ [ex:bool "false"^^rdf:JSON] .
252
+ )
253
+ },
254
+ "double": {
255
+ input: %(
256
+ "@context":
257
+ "@version": 1.1
258
+ e:
259
+ "@id": http://example.org/vocab#double
260
+ "@type": "@json"
261
+ e: 1.23
262
+ ),
263
+ output: %(
264
+ @prefix ex: <http://example.org/vocab#> .
265
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
266
+ [ex:double "1.23"^^rdf:JSON] .
267
+ )
268
+ },
269
+ #"double-zero": {
270
+ # input: %(
271
+ # "@context":
272
+ # "@version": 1.1
273
+ # e:
274
+ # "@id": http://example.org/vocab#double
275
+ # "@type": "@json"
276
+ # e: 0.0e0
277
+ # ),
278
+ # output: %(
279
+ # @prefix ex: <http://example.org/vocab#> .
280
+ # @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
281
+ # [ex:double "0.0e0"^^rdf:JSON] .
282
+ # )
283
+ #},
284
+ "integer": {
285
+ input: %(
286
+ "@context":
287
+ "@version": 1.1
288
+ e:
289
+ "@id": http://example.org/vocab#integer
290
+ "@type": "@json"
291
+ e: 123
292
+ ),
293
+ output: %(
294
+ @prefix ex: <http://example.org/vocab#> .
295
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
296
+ [ex:integer "123"^^rdf:JSON] .
297
+ )
298
+ },
299
+ "string": {
300
+ input: %(
301
+ "@context":
302
+ "@version": 1.1
303
+ e:
304
+ "@id": http://example.org/vocab#string
305
+ "@type": "@json"
306
+ e: string
307
+ ),
308
+ output: %(
309
+ @prefix ex: <http://example.org/vocab#> .
310
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
311
+ [ex:string "\\"string\\""^^rdf:JSON] .
312
+ )
313
+ },
314
+ "null": {
315
+ input: %(
316
+ "@context":
317
+ "@version": 1.1
318
+ e:
319
+ "@id": http://example.org/vocab#null
320
+ "@type": "@json"
321
+ e: null
322
+ ),
323
+ output: %(
324
+ @prefix ex: <http://example.org/vocab#> .
325
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
326
+ [ex:null "null"^^rdf:JSON] .
327
+ )
328
+ },
329
+ "object": {
330
+ input: %(
331
+ "@context":
332
+ "@version": 1.1
333
+ e:
334
+ "@id": http://example.org/vocab#object
335
+ "@type": "@json"
336
+ e:
337
+ foo: bar
338
+ ),
339
+ output: %(
340
+ @prefix ex: <http://example.org/vocab#> .
341
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
342
+ [ex:object """{"foo":"bar"}"""^^rdf:JSON] .
343
+ )
344
+ },
345
+ "array": {
346
+ input: %(
347
+ "@context":
348
+ "@version": 1.1
349
+ e:
350
+ "@id": http://example.org/vocab#array
351
+ "@type": "@json"
352
+ e:
353
+ - foo: bar
354
+ ),
355
+ output: %(
356
+ @prefix ex: <http://example.org/vocab#> .
357
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
358
+ [ex:array """[{"foo":"bar"}]"""^^rdf:JSON] .
359
+ )
360
+ },
361
+ "c14n-arrays": {
362
+ input: %(
363
+ "@context":
364
+ "@version": 1.1
365
+ e:
366
+ "@id": http://example.org/vocab#c14n
367
+ "@type": "@json"
368
+ e:
369
+ - 56
370
+ - '1': []
371
+ '10':
372
+ d: true
373
+ ),
374
+ output: %(
375
+ @prefix ex: <http://example.org/vocab#> .
376
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
377
+ [ex:c14n """[56,{"1":[],"10":null,"d":true}]"""^^rdf:JSON] .
378
+ )
379
+ },
380
+ "c14n-french": {
381
+ input: %(
382
+ "@context":
383
+ "@version": 1.1
384
+ e:
385
+ "@id": http://example.org/vocab#c14n
386
+ "@type": "@json"
387
+ e:
388
+ peach: This sorting order
389
+ péché: is wrong according to French
390
+ pêche: but canonicalization MUST
391
+ sin: ignore locale
392
+ ),
393
+ output: %(
394
+ @prefix ex: <http://example.org/vocab#> .
395
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
396
+ [ex:c14n """{"peach":"This sorting order","péché":"is wrong according to French","pêche":"but canonicalization MUST","sin":"ignore locale"}"""^^rdf:JSON] .
397
+ )
398
+ },
399
+ "c14n-structures": {
400
+ input: %(
401
+ "@context":
402
+ "@version": 1.1
403
+ e:
404
+ "@id": http://example.org/vocab#c14n
405
+ "@type": "@json"
406
+ e:
407
+ '1':
408
+ f:
409
+ f: hi
410
+ F: 5
411
+ " ": 56
412
+ '10': {}
413
+ '111':
414
+ - e: 'yes'
415
+ E: 'no'
416
+ '': empty
417
+ a: {}
418
+ A: {}
419
+ ),
420
+ output: %(
421
+ @prefix ex: <http://example.org/vocab#> .
422
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
423
+ [ex:c14n """{"":"empty","1":{" ":56,"f":{"F":5,"f":"hi"}},"10":{},"111":[{"E":"no","e":"yes"}],"A":{},"a":{}}"""^^rdf:JSON] .
424
+ )
425
+ },
426
+ "c14n-unicode": {
427
+ input: %(
428
+ "@context":
429
+ "@version": 1.1
430
+ e:
431
+ "@id": http://example.org/vocab#c14n
432
+ "@type": "@json"
433
+ e:
434
+ Unnormalized Unicode: Å
435
+ ),
436
+ output: %(
437
+ @prefix ex: <http://example.org/vocab#> .
438
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
439
+ [ex:c14n """{"Unnormalized Unicode":"Å"}"""^^rdf:JSON] .
440
+ )
441
+ },
442
+ }.each do |title, params|
443
+ it title do
444
+ params[:output] = RDF::Graph.new << RDF::Turtle::Reader.new(params[:output])
445
+ run_to_rdf params
446
+ end
447
+ end
448
+ end
449
+ end
450
+
451
+ context "overriding keywords" do
452
+ {
453
+ "'url' for @id, 'a' for @type" => [
454
+ %q(
455
+ "@context":
456
+ url: "@id"
457
+ a: "@type"
458
+ name: http://schema.org/name
459
+ url: http://example.com/about#gregg
460
+ a: http://schema.org/Person
461
+ name: Gregg Kellogg
462
+ ),
463
+ %q(
464
+ <http://example.com/about#gregg> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
465
+ <http://example.com/about#gregg> <http://schema.org/name> "Gregg Kellogg"^^xsd:string .
466
+ )
467
+ ],
468
+ }.each do |title, (js, ttl)|
469
+ it title do
470
+ ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
471
+ expect(parse(js)).to be_equivalent_graph(ttl, logger: logger, inputDocument: js)
472
+ end
473
+ end
474
+ end
475
+
476
+ context "@direction" do
477
+ context "rdfDirection: null" do
478
+ {
479
+ "no language rtl": [
480
+ %q(
481
+ http://example.org/label:
482
+ "@value": no language
483
+ "@direction": rtl
484
+ ),
485
+ %q(_:a <http://example.org/label> "no language" .)
486
+ ],
487
+ "en-US rtl": [
488
+ %q(
489
+ http://example.org/label:
490
+ "@value": en-US
491
+ "@language": en-US
492
+ "@direction": rtl
493
+ ),
494
+ %q(_:a <http://example.org/label> "en-US"@en-us .)
495
+ ]
496
+ }.each do |title, (js, ttl)|
497
+ it title do
498
+ ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
499
+ expect(parse(js, rdfDirection: nil)).to be_equivalent_graph(ttl, logger: logger, inputDocument: js)
500
+ end
501
+ end
502
+ end
503
+
504
+ context "rdfDirection: i18n-datatype" do
505
+ {
506
+ "no language rtl": [
507
+ %q(
508
+ http://example.org/label:
509
+ "@value": no language
510
+ "@direction": rtl
511
+ ),
512
+ %q(_:a <http://example.org/label> "no language"^^<https://www.w3.org/ns/i18n#_rtl> .)
513
+ ],
514
+ "en-US rtl": [
515
+ %q(
516
+ http://example.org/label:
517
+ "@value": en-US
518
+ "@language": en-US
519
+ "@direction": rtl
520
+ ),
521
+ %q(_:a <http://example.org/label> "en-US"^^<https://www.w3.org/ns/i18n#en-us_rtl> .)
522
+ ]
523
+ }.each do |title, (js, ttl)|
524
+ it title do
525
+ ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
526
+ expect(parse(js, rdfDirection: 'i18n-datatype')).to be_equivalent_graph(ttl, logger: logger, inputDocument: js)
527
+ end
528
+ end
529
+ end
530
+ end
531
+ end
532
+
533
+ def parse(input, **options)
534
+ graph = options[:graph] || RDF::Graph.new
535
+ options = {logger: logger, validate: true, canonicalize: false}.merge(options)
536
+ YAML_LD::API.toRdf(StringIO.new(input), rename_bnodes: false, **options) {|st| graph << st}
537
+ graph
538
+ end
539
+
540
+ def run_to_rdf(params)
541
+ input, output = params[:input], params[:output]
542
+ graph = params[:graph] || RDF::Graph.new
543
+ input = StringIO.new(input) if input.is_a?(String)
544
+ pending params.fetch(:pending, "test implementation") unless input
545
+ if params[:exception]
546
+ expect {YAML_LD::API.toRdf(input, **params)}.to raise_error(params[:exception])
547
+ else
548
+ if params[:write]
549
+ expect{YAML_LD::API.toRdf(input, base: params[:base], logger: logger, rename_bnodes: false, **params) {|st| graph << st}}.to write(params[:write]).to(:error)
550
+ else
551
+ expect{YAML_LD::API.toRdf(input, base: params[:base], logger: logger, rename_bnodes: false, **params) {|st| graph << st}}.not_to write.to(:error)
552
+ end
553
+ expect(graph).to be_equivalent_graph(output, logger: logger, inputDocument: input)
554
+ end
555
+ end
556
+ end