json-ld 3.1.4 → 3.1.9

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.
@@ -766,6 +766,187 @@ describe JSON::LD::API do
766
766
  end
767
767
  end
768
768
 
769
+ context "RDF-star" do
770
+ {
771
+ "subject-iii": {
772
+ input: RDF::Statement(
773
+ RDF::Statement(
774
+ RDF::URI('http://example/s1'),
775
+ RDF::URI('http://example/p1'),
776
+ RDF::URI('http://example/o1')),
777
+ RDF::URI('http://example/p'),
778
+ RDF::URI('http://example/o')),
779
+ output: %([{
780
+ "@id": {
781
+ "@id": "http://example/s1",
782
+ "http://example/p1": [{"@id": "http://example/o1"}]
783
+ },
784
+ "http://example/p": [{"@id": "http://example/o"}]
785
+ }])
786
+ },
787
+ "subject-iib": {
788
+ input: RDF::Statement(
789
+ RDF::Statement(
790
+ RDF::URI('http://example/s1'),
791
+ RDF::URI('http://example/p1'),
792
+ RDF::Node.new('o1')),
793
+ RDF::URI('http://example/p'),
794
+ RDF::URI('http://example/o')),
795
+ output: %([{
796
+ "@id": {
797
+ "@id": "http://example/s1",
798
+ "http://example/p1": [{"@id": "_:o1"}]
799
+ },
800
+ "http://example/p": [{"@id": "http://example/o"}]
801
+ }])
802
+ },
803
+ "subject-iil": {
804
+ input: RDF::Statement(
805
+ RDF::Statement(
806
+ RDF::URI('http://example/s1'),
807
+ RDF::URI('http://example/p1'),
808
+ RDF::Literal('o1')),
809
+ RDF::URI('http://example/p'),
810
+ RDF::URI('http://example/o')),
811
+ output: %([{
812
+ "@id": {
813
+ "@id": "http://example/s1",
814
+ "http://example/p1": [{"@value": "o1"}]
815
+ },
816
+ "http://example/p": [{"@id": "http://example/o"}]
817
+ }])
818
+ },
819
+ "subject-bii": {
820
+ input: RDF::Statement(
821
+ RDF::Statement(
822
+ RDF::Node('s1'),
823
+ RDF::URI('http://example/p1'),
824
+ RDF::URI('http://example/o1')),
825
+ RDF::URI('http://example/p'),
826
+ RDF::URI('http://example/o')),
827
+ output: %([{
828
+ "@id": {
829
+ "@id": "_:s1",
830
+ "http://example/p1": [{"@id": "http://example/o1"}]
831
+ },
832
+ "http://example/p": [{"@id": "http://example/o"}]
833
+ }])
834
+ },
835
+ "subject-bib": {
836
+ input: RDF::Statement(
837
+ RDF::Statement(
838
+ RDF::Node('s1'),
839
+ RDF::URI('http://example/p1'),
840
+ RDF::Node.new('o1')),
841
+ RDF::URI('http://example/p'), RDF::URI('http://example/o')),
842
+ output: %([{
843
+ "@id": {
844
+ "@id": "_:s1",
845
+ "http://example/p1": [{"@id": "_:o1"}]
846
+ },
847
+ "http://example/p": [{"@id": "http://example/o"}]
848
+ }])
849
+ },
850
+ "subject-bil": {
851
+ input: RDF::Statement(
852
+ RDF::Statement(
853
+ RDF::Node('s1'),
854
+ RDF::URI('http://example/p1'),
855
+ RDF::Literal('o1')),
856
+ RDF::URI('http://example/p'),
857
+ RDF::URI('http://example/o')),
858
+ output: %([{
859
+ "@id": {
860
+ "@id": "_:s1",
861
+ "http://example/p1": [{"@value": "o1"}]
862
+ },
863
+ "http://example/p": [{"@id": "http://example/o"}]
864
+ }])
865
+ },
866
+ "object-iii": {
867
+ input: RDF::Statement(
868
+ RDF::URI('http://example/s'),
869
+ RDF::URI('http://example/p'),
870
+ RDF::Statement(
871
+ RDF::URI('http://example/s1'),
872
+ RDF::URI('http://example/p1'),
873
+ RDF::URI('http://example/o1'))),
874
+ output: %([{
875
+ "@id": "http://example/s",
876
+ "http://example/p": [{
877
+ "@id": {
878
+ "@id": "http://example/s1",
879
+ "http://example/p1": [{"@id": "http://example/o1"}]
880
+ }
881
+ }]
882
+ }])
883
+ },
884
+ "object-iib": {
885
+ input: RDF::Statement(
886
+ RDF::URI('http://example/s'),
887
+ RDF::URI('http://example/p'),
888
+ RDF::Statement(
889
+ RDF::URI('http://example/s1'),
890
+ RDF::URI('http://example/p1'),
891
+ RDF::Node.new('o1'))),
892
+ output: %([{
893
+ "@id": "http://example/s",
894
+ "http://example/p": [{
895
+ "@id": {
896
+ "@id": "http://example/s1",
897
+ "http://example/p1": [{"@id": "_:o1"}]
898
+ }
899
+ }]
900
+ }])
901
+ },
902
+ "object-iil": {
903
+ input: RDF::Statement(
904
+ RDF::URI('http://example/s'),
905
+ RDF::URI('http://example/p'),
906
+ RDF::Statement(
907
+ RDF::URI('http://example/s1'),
908
+ RDF::URI('http://example/p1'),
909
+ RDF::Literal('o1'))),
910
+ output: %([{
911
+ "@id": "http://example/s",
912
+ "http://example/p": [{
913
+ "@id": {
914
+ "@id": "http://example/s1",
915
+ "http://example/p1": [{"@value": "o1"}]
916
+ }
917
+ }]
918
+ }])
919
+ },
920
+ "recursive-subject": {
921
+ input: RDF::Statement(
922
+ RDF::Statement(
923
+ RDF::Statement(
924
+ RDF::URI('http://example/s2'),
925
+ RDF::URI('http://example/p2'),
926
+ RDF::URI('http://example/o2')),
927
+ RDF::URI('http://example/p1'),
928
+ RDF::URI('http://example/o1')),
929
+ RDF::URI('http://example/p'),
930
+ RDF::URI('http://example/o')),
931
+ output: %([{
932
+ "@id": {
933
+ "@id": {
934
+ "@id": "http://example/s2",
935
+ "http://example/p2": [{"@id": "http://example/o2"}]
936
+ },
937
+ "http://example/p1": [{"@id": "http://example/o1"}]
938
+ },
939
+ "http://example/p": [{"@id": "http://example/o"}]
940
+ }])
941
+ },
942
+ }.each do |name, params|
943
+ it name do
944
+ graph = RDF::Graph.new {|g| g << params[:input]}
945
+ do_fromRdf(params.merge(input: graph, prefixes: {ex: 'http://example/'}))
946
+ end
947
+ end
948
+ end
949
+
769
950
  context "problems" do
770
951
  {
771
952
  "xsd:boolean as value" => {
data/spec/matchers.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'rspec/matchers' # @see http://rubygems.org/gems/rspec
1
+ require 'rspec/matchers' # @see https://rubygems.org/gems/rspec
2
2
  require_relative 'support/extensions'
3
3
 
4
4
  RSpec::Matchers.define :produce_jsonld do |expected, logger|
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ require_relative 'spec_helper'
3
+
4
+ describe JSON::LD do
5
+ describe "test suite" do
6
+ require_relative 'suite_helper'
7
+ %w{
8
+ expand
9
+ compact
10
+ flatten
11
+ fromRdf
12
+ toRdf
13
+ }.each do |partial|
14
+ m = Fixtures::SuiteTest::Manifest.open("#{Fixtures::SuiteTest::STAR_SUITE}#{partial}-manifest.jsonld")
15
+ describe m.name do
16
+ m.entries.each do |t|
17
+ specify "#{t.property('@id')}: #{t.name}#{' (negative test)' unless t.positiveTest?}" do
18
+ t.options[:ordered] = false
19
+ expect {t.run self}.not_to write.to(:error)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end unless ENV['CI']
data/spec/spec_helper.rb CHANGED
@@ -67,6 +67,38 @@ def detect_format(stream)
67
67
  end
68
68
  end
69
69
 
70
+ # Creates a bijection between the two objects and replaces nodes in actual from expected.
71
+ def remap_bnodes(actual, expected)
72
+ # Transform each to RDF and perform a blank node bijection.
73
+ # Replace the blank nodes in action with the mapping from bijection.
74
+ ds_actual = RDF::Repository.new << JSON::LD::API.toRdf(actual, rdfstar: true, rename_bnodes: false)
75
+ ds_expected = RDF::Repository.new << JSON::LD::API.toRdf(expected, rdfstar: true, rename_bnodes: false)
76
+ if bijection = ds_actual.bijection_to(ds_expected)
77
+ bijection = bijection.inject({}) {|memo, (k, v)| memo.merge(k.to_s => v.to_s)}
78
+
79
+ # Recursively replace blank nodes in actual with the bijection
80
+ replace_nodes(actual, bijection)
81
+ else
82
+ actual
83
+ end
84
+ end
85
+
86
+ def replace_nodes(object, bijection)
87
+ case object
88
+ when Array
89
+ object.map {|o| replace_nodes(o, bijection)}
90
+ when Hash
91
+ object.inject({}) do |memo, (k, v)|
92
+ memo.merge(bijection.fetch(k, k) => replace_nodes(v, bijection))
93
+ end
94
+ when String
95
+ bijection.fetch(object, object)
96
+ else
97
+ object
98
+ end
99
+ end
100
+
101
+
70
102
  LIBRARY_INPUT = JSON.parse(%([
71
103
  {
72
104
  "@id": "http://example.org/library",
@@ -7,6 +7,8 @@ describe JSON::LD do
7
7
  m = Fixtures::SuiteTest::Manifest.open("#{Fixtures::SuiteTest::SUITE}flatten-manifest.jsonld")
8
8
  describe m.name do
9
9
  m.entries.each do |t|
10
+ t.options[:remap_bnodes] = %w(#t0045).include?(t.property('@id'))
11
+
10
12
  specify "#{t.property('@id')}: #{t.name} unordered#{' (negative test)' unless t.positiveTest?}" do
11
13
  t.options[:ordered] = false
12
14
  if %w(#t0005).include?(t.property('@id'))
@@ -16,6 +18,8 @@ describe JSON::LD do
16
18
  end
17
19
  end
18
20
 
21
+ # Skip ordered tests when remapping bnodes
22
+ next if t.options[:remap_bnodes]
19
23
  specify "#{t.property('@id')}: #{t.name} ordered#{' (negative test)' unless t.positiveTest?}" do
20
24
  t.options[:ordered] = true
21
25
  if %w(#t0005).include?(t.property('@id'))
@@ -7,13 +7,20 @@ describe JSON::LD do
7
7
  m = Fixtures::SuiteTest::Manifest.open("#{Fixtures::SuiteTest::FRAME_SUITE}frame-manifest.jsonld")
8
8
  describe m.name do
9
9
  m.entries.each do |t|
10
+ t.options[:remap_bnodes] = %w(#t0021 #tp021).include?(t.property('@id'))
11
+
10
12
  specify "#{t.property('@id')}: #{t.name} unordered#{' (negative test)' unless t.positiveTest?}" do
11
13
  t.options[:ordered] = false
12
14
  expect {t.run self}.not_to write.to(:error)
13
15
  end
14
16
 
17
+ # Skip ordered tests when remapping bnodes
18
+ next if t.options[:remap_bnodes]
15
19
  specify "#{t.property('@id')}: #{t.name} ordered#{' (negative test)' unless t.positiveTest?}" do
16
20
  t.options[:ordered] = true
21
+ if %w(#tp021).include?(t.property('@id'))
22
+ pending("changes due to blank node reordering")
23
+ end
17
24
  expect {t.run self}.not_to write.to(:error)
18
25
  end
19
26
  end
data/spec/suite_helper.rb CHANGED
@@ -7,6 +7,7 @@ module RDF::Util
7
7
  "https://w3c.github.io/json-ld-api/tests/" => ::File.expand_path("../json-ld-api/tests", __FILE__) + '/',
8
8
  "https://w3c.github.io/json-ld-framing/tests/" => ::File.expand_path("../json-ld-framing/tests", __FILE__) + '/',
9
9
  "https://w3c.github.io/json-ld-streaming/tests/" => ::File.expand_path("../json-ld-streaming/tests", __FILE__) + '/',
10
+ "https://json-ld.github.io/json-ld-star/tests/" => ::File.expand_path("../json-ld-star/tests", __FILE__) + '/',
10
11
  "file:" => ""
11
12
  }
12
13
 
@@ -76,6 +77,7 @@ module Fixtures
76
77
  SUITE = RDF::URI("https://w3c.github.io/json-ld-api/tests/")
77
78
  FRAME_SUITE = RDF::URI("https://w3c.github.io/json-ld-framing/tests/")
78
79
  STREAM_SUITE = RDF::URI("https://w3c.github.io/json-ld-streaming/tests/")
80
+ STAR_SUITE = RDF::URI("https://json-ld.github.io/json-ld-star/tests/")
79
81
 
80
82
  class Manifest < JSON::LD::Resource
81
83
  attr_accessor :manifest_url
@@ -201,8 +203,8 @@ module Fixtures
201
203
  logger.info "frame: #{frame}" if frame_loc
202
204
 
203
205
  options = self.options
204
- unless options[:specVersion] == "json-ld-1.1"
205
- skip "not a 1.1 test"
206
+ if options[:specVersion] == "json-ld-1.0"
207
+ skip "1.0 test"
206
208
  return
207
209
  end
208
210
 
@@ -223,7 +225,7 @@ module Fixtures
223
225
  JSON::LD::API.frame(input_loc, frame_loc, logger: logger, **options)
224
226
  when "jld:FromRDFTest"
225
227
  # Use an array, to preserve input order
226
- repo = RDF::NQuads::Reader.open(input_loc) do |reader|
228
+ repo = RDF::NQuads::Reader.open(input_loc, rdfstar: options[:rdfstar]) do |reader|
227
229
  reader.each_statement.to_a
228
230
  end.to_a.uniq.extend(RDF::Enumerable)
229
231
  logger.info "repo: #{repo.dump(self.id == '#t0012' ? :nquads : :trig)}"
@@ -235,7 +237,7 @@ module Fixtures
235
237
  repo << statement
236
238
  end
237
239
  else
238
- JSON::LD::API.toRdf(input_loc, logger: logger, **options) do |statement|
240
+ JSON::LD::API.toRdf(input_loc, rename_bnodes: false, logger: logger, **options) do |statement|
239
241
  repo << statement
240
242
  end
241
243
  end
@@ -256,12 +258,16 @@ module Fixtures
256
258
  end
257
259
  if evaluationTest?
258
260
  if testType == "jld:ToRDFTest"
259
- expected = RDF::Repository.new << RDF::NQuads::Reader.new(expect, logger: [])
261
+ expected = RDF::Repository.new << RDF::NQuads::Reader.new(expect, rdfstar: options[:rdfstar], logger: [])
260
262
  rspec_example.instance_eval {
261
263
  expect(result).to be_equivalent_graph(expected, logger)
262
264
  }
263
265
  else
264
266
  expected = JSON.load(expect)
267
+
268
+ # If called for, remap bnodes
269
+ result = remap_bnodes(result, expected) if options[:remap_bnodes]
270
+
265
271
  if options[:ordered]
266
272
  # Compare without transformation
267
273
  rspec_example.instance_eval {
@@ -308,7 +314,7 @@ module Fixtures
308
314
  when "jld:FrameTest"
309
315
  JSON::LD::API.frame(t.input_loc, t.frame_loc, logger: logger, **options)
310
316
  when "jld:FromRDFTest"
311
- repo = RDF::Repository.load(t.input_loc)
317
+ repo = RDF::Repository.load(t.input_loc, rdfstar: options[:rdfstar])
312
318
  logger.info "repo: #{repo.dump(t.id == '#t0012' ? :nquads : :trig)}"
313
319
  JSON::LD::API.fromRdf(repo, logger: logger, **options)
314
320
  when "jld:HttpTest"
@@ -325,7 +331,7 @@ module Fixtures
325
331
  if t.manifest_url.to_s.include?('stream')
326
332
  JSON::LD::Reader.open(t.input_loc, stream: true, logger: logger, **options).each_statement {}
327
333
  else
328
- JSON::LD::API.toRdf(t.input_loc, logger: logger, **options) {}
334
+ JSON::LD::API.toRdf(t.input_loc, rename_bnodes: false, logger: logger, **options) {}
329
335
  end
330
336
  else
331
337
  success("Unknown test type: #{testType}")
@@ -9,6 +9,7 @@ describe JSON::LD do
9
9
  m.entries.each do |t|
10
10
  specify "#{t.property('@id')}: #{t.name}#{' (negative test)' unless t.positiveTest?}" do
11
11
  pending "Generalized RDF" if t.options[:produceGeneralizedRdf]
12
+ pending "RDF-star" if t.property('@id') == '#te122'
12
13
  if %w(#t0118).include?(t.property('@id'))
13
14
  expect {t.run self}.to write(/Statement .* is invalid/).to(:error)
14
15
  elsif %w(#te075).include?(t.property('@id'))
data/spec/to_rdf_spec.rb CHANGED
@@ -1175,6 +1175,212 @@ describe JSON::LD::API do
1175
1175
  end
1176
1176
  end
1177
1177
 
1178
+ context "JSON-LD-star" do
1179
+ {
1180
+ "node with embedded subject without rdfstar option": {
1181
+ input: %({
1182
+ "@id": {
1183
+ "@id": "ex:rei",
1184
+ "ex:prop": "value"
1185
+ },
1186
+ "ex:prop": "value2"
1187
+ }),
1188
+ exception: JSON::LD::JsonLdError::InvalidIdValue
1189
+ },
1190
+ }.each do |title, params|
1191
+ it(title) {run_to_rdf params}
1192
+ end
1193
+
1194
+ {
1195
+ "node with embedded subject having no @id": {
1196
+ input: %({
1197
+ "@id": {
1198
+ "ex:prop": "value"
1199
+ },
1200
+ "ex:prop": "value2"
1201
+ }),
1202
+ expected: %(
1203
+ <<_:b0 <ex:prop> "value">> <ex:prop> "value2" .
1204
+ ),
1205
+ },
1206
+ "node with embedded subject having IRI @id": {
1207
+ input: %({
1208
+ "@id": {
1209
+ "@id": "ex:rei",
1210
+ "ex:prop": "value"
1211
+ },
1212
+ "ex:prop": "value2"
1213
+ }),
1214
+ expected: %(
1215
+ <<<ex:rei> <ex:prop> "value">> <ex:prop> "value2" .
1216
+ ),
1217
+ },
1218
+ "node with embedded subject having BNode @id": {
1219
+ input: %({
1220
+ "@id": {
1221
+ "@id": "_:rei",
1222
+ "ex:prop": "value"
1223
+ },
1224
+ "ex:prop": "value2"
1225
+ }),
1226
+ expected: %(
1227
+ <<_:b0 <ex:prop> "value">> <ex:prop> "value2" .
1228
+ ),
1229
+ },
1230
+ "node with embedded subject having a type": {
1231
+ input: %({
1232
+ "@id": {
1233
+ "@id": "ex:rei",
1234
+ "@type": "ex:Type"
1235
+ },
1236
+ "ex:prop": "value2"
1237
+ }),
1238
+ expected: %(
1239
+ <<<ex:rei> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <ex:Type>>> <ex:prop> "value2" .
1240
+ ),
1241
+ },
1242
+ "node with embedded subject having an IRI value": {
1243
+ input: %({
1244
+ "@id": {
1245
+ "@id": "ex:rei",
1246
+ "ex:prop": {"@id": "ex:value"}
1247
+ },
1248
+ "ex:prop": "value2"
1249
+ }),
1250
+ expected: %(
1251
+ <<<ex:rei> <ex:prop> <ex:value>>> <ex:prop> "value2" .
1252
+ ),
1253
+ },
1254
+ "node with embedded subject having an BNode value": {
1255
+ input: %({
1256
+ "@id": {
1257
+ "@id": "ex:rei",
1258
+ "ex:prop": {"@id": "_:value"}
1259
+ },
1260
+ "ex:prop": "value2"
1261
+ }),
1262
+ expected: %(
1263
+ <<<ex:rei> <ex:prop> _:b0>> <ex:prop> "value2" .
1264
+ ),
1265
+ },
1266
+ "node with recursive embedded subject": {
1267
+ input: %({
1268
+ "@id": {
1269
+ "@id": {
1270
+ "@id": "ex:rei",
1271
+ "ex:prop": "value3"
1272
+ },
1273
+ "ex:prop": "value"
1274
+ },
1275
+ "ex:prop": "value2"
1276
+ }),
1277
+ expected: %(
1278
+ <<<<<ex:rei> <ex:prop> "value3">> <ex:prop> "value">> <ex:prop> "value2" .
1279
+ ),
1280
+ },
1281
+ "illegal node with subject having no property": {
1282
+ input: %({
1283
+ "@id": {
1284
+ "@id": "ex:rei"
1285
+ },
1286
+ "ex:prop": "value3"
1287
+ }),
1288
+ exception: JSON::LD::JsonLdError::InvalidEmbeddedNode
1289
+ },
1290
+ "illegal node with subject having multiple properties": {
1291
+ input: %({
1292
+ "@id": {
1293
+ "@id": "ex:rei",
1294
+ "ex:prop": ["value1", "value2"]
1295
+ },
1296
+ "ex:prop": "value3"
1297
+ }),
1298
+ exception: JSON::LD::JsonLdError::InvalidEmbeddedNode
1299
+ },
1300
+ "illegal node with subject having multiple types": {
1301
+ input: %({
1302
+ "@id": {
1303
+ "@id": "ex:rei",
1304
+ "@type": ["ex:Type1", "ex:Type2"]
1305
+ },
1306
+ "ex:prop": "value3"
1307
+ }),
1308
+ exception: JSON::LD::JsonLdError::InvalidEmbeddedNode
1309
+ },
1310
+ "illegal node with subject having type and property": {
1311
+ input: %({
1312
+ "@id": {
1313
+ "@id": "ex:rei",
1314
+ "@type": "ex:Type",
1315
+ "ex:prop": "value"
1316
+ },
1317
+ "ex:prop": "value2"
1318
+ }),
1319
+ exception: JSON::LD::JsonLdError::InvalidEmbeddedNode
1320
+ },
1321
+ "node with embedded object": {
1322
+ input: %({
1323
+ "@id": "ex:subj",
1324
+ "ex:value": {
1325
+ "@id": {
1326
+ "@id": "ex:rei",
1327
+ "ex:prop": "value"
1328
+ }
1329
+ }
1330
+ }),
1331
+ expected: %(
1332
+ <ex:subj> <ex:value> <<<ex:rei> <ex:prop> "value">> .
1333
+ ),
1334
+ },
1335
+ "node with embedded object having properties": {
1336
+ input: %({
1337
+ "@id": "ex:subj",
1338
+ "ex:value": {
1339
+ "@id": {
1340
+ "@id": "ex:rei",
1341
+ "ex:prop": "value"
1342
+ },
1343
+ "ex:prop": "value2"
1344
+ }
1345
+ }),
1346
+ expected: %(
1347
+ <ex:subj> <ex:value> <<<ex:rei> <ex:prop> "value">> .
1348
+ <<<ex:rei> <ex:prop> "value">> <ex:prop> "value2" .
1349
+ ),
1350
+ },
1351
+ "node with recursive embedded object": {
1352
+ input: %({
1353
+ "@id": "ex:subj",
1354
+ "ex:value": {
1355
+ "@id": {
1356
+ "@id": {
1357
+ "@id": "ex:rei",
1358
+ "ex:prop": "value3"
1359
+ },
1360
+ "ex:prop": "value"
1361
+ },
1362
+ "ex:prop": "value2"
1363
+ }
1364
+ }),
1365
+ expected: %(
1366
+ <ex:subj> <ex:value> <<<<<ex:rei> <ex:prop> "value3">> <ex:prop> "value">> .
1367
+ <<<<<ex:rei> <ex:prop> "value3">> <ex:prop> "value">> <ex:prop> "value2" .
1368
+ ),
1369
+ },
1370
+ }.each do |title, params|
1371
+ context(title) do
1372
+ it "Generates statements" do
1373
+ output_graph = RDF::Graph.new {|g| g << RDF::NTriples::Reader.new(params[:expected], rdfstar: true)}
1374
+ run_to_rdf params.merge(rdfstar: true, output: output_graph)
1375
+ end if params[:expected]
1376
+
1377
+ it "Exception" do
1378
+ run_to_rdf params.merge(rdfstar: true)
1379
+ end if params[:exception]
1380
+ end
1381
+ end
1382
+ end
1383
+
1178
1384
  context "exceptions" do
1179
1385
  {
1180
1386
  "Invalid subject" => {
@@ -1322,7 +1528,7 @@ describe JSON::LD::API do
1322
1528
  def parse(input, **options)
1323
1529
  graph = options[:graph] || RDF::Graph.new
1324
1530
  options = {logger: logger, validate: true, canonicalize: false}.merge(options)
1325
- JSON::LD::API.toRdf(StringIO.new(input), **options) {|st| graph << st}
1531
+ JSON::LD::API.toRdf(StringIO.new(input), rename_bnodes: false, **options) {|st| graph << st}
1326
1532
  graph
1327
1533
  end
1328
1534
 
@@ -1335,9 +1541,9 @@ describe JSON::LD::API do
1335
1541
  expect {JSON::LD::API.toRdf(input, **params)}.to raise_error(params[:exception])
1336
1542
  else
1337
1543
  if params[:write]
1338
- expect{JSON::LD::API.toRdf(input, base: params[:base], logger: logger, **params) {|st| graph << st}}.to write(params[:write]).to(:error)
1544
+ expect{JSON::LD::API.toRdf(input, base: params[:base], logger: logger, rename_bnodes: false, **params) {|st| graph << st}}.to write(params[:write]).to(:error)
1339
1545
  else
1340
- expect{JSON::LD::API.toRdf(input, base: params[:base], logger: logger, **params) {|st| graph << st}}.not_to write.to(:error)
1546
+ expect{JSON::LD::API.toRdf(input, base: params[:base], logger: logger, rename_bnodes: false, **params) {|st| graph << st}}.not_to write.to(:error)
1341
1547
  end
1342
1548
  expect(graph).to be_equivalent_graph(output, logger: logger, inputDocument: input)
1343
1549
  end