json-ld 1.1.7 → 1.1.8
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.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/VERSION +1 -1
- data/bin/jsonld +42 -23
- data/lib/json/ld.rb +6 -6
- data/lib/json/ld/api.rb +68 -93
- data/lib/json/ld/compact.rb +15 -15
- data/lib/json/ld/context.rb +47 -22
- data/lib/json/ld/expand.rb +7 -7
- data/lib/json/ld/extensions.rb +2 -2
- data/lib/json/ld/flatten.rb +1 -1
- data/lib/json/ld/format.rb +5 -5
- data/lib/json/ld/frame.rb +5 -5
- data/lib/json/ld/from_rdf.rb +2 -2
- data/lib/json/ld/reader.rb +0 -2
- data/lib/json/ld/resource.rb +4 -4
- data/lib/json/ld/streaming_writer.rb +123 -0
- data/lib/json/ld/to_rdf.rb +6 -6
- data/lib/json/ld/writer.rb +29 -6
- data/spec/api_spec.rb +57 -4
- data/spec/compact_spec.rb +92 -92
- data/spec/context_spec.rb +43 -23
- data/spec/expand_spec.rb +142 -142
- data/spec/flatten_spec.rb +17 -17
- data/spec/format_spec.rb +17 -17
- data/spec/frame_spec.rb +47 -47
- data/spec/from_rdf_spec.rb +25 -25
- data/spec/matchers.rb +9 -9
- data/spec/reader_spec.rb +4 -4
- data/spec/resource_spec.rb +1 -1
- data/spec/spec_helper.rb +14 -9
- data/spec/streaming_writer_spec.rb +142 -0
- data/spec/suite_helper.rb +29 -88
- data/spec/to_rdf_spec.rb +17 -17
- data/spec/writer_spec.rb +43 -20
- metadata +40 -15
data/spec/context_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe JSON::LD::Context do
|
|
26
26
|
before(:each) {
|
27
27
|
@debug = []
|
28
28
|
}
|
29
|
-
let(:context) {JSON::LD::Context.new(:
|
29
|
+
let(:context) {JSON::LD::Context.new(debug: @debug, validate: true)}
|
30
30
|
let(:remote_doc) do
|
31
31
|
JSON::LD::API::RemoteDocument.new("http://example.com/context", %q({
|
32
32
|
"@context": {
|
@@ -43,18 +43,18 @@ describe JSON::LD::Context do
|
|
43
43
|
context "remote" do
|
44
44
|
|
45
45
|
it "retrieves and parses a remote context document" do
|
46
|
-
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context").and_yield(remote_doc)
|
46
|
+
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
47
47
|
ec = subject.parse("http://example.com/context")
|
48
48
|
expect(ec.provided_context).to produce("http://example.com/context", @debug)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "fails given a missing remote @context" do
|
52
|
-
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context").and_raise(IOError)
|
52
|
+
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_raise(IOError)
|
53
53
|
expect {subject.parse("http://example.com/context")}.to raise_error(JSON::LD::JsonLdError::LoadingRemoteContextFailed, %r{http://example.com/context})
|
54
54
|
end
|
55
55
|
|
56
56
|
it "creates mappings" do
|
57
|
-
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context").and_yield(remote_doc)
|
57
|
+
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
58
58
|
ec = subject.parse("http://example.com/context")
|
59
59
|
expect(ec.send(:mappings)).to produce({
|
60
60
|
"xsd" => "http://www.w3.org/2001/XMLSchema#",
|
@@ -70,8 +70,8 @@ describe JSON::LD::Context do
|
|
70
70
|
|
71
71
|
it "parses a referenced context at a relative URI" do
|
72
72
|
rd1 = JSON::LD::API::RemoteDocument.new("http://example.com/c1", %({"@context": "context"}))
|
73
|
-
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/c1").and_yield(rd1)
|
74
|
-
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context").and_yield(remote_doc)
|
73
|
+
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/c1", anything).and_yield(rd1)
|
74
|
+
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
75
75
|
ec = subject.parse("http://example.com/c1")
|
76
76
|
expect(ec.send(:mappings)).to produce({
|
77
77
|
"xsd" => "http://www.w3.org/2001/XMLSchema#",
|
@@ -84,12 +84,12 @@ describe JSON::LD::Context do
|
|
84
84
|
context "remote with local mappings" do
|
85
85
|
let(:ctx) {["http://example.com/context", {"integer" => "xsd:integer"}]}
|
86
86
|
it "retrieves and parses a remote context document" do
|
87
|
-
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context").and_yield(remote_doc)
|
87
|
+
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
88
88
|
ec = subject.parse(ctx)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "does not use passed context as provided_context" do
|
92
|
-
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context").and_yield(remote_doc)
|
92
|
+
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
93
93
|
ec = subject.parse(ctx)
|
94
94
|
expect(ec.provided_context).to produce(ctx, @debug)
|
95
95
|
end
|
@@ -295,9 +295,29 @@ describe JSON::LD::Context do
|
|
295
295
|
end
|
296
296
|
end
|
297
297
|
|
298
|
+
describe "#merge" do
|
299
|
+
it "creates a new context with components of each" do
|
300
|
+
c2 = JSON::LD::Context.new().parse({'foo' => "http://example.com/"})
|
301
|
+
cm = context.merge(c2)
|
302
|
+
expect(cm).not_to equal context
|
303
|
+
expect(cm).not_to equal c2
|
304
|
+
expect(cm.term_definitions).to eq c2.term_definitions
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
describe "#merge!" do
|
309
|
+
it "updates context with components from new" do
|
310
|
+
c2 = JSON::LD::Context.new().parse({'foo' => "http://example.com/"})
|
311
|
+
cm = context.merge!(c2)
|
312
|
+
expect(cm).to equal context
|
313
|
+
expect(cm).not_to equal c2
|
314
|
+
expect(cm.term_definitions).to eq c2.term_definitions
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
298
318
|
describe "#serialize" do
|
299
319
|
it "context document" do
|
300
|
-
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context").and_yield(remote_doc)
|
320
|
+
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
301
321
|
ec = subject.parse("http://example.com/context")
|
302
322
|
expect(ec.serialize).to produce({
|
303
323
|
"@context" => "http://example.com/context"
|
@@ -570,8 +590,8 @@ describe JSON::LD::Context do
|
|
570
590
|
context "extra keys or values" do
|
571
591
|
{
|
572
592
|
"extra key" => {
|
573
|
-
:
|
574
|
-
:
|
593
|
+
input: {"foo" => {"@id" => "http://example.com/foo", "@baz" => "foobar"}},
|
594
|
+
result: {"@context" => {"foo" => {"@id" => "http://example.com/foo", "@baz" => "foobar"}}}
|
575
595
|
}
|
576
596
|
}.each do |title, params|
|
577
597
|
it title do
|
@@ -602,7 +622,7 @@ describe JSON::LD::Context do
|
|
602
622
|
%w(id type).each do |kw|
|
603
623
|
it "expands #{kw} to @#{kw}" do
|
604
624
|
subject.set_mapping(kw, "@#{kw}")
|
605
|
-
expect(subject.expand_iri(kw, :
|
625
|
+
expect(subject.expand_iri(kw, vocab: true)).to produce("@#{kw}", @debug)
|
606
626
|
end
|
607
627
|
end
|
608
628
|
end
|
@@ -645,7 +665,7 @@ describe JSON::LD::Context do
|
|
645
665
|
"_" => ["_", RDF::URI("http://base/_")],
|
646
666
|
}.each do |title, (input, result)|
|
647
667
|
it title do
|
648
|
-
expect(subject.expand_iri(input, :
|
668
|
+
expect(subject.expand_iri(input, documentRelative: true)).to produce(result, @debug)
|
649
669
|
end
|
650
670
|
end
|
651
671
|
end
|
@@ -666,7 +686,7 @@ describe JSON::LD::Context do
|
|
666
686
|
"_" => ["_", RDF::URI("http://underscore/")],
|
667
687
|
}.each do |title, (input, result)|
|
668
688
|
it title do
|
669
|
-
expect(subject.expand_iri(input, :
|
689
|
+
expect(subject.expand_iri(input, vocab: true)).to produce(result, @debug)
|
670
690
|
end
|
671
691
|
end
|
672
692
|
end
|
@@ -719,7 +739,7 @@ describe JSON::LD::Context do
|
|
719
739
|
"odd CURIE" => ["experts", "http://example.org/perts"]
|
720
740
|
}.each do |title, (result, input)|
|
721
741
|
it title do
|
722
|
-
expect(subject.compact_iri(input, :
|
742
|
+
expect(subject.compact_iri(input, vocab: true)).to produce(result, @debug)
|
723
743
|
end
|
724
744
|
end
|
725
745
|
end
|
@@ -738,14 +758,14 @@ describe JSON::LD::Context do
|
|
738
758
|
"odd CURIE" => ["experts", "http://example.org/perts"]
|
739
759
|
}.each do |title, (result, input)|
|
740
760
|
it title do
|
741
|
-
expect(subject.compact_iri(input, :
|
761
|
+
expect(subject.compact_iri(input, vocab: true)).to produce(result, @debug)
|
742
762
|
end
|
743
763
|
end
|
744
764
|
|
745
765
|
it "does not use @vocab if it would collide with a term" do
|
746
766
|
subject.set_mapping("name", "http://xmlns.com/foaf/0.1/name")
|
747
767
|
subject.set_mapping("ex", nil)
|
748
|
-
expect(subject.compact_iri("http://example.org/name", :
|
768
|
+
expect(subject.compact_iri("http://example.org/name", position: :predicate)).
|
749
769
|
to produce("lex:name", @debug)
|
750
770
|
end
|
751
771
|
end
|
@@ -789,7 +809,7 @@ describe JSON::LD::Context do
|
|
789
809
|
context "uses #{prop}" do
|
790
810
|
values.each do |value|
|
791
811
|
it "for #{value.inspect}" do
|
792
|
-
expect(ctx.compact_iri("http://example.com/#{prop.sub('set', '')}", :
|
812
|
+
expect(ctx.compact_iri("http://example.com/#{prop.sub('set', '')}", value: value, vocab: true)).
|
793
813
|
to produce(prop, @debug)
|
794
814
|
end
|
795
815
|
end
|
@@ -818,7 +838,7 @@ describe JSON::LD::Context do
|
|
818
838
|
context "uses #{prop}" do
|
819
839
|
values.each do |value|
|
820
840
|
it "for #{{"@list" => value}.inspect}" do
|
821
|
-
expect(ctx.compact_iri("http://example.com/#{prop.sub('list', '')}", :
|
841
|
+
expect(ctx.compact_iri("http://example.com/#{prop.sub('list', '')}", value: {"@list" => value}, vocab: true)).
|
822
842
|
to produce(prop, @debug)
|
823
843
|
end
|
824
844
|
end
|
@@ -861,7 +881,7 @@ describe JSON::LD::Context do
|
|
861
881
|
"odd CURIE" => ["experts", "http://example.org/perts"]
|
862
882
|
}.each do |title, (result, input)|
|
863
883
|
it title do
|
864
|
-
expect(subject.compact_iri(input, :
|
884
|
+
expect(subject.compact_iri(input, vocab: true)).to produce(result, @debug)
|
865
885
|
end
|
866
886
|
end
|
867
887
|
end
|
@@ -966,7 +986,7 @@ describe JSON::LD::Context do
|
|
966
986
|
}.each do |term, value|
|
967
987
|
[value].flatten.each do |v|
|
968
988
|
it "Uses #{term} for #{v}" do
|
969
|
-
expect(ctx.compact_iri("http://example.com/term", :
|
989
|
+
expect(ctx.compact_iri("http://example.com/term", value: JSON.parse(v), vocab: true)).
|
970
990
|
to produce(term, @debug)
|
971
991
|
end
|
972
992
|
end
|
@@ -981,7 +1001,7 @@ describe JSON::LD::Context do
|
|
981
1001
|
})
|
982
1002
|
end
|
983
1003
|
it "Compact @id that is a property IRI when @container is @list" do
|
984
|
-
expect(ctx.compact_iri("http://example.org/ns#property", :
|
1004
|
+
expect(ctx.compact_iri("http://example.org/ns#property", position: :subject)).
|
985
1005
|
to produce("ex:property", @debug)
|
986
1006
|
end
|
987
1007
|
end
|
@@ -991,7 +1011,7 @@ describe JSON::LD::Context do
|
|
991
1011
|
subject.parse({"name" => {"@id" => "http://example.com/property", "@container" => "@list"}})
|
992
1012
|
end
|
993
1013
|
it "Does not use @list with @index" do
|
994
|
-
expect(ctx.compact_iri("http://example.com/property", :
|
1014
|
+
expect(ctx.compact_iri("http://example.com/property", value: {
|
995
1015
|
"@list" => ["one item"],
|
996
1016
|
"@index" => "an annotation"
|
997
1017
|
})).to produce("http://example.com/property", @debug)
|
data/spec/expand_spec.rb
CHANGED
@@ -8,66 +8,66 @@ describe JSON::LD::API do
|
|
8
8
|
describe ".expand" do
|
9
9
|
{
|
10
10
|
"empty doc" => {
|
11
|
-
:
|
12
|
-
:
|
11
|
+
input: {},
|
12
|
+
output: []
|
13
13
|
},
|
14
14
|
"@list coercion" => {
|
15
|
-
:
|
15
|
+
input: {
|
16
16
|
"@context" => {
|
17
17
|
"foo" => {"@id" => "http://example.com/foo", "@container" => "@list"}
|
18
18
|
},
|
19
19
|
"foo" => [{"@value" => "bar"}]
|
20
20
|
},
|
21
|
-
:
|
21
|
+
output: [{
|
22
22
|
"http://example.com/foo" => [{"@list" => [{"@value" => "bar"}]}]
|
23
23
|
}]
|
24
24
|
},
|
25
25
|
"native values in list" => {
|
26
|
-
:
|
26
|
+
input: {
|
27
27
|
"http://example.com/foo" => {"@list" => [1, 2]}
|
28
28
|
},
|
29
|
-
:
|
29
|
+
output: [{
|
30
30
|
"http://example.com/foo" => [{"@list" => [{"@value" => 1}, {"@value" => 2}]}]
|
31
31
|
}]
|
32
32
|
},
|
33
33
|
"@graph" => {
|
34
|
-
:
|
34
|
+
input: {
|
35
35
|
"@context" => {"ex" => "http://example.com/"},
|
36
36
|
"@graph" => [
|
37
37
|
{"ex:foo" => {"@value" => "foo"}},
|
38
38
|
{"ex:bar" => {"@value" => "bar"}}
|
39
39
|
]
|
40
40
|
},
|
41
|
-
:
|
41
|
+
output: [
|
42
42
|
{"http://example.com/foo" => [{"@value" => "foo"}]},
|
43
43
|
{"http://example.com/bar" => [{"@value" => "bar"}]}
|
44
44
|
]
|
45
45
|
},
|
46
46
|
"@type with CURIE" => {
|
47
|
-
:
|
47
|
+
input: {
|
48
48
|
"@context" => {"ex" => "http://example.com/"},
|
49
49
|
"@type" => "ex:type"
|
50
50
|
},
|
51
|
-
:
|
51
|
+
output: [
|
52
52
|
{"@type" => ["http://example.com/type"]}
|
53
53
|
]
|
54
54
|
},
|
55
55
|
"@type with CURIE and muliple values" => {
|
56
|
-
:
|
56
|
+
input: {
|
57
57
|
"@context" => {"ex" => "http://example.com/"},
|
58
58
|
"@type" => ["ex:type1", "ex:type2"]
|
59
59
|
},
|
60
|
-
:
|
60
|
+
output: [
|
61
61
|
{"@type" => ["http://example.com/type1", "http://example.com/type2"]}
|
62
62
|
]
|
63
63
|
},
|
64
64
|
"@value with false" => {
|
65
|
-
:
|
66
|
-
:
|
65
|
+
input: {"http://example.com/ex" => {"@value" => false}},
|
66
|
+
output: [{"http://example.com/ex" => [{"@value" => false}]}]
|
67
67
|
}
|
68
68
|
}.each_pair do |title, params|
|
69
69
|
it title do
|
70
|
-
jld = JSON::LD::API.expand(params[:input], :
|
70
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug)
|
71
71
|
expect(jld).to produce(params[:output], @debug)
|
72
72
|
end
|
73
73
|
end
|
@@ -75,46 +75,46 @@ describe JSON::LD::API do
|
|
75
75
|
context "with relative IRIs" do
|
76
76
|
{
|
77
77
|
"base" => {
|
78
|
-
:
|
78
|
+
input: {
|
79
79
|
"@id" => "",
|
80
80
|
"@type" => "#{RDF::RDFS.Resource}"
|
81
81
|
},
|
82
|
-
:
|
82
|
+
output: [{
|
83
83
|
"@id" => "http://example.org/",
|
84
84
|
"@type" => ["#{RDF::RDFS.Resource}"]
|
85
85
|
}]
|
86
86
|
},
|
87
87
|
"relative" => {
|
88
|
-
:
|
88
|
+
input: {
|
89
89
|
"@id" => "a/b",
|
90
90
|
"@type" => "#{RDF::RDFS.Resource}"
|
91
91
|
},
|
92
|
-
:
|
92
|
+
output: [{
|
93
93
|
"@id" => "http://example.org/a/b",
|
94
94
|
"@type" => ["#{RDF::RDFS.Resource}"]
|
95
95
|
}]
|
96
96
|
},
|
97
97
|
"hash" => {
|
98
|
-
:
|
98
|
+
input: {
|
99
99
|
"@id" => "#a",
|
100
100
|
"@type" => "#{RDF::RDFS.Resource}"
|
101
101
|
},
|
102
|
-
:
|
102
|
+
output: [{
|
103
103
|
"@id" => "http://example.org/#a",
|
104
104
|
"@type" => ["#{RDF::RDFS.Resource}"]
|
105
105
|
}]
|
106
106
|
},
|
107
107
|
"unmapped @id" => {
|
108
|
-
:
|
108
|
+
input: {
|
109
109
|
"http://example.com/foo" => {"@id" => "bar"}
|
110
110
|
},
|
111
|
-
:
|
111
|
+
output: [{
|
112
112
|
"http://example.com/foo" => [{"@id" => "http://example.org/bar"}]
|
113
113
|
}]
|
114
114
|
},
|
115
115
|
}.each do |title, params|
|
116
116
|
it title do
|
117
|
-
jld = JSON::LD::API.expand(params[:input], :
|
117
|
+
jld = JSON::LD::API.expand(params[:input], base: "http://example.org/", debug: @debug)
|
118
118
|
expect(jld).to produce(params[:output], @debug)
|
119
119
|
end
|
120
120
|
end
|
@@ -123,57 +123,57 @@ describe JSON::LD::API do
|
|
123
123
|
context "keyword aliasing" do
|
124
124
|
{
|
125
125
|
"@id" => {
|
126
|
-
:
|
126
|
+
input: {
|
127
127
|
"@context" => {"id" => "@id"},
|
128
128
|
"id" => "",
|
129
129
|
"@type" => "#{RDF::RDFS.Resource}"
|
130
130
|
},
|
131
|
-
:
|
131
|
+
output: [{
|
132
132
|
"@id" => "",
|
133
133
|
"@type" =>[ "#{RDF::RDFS.Resource}"]
|
134
134
|
}]
|
135
135
|
},
|
136
136
|
"@type" => {
|
137
|
-
:
|
137
|
+
input: {
|
138
138
|
"@context" => {"type" => "@type"},
|
139
139
|
"type" => RDF::RDFS.Resource.to_s,
|
140
140
|
"http://example.com/foo" => {"@value" => "bar", "type" => "http://example.com/baz"}
|
141
141
|
},
|
142
|
-
:
|
142
|
+
output: [{
|
143
143
|
"@type" => [RDF::RDFS.Resource.to_s],
|
144
144
|
"http://example.com/foo" => [{"@value" => "bar", "@type" => "http://example.com/baz"}]
|
145
145
|
}]
|
146
146
|
},
|
147
147
|
"@language" => {
|
148
|
-
:
|
148
|
+
input: {
|
149
149
|
"@context" => {"language" => "@language"},
|
150
150
|
"http://example.com/foo" => {"@value" => "bar", "language" => "baz"}
|
151
151
|
},
|
152
|
-
:
|
152
|
+
output: [{
|
153
153
|
"http://example.com/foo" => [{"@value" => "bar", "@language" => "baz"}]
|
154
154
|
}]
|
155
155
|
},
|
156
156
|
"@value" => {
|
157
|
-
:
|
157
|
+
input: {
|
158
158
|
"@context" => {"literal" => "@value"},
|
159
159
|
"http://example.com/foo" => {"literal" => "bar"}
|
160
160
|
},
|
161
|
-
:
|
161
|
+
output: [{
|
162
162
|
"http://example.com/foo" => [{"@value" => "bar"}]
|
163
163
|
}]
|
164
164
|
},
|
165
165
|
"@list" => {
|
166
|
-
:
|
166
|
+
input: {
|
167
167
|
"@context" => {"list" => "@list"},
|
168
168
|
"http://example.com/foo" => {"list" => ["bar"]}
|
169
169
|
},
|
170
|
-
:
|
170
|
+
output: [{
|
171
171
|
"http://example.com/foo" => [{"@list" => [{"@value" => "bar"}]}]
|
172
172
|
}]
|
173
173
|
},
|
174
174
|
}.each do |title, params|
|
175
175
|
it title do
|
176
|
-
jld = JSON::LD::API.expand(params[:input], :
|
176
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug)
|
177
177
|
expect(jld).to produce(params[:output], @debug)
|
178
178
|
end
|
179
179
|
end
|
@@ -182,53 +182,53 @@ describe JSON::LD::API do
|
|
182
182
|
context "native types" do
|
183
183
|
{
|
184
184
|
"true" => {
|
185
|
-
:
|
185
|
+
input: {
|
186
186
|
"@context" => {"e" => "http://example.org/vocab#"},
|
187
187
|
"e:bool" => true
|
188
188
|
},
|
189
|
-
:
|
189
|
+
output: [{
|
190
190
|
"http://example.org/vocab#bool" => [{"@value" => true}]
|
191
191
|
}]
|
192
192
|
},
|
193
193
|
"false" => {
|
194
|
-
:
|
194
|
+
input: {
|
195
195
|
"@context" => {"e" => "http://example.org/vocab#"},
|
196
196
|
"e:bool" => false
|
197
197
|
},
|
198
|
-
:
|
198
|
+
output: [{
|
199
199
|
"http://example.org/vocab#bool" => [{"@value" => false}]
|
200
200
|
}]
|
201
201
|
},
|
202
202
|
"double" => {
|
203
|
-
:
|
203
|
+
input: {
|
204
204
|
"@context" => {"e" => "http://example.org/vocab#"},
|
205
205
|
"e:double" => 1.23
|
206
206
|
},
|
207
|
-
:
|
207
|
+
output: [{
|
208
208
|
"http://example.org/vocab#double" => [{"@value" => 1.23}]
|
209
209
|
}]
|
210
210
|
},
|
211
211
|
"double-zero" => {
|
212
|
-
:
|
212
|
+
input: {
|
213
213
|
"@context" => {"e" => "http://example.org/vocab#"},
|
214
214
|
"e:double-zero" => 0.0e0
|
215
215
|
},
|
216
|
-
:
|
216
|
+
output: [{
|
217
217
|
"http://example.org/vocab#double-zero" => [{"@value" => 0.0e0}]
|
218
218
|
}]
|
219
219
|
},
|
220
220
|
"integer" => {
|
221
|
-
:
|
221
|
+
input: {
|
222
222
|
"@context" => {"e" => "http://example.org/vocab#"},
|
223
223
|
"e:integer" => 123
|
224
224
|
},
|
225
|
-
:
|
225
|
+
output: [{
|
226
226
|
"http://example.org/vocab#integer" => [{"@value" => 123}]
|
227
227
|
}]
|
228
228
|
},
|
229
229
|
}.each do |title, params|
|
230
230
|
it title do
|
231
|
-
jld = JSON::LD::API.expand(params[:input], :
|
231
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug)
|
232
232
|
expect(jld).to produce(params[:output], @debug)
|
233
233
|
end
|
234
234
|
end
|
@@ -237,26 +237,26 @@ describe JSON::LD::API do
|
|
237
237
|
context "coerced typed values" do
|
238
238
|
{
|
239
239
|
"boolean" => {
|
240
|
-
:
|
240
|
+
input: {
|
241
241
|
"@context" => {"foo" => {"@id" => "http://example.org/foo", "@type" => RDF::XSD.boolean.to_s}},
|
242
242
|
"foo" => "true"
|
243
243
|
},
|
244
|
-
:
|
244
|
+
output: [{
|
245
245
|
"http://example.org/foo" => [{"@value" => "true", "@type" => RDF::XSD.boolean.to_s}]
|
246
246
|
}]
|
247
247
|
},
|
248
248
|
"date" => {
|
249
|
-
:
|
249
|
+
input: {
|
250
250
|
"@context" => {"foo" => {"@id" => "http://example.org/foo", "@type" => RDF::XSD.date.to_s}},
|
251
251
|
"foo" => "2011-03-26"
|
252
252
|
},
|
253
|
-
:
|
253
|
+
output: [{
|
254
254
|
"http://example.org/foo" => [{"@value" => "2011-03-26", "@type" => RDF::XSD.date.to_s}]
|
255
255
|
}]
|
256
256
|
},
|
257
257
|
}.each do |title, params|
|
258
258
|
it title do
|
259
|
-
jld = JSON::LD::API.expand(params[:input], :
|
259
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug)
|
260
260
|
expect(jld).to produce(params[:output], @debug)
|
261
261
|
end
|
262
262
|
end
|
@@ -265,42 +265,42 @@ describe JSON::LD::API do
|
|
265
265
|
context "null" do
|
266
266
|
{
|
267
267
|
"value" => {
|
268
|
-
:
|
269
|
-
:
|
268
|
+
input: {"http://example.com/foo" => nil},
|
269
|
+
output: []
|
270
270
|
},
|
271
271
|
"@value" => {
|
272
|
-
:
|
273
|
-
:
|
272
|
+
input: {"http://example.com/foo" => {"@value" => nil}},
|
273
|
+
output: []
|
274
274
|
},
|
275
275
|
"@value and non-null @type" => {
|
276
|
-
:
|
277
|
-
:
|
276
|
+
input: {"http://example.com/foo" => {"@value" => nil, "@type" => "http://type"}},
|
277
|
+
output: []
|
278
278
|
},
|
279
279
|
"@value and non-null @language" => {
|
280
|
-
:
|
281
|
-
:
|
280
|
+
input: {"http://example.com/foo" => {"@value" => nil, "@language" => "en"}},
|
281
|
+
output: []
|
282
282
|
},
|
283
283
|
"array with null elements" => {
|
284
|
-
:
|
284
|
+
input: {
|
285
285
|
"http://example.com/foo" => [nil]
|
286
286
|
},
|
287
|
-
:
|
287
|
+
output: [{
|
288
288
|
"http://example.com/foo" => []
|
289
289
|
}]
|
290
290
|
},
|
291
291
|
"@set with null @value" => {
|
292
|
-
:
|
292
|
+
input: {
|
293
293
|
"http://example.com/foo" => [
|
294
294
|
{"@value" => nil, "@type" => "http://example.org/Type"}
|
295
295
|
]
|
296
296
|
},
|
297
|
-
:
|
297
|
+
output: [{
|
298
298
|
"http://example.com/foo" => []
|
299
299
|
}]
|
300
300
|
}
|
301
301
|
}.each do |title, params|
|
302
302
|
it title do
|
303
|
-
jld = JSON::LD::API.expand(params[:input], :
|
303
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug)
|
304
304
|
expect(jld).to produce(params[:output], @debug)
|
305
305
|
end
|
306
306
|
end
|
@@ -309,7 +309,7 @@ describe JSON::LD::API do
|
|
309
309
|
context "default language" do
|
310
310
|
{
|
311
311
|
"value with coerced null language" => {
|
312
|
-
:
|
312
|
+
input: {
|
313
313
|
"@context" => {
|
314
314
|
"@language" => "en",
|
315
315
|
"ex" => "http://example.org/vocab#",
|
@@ -319,7 +319,7 @@ describe JSON::LD::API do
|
|
319
319
|
"ex:german" => "german",
|
320
320
|
"ex:nolang" => "no language"
|
321
321
|
},
|
322
|
-
:
|
322
|
+
output: [
|
323
323
|
{
|
324
324
|
"http://example.org/vocab#german" => [{"@value" => "german", "@language" => "de"}],
|
325
325
|
"http://example.org/vocab#nolang" => [{"@value" => "no language"}]
|
@@ -328,7 +328,7 @@ describe JSON::LD::API do
|
|
328
328
|
},
|
329
329
|
}.each do |title, params|
|
330
330
|
it title do
|
331
|
-
jld = JSON::LD::API.expand(params[:input], :
|
331
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug)
|
332
332
|
expect(jld).to produce(params[:output], @debug)
|
333
333
|
end
|
334
334
|
end
|
@@ -337,25 +337,25 @@ describe JSON::LD::API do
|
|
337
337
|
context "default vocabulary" do
|
338
338
|
{
|
339
339
|
"property" => {
|
340
|
-
:
|
340
|
+
input: {
|
341
341
|
"@context" => {"@vocab" => "http://example.com/"},
|
342
342
|
"verb" => {"@value" => "foo"}
|
343
343
|
},
|
344
|
-
:
|
344
|
+
output: [{
|
345
345
|
"http://example.com/verb" => [{"@value" => "foo"}]
|
346
346
|
}]
|
347
347
|
},
|
348
348
|
"datatype" => {
|
349
|
-
:
|
349
|
+
input: {
|
350
350
|
"@context" => {"@vocab" => "http://example.com/"},
|
351
351
|
"http://example.org/verb" => {"@value" => "foo", "@type" => "string"}
|
352
352
|
},
|
353
|
-
:
|
353
|
+
output: [
|
354
354
|
"http://example.org/verb" => [{"@value" => "foo", "@type" => "http://example.com/string"}]
|
355
355
|
]
|
356
356
|
},
|
357
357
|
"expand-0028" => {
|
358
|
-
:
|
358
|
+
input: {
|
359
359
|
"@context" => {
|
360
360
|
"@vocab" => "http://example.org/vocab#",
|
361
361
|
"date" => { "@type" => "dateTime" }
|
@@ -368,7 +368,7 @@ describe JSON::LD::API do
|
|
368
368
|
"expandedDate" => { "@value" => "2012-08-01T00:00:00Z", "@type" => "dateTime" }
|
369
369
|
}
|
370
370
|
},
|
371
|
-
:
|
371
|
+
output: [
|
372
372
|
{
|
373
373
|
"@id" => "http://foo/bar/example1",
|
374
374
|
"@type" => ["http://example.org/vocab#test"],
|
@@ -395,8 +395,8 @@ describe JSON::LD::API do
|
|
395
395
|
}.each do |title, params|
|
396
396
|
it title do
|
397
397
|
jld = JSON::LD::API.expand(params[:input],
|
398
|
-
:
|
399
|
-
:
|
398
|
+
base: "http://foo/bar/",
|
399
|
+
debug: @debug)
|
400
400
|
expect(jld).to produce(params[:output], @debug)
|
401
401
|
end
|
402
402
|
end
|
@@ -405,35 +405,35 @@ describe JSON::LD::API do
|
|
405
405
|
context "unmapped properties" do
|
406
406
|
{
|
407
407
|
"unmapped key" => {
|
408
|
-
:
|
408
|
+
input: {
|
409
409
|
"foo" => "bar"
|
410
410
|
},
|
411
|
-
:
|
411
|
+
output: []
|
412
412
|
},
|
413
413
|
"unmapped @type as datatype" => {
|
414
|
-
:
|
414
|
+
input: {
|
415
415
|
"http://example.com/foo" => {"@value" => "bar", "@type" => "baz"}
|
416
416
|
},
|
417
|
-
:
|
417
|
+
output: [{
|
418
418
|
"http://example.com/foo" => [{"@value" => "bar", "@type" => "http://example/baz"}]
|
419
419
|
}]
|
420
420
|
},
|
421
421
|
"unknown keyword" => {
|
422
|
-
:
|
422
|
+
input: {
|
423
423
|
"@foo" => "bar"
|
424
424
|
},
|
425
|
-
:
|
425
|
+
output: []
|
426
426
|
},
|
427
427
|
"value" => {
|
428
|
-
:
|
428
|
+
input: {
|
429
429
|
"@context" => {"ex" => {"@id" => "http://example.org/idrange", "@type" => "@id"}},
|
430
430
|
"@id" => "http://example.org/Subj",
|
431
431
|
"idrange" => "unmapped"
|
432
432
|
},
|
433
|
-
:
|
433
|
+
output: []
|
434
434
|
},
|
435
435
|
"context reset" => {
|
436
|
-
:
|
436
|
+
input: {
|
437
437
|
"@context" => {"ex" => "http://example.org/", "prop" => "ex:prop"},
|
438
438
|
"@id" => "http://example.org/id1",
|
439
439
|
"prop" => "prop",
|
@@ -443,7 +443,7 @@ describe JSON::LD::API do
|
|
443
443
|
"prop" => "prop"
|
444
444
|
}
|
445
445
|
},
|
446
|
-
:
|
446
|
+
output: [{
|
447
447
|
"@id" => "http://example.org/id1",
|
448
448
|
"http://example.org/prop" => [{"@value" => "prop"}],
|
449
449
|
"http://example.org/chain" => [{"@id" => "http://example.org/id2"}]
|
@@ -451,7 +451,7 @@ describe JSON::LD::API do
|
|
451
451
|
]}
|
452
452
|
}.each do |title, params|
|
453
453
|
it title do
|
454
|
-
jld = JSON::LD::API.expand(params[:input], :
|
454
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug, base: 'http://example/')
|
455
455
|
expect(jld).to produce(params[:output], @debug)
|
456
456
|
end
|
457
457
|
end
|
@@ -460,52 +460,52 @@ describe JSON::LD::API do
|
|
460
460
|
context "lists" do
|
461
461
|
{
|
462
462
|
"empty" => {
|
463
|
-
:
|
464
|
-
:
|
463
|
+
input: {"http://example.com/foo" => {"@list" => []}},
|
464
|
+
output: [{"http://example.com/foo" => [{"@list" => []}]}]
|
465
465
|
},
|
466
466
|
"coerced empty" => {
|
467
|
-
:
|
467
|
+
input: {
|
468
468
|
"@context" => {"http://example.com/foo" => {"@container" => "@list"}},
|
469
469
|
"http://example.com/foo" => []
|
470
470
|
},
|
471
|
-
:
|
471
|
+
output: [{"http://example.com/foo" => [{"@list" => []}]}]
|
472
472
|
},
|
473
473
|
"coerced single element" => {
|
474
|
-
:
|
474
|
+
input: {
|
475
475
|
"@context" => {"http://example.com/foo" => {"@container" => "@list"}},
|
476
476
|
"http://example.com/foo" => [ "foo" ]
|
477
477
|
},
|
478
|
-
:
|
478
|
+
output: [{"http://example.com/foo" => [{"@list" => [{"@value" => "foo"}]}]}]
|
479
479
|
},
|
480
480
|
"coerced multiple elements" => {
|
481
|
-
:
|
481
|
+
input: {
|
482
482
|
"@context" => {"http://example.com/foo" => {"@container" => "@list"}},
|
483
483
|
"http://example.com/foo" => [ "foo", "bar" ]
|
484
484
|
},
|
485
|
-
:
|
485
|
+
output: [{
|
486
486
|
"http://example.com/foo" => [{"@list" => [ {"@value" => "foo"}, {"@value" => "bar"} ]}]
|
487
487
|
}]
|
488
488
|
},
|
489
489
|
"explicit list with coerced @id values" => {
|
490
|
-
:
|
490
|
+
input: {
|
491
491
|
"@context" => {"http://example.com/foo" => {"@type" => "@id"}},
|
492
492
|
"http://example.com/foo" => {"@list" => ["http://foo", "http://bar"]}
|
493
493
|
},
|
494
|
-
:
|
494
|
+
output: [{
|
495
495
|
"http://example.com/foo" => [{"@list" => [{"@id" => "http://foo"}, {"@id" => "http://bar"}]}]
|
496
496
|
}]
|
497
497
|
},
|
498
498
|
"explicit list with coerced datatype values" => {
|
499
|
-
:
|
499
|
+
input: {
|
500
500
|
"@context" => {"http://example.com/foo" => {"@type" => RDF::XSD.date.to_s}},
|
501
501
|
"http://example.com/foo" => {"@list" => ["2012-04-12"]}
|
502
502
|
},
|
503
|
-
:
|
503
|
+
output: [{
|
504
504
|
"http://example.com/foo" => [{"@list" => [{"@value" => "2012-04-12", "@type" => RDF::XSD.date.to_s}]}]
|
505
505
|
}]
|
506
506
|
},
|
507
507
|
"expand-0004" => {
|
508
|
-
:
|
508
|
+
input: ::JSON.parse(%({
|
509
509
|
"@context": {
|
510
510
|
"mylist1": {"@id": "http://example.com/mylist1", "@container": "@list"},
|
511
511
|
"mylist2": {"@id": "http://example.com/mylist2", "@container": "@list"},
|
@@ -514,7 +514,7 @@ describe JSON::LD::API do
|
|
514
514
|
},
|
515
515
|
"http://example.org/property": { "@list": "one item" }
|
516
516
|
})),
|
517
|
-
:
|
517
|
+
output: ::JSON.parse(%([
|
518
518
|
{
|
519
519
|
"http://example.org/property": [
|
520
520
|
{
|
@@ -530,7 +530,7 @@ describe JSON::LD::API do
|
|
530
530
|
}
|
531
531
|
}.each do |title, params|
|
532
532
|
it title do
|
533
|
-
jld = JSON::LD::API.expand(params[:input], :
|
533
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug)
|
534
534
|
expect(jld).to produce(params[:output], @debug)
|
535
535
|
end
|
536
536
|
end
|
@@ -539,51 +539,51 @@ describe JSON::LD::API do
|
|
539
539
|
context "sets" do
|
540
540
|
{
|
541
541
|
"empty" => {
|
542
|
-
:
|
542
|
+
input: {
|
543
543
|
"http://example.com/foo" => {"@set" => []}
|
544
544
|
},
|
545
|
-
:
|
545
|
+
output: [{
|
546
546
|
"http://example.com/foo" => []
|
547
547
|
}]
|
548
548
|
},
|
549
549
|
"coerced empty" => {
|
550
|
-
:
|
550
|
+
input: {
|
551
551
|
"@context" => {"http://example.com/foo" => {"@container" => "@set"}},
|
552
552
|
"http://example.com/foo" => []
|
553
553
|
},
|
554
|
-
:
|
554
|
+
output: [{
|
555
555
|
"http://example.com/foo" => []
|
556
556
|
}]
|
557
557
|
},
|
558
558
|
"coerced single element" => {
|
559
|
-
:
|
559
|
+
input: {
|
560
560
|
"@context" => {"http://example.com/foo" => {"@container" => "@set"}},
|
561
561
|
"http://example.com/foo" => [ "foo" ]
|
562
562
|
},
|
563
|
-
:
|
563
|
+
output: [{
|
564
564
|
"http://example.com/foo" => [ {"@value" => "foo"} ]
|
565
565
|
}]
|
566
566
|
},
|
567
567
|
"coerced multiple elements" => {
|
568
|
-
:
|
568
|
+
input: {
|
569
569
|
"@context" => {"http://example.com/foo" => {"@container" => "@set"}},
|
570
570
|
"http://example.com/foo" => [ "foo", "bar" ]
|
571
571
|
},
|
572
|
-
:
|
572
|
+
output: [{
|
573
573
|
"http://example.com/foo" => [ {"@value" => "foo"}, {"@value" => "bar"} ]
|
574
574
|
}]
|
575
575
|
},
|
576
576
|
"array containing set" => {
|
577
|
-
:
|
577
|
+
input: {
|
578
578
|
"http://example.com/foo" => [{"@set" => []}]
|
579
579
|
},
|
580
|
-
:
|
580
|
+
output: [{
|
581
581
|
"http://example.com/foo" => []
|
582
582
|
}]
|
583
583
|
},
|
584
584
|
}.each do |title, params|
|
585
585
|
it title do
|
586
|
-
jld = JSON::LD::API.expand(params[:input], :
|
586
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug)
|
587
587
|
expect(jld).to produce(params[:output], @debug)
|
588
588
|
end
|
589
589
|
end
|
@@ -592,7 +592,7 @@ describe JSON::LD::API do
|
|
592
592
|
context "language maps" do
|
593
593
|
{
|
594
594
|
"simple map" => {
|
595
|
-
:
|
595
|
+
input: {
|
596
596
|
"@context" => {
|
597
597
|
"vocab" => "http://example.com/vocab/",
|
598
598
|
"label" => {
|
@@ -606,7 +606,7 @@ describe JSON::LD::API do
|
|
606
606
|
"de" => [ "Die Königin", "Ihre Majestät" ]
|
607
607
|
}
|
608
608
|
},
|
609
|
-
:
|
609
|
+
output: [
|
610
610
|
{
|
611
611
|
"@id" => "http://example.com/queen",
|
612
612
|
"http://example.com/vocab/label" => [
|
@@ -618,7 +618,7 @@ describe JSON::LD::API do
|
|
618
618
|
]
|
619
619
|
},
|
620
620
|
"expand-0035" => {
|
621
|
-
:
|
621
|
+
input: {
|
622
622
|
"@context" => {
|
623
623
|
"@vocab" => "http://example.com/vocab/",
|
624
624
|
"@language" => "it",
|
@@ -636,7 +636,7 @@ describe JSON::LD::API do
|
|
636
636
|
{ "@value" => "The king", "@language" => "en" }
|
637
637
|
]
|
638
638
|
},
|
639
|
-
:
|
639
|
+
output: [
|
640
640
|
{
|
641
641
|
"@id" => "http://example.com/queen",
|
642
642
|
"http://example.com/vocab/label" => [
|
@@ -651,7 +651,7 @@ describe JSON::LD::API do
|
|
651
651
|
}
|
652
652
|
}.each do |title, params|
|
653
653
|
it title do
|
654
|
-
jld = JSON::LD::API.expand(params[:input], :
|
654
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug)
|
655
655
|
expect(jld).to produce(params[:output], @debug)
|
656
656
|
end
|
657
657
|
end
|
@@ -660,7 +660,7 @@ describe JSON::LD::API do
|
|
660
660
|
context "@reverse" do
|
661
661
|
{
|
662
662
|
"expand-0037" => {
|
663
|
-
:
|
663
|
+
input: ::JSON.parse(%({
|
664
664
|
"@context": {
|
665
665
|
"name": "http://xmlns.com/foaf/0.1/name"
|
666
666
|
},
|
@@ -673,7 +673,7 @@ describe JSON::LD::API do
|
|
673
673
|
}
|
674
674
|
}
|
675
675
|
})),
|
676
|
-
:
|
676
|
+
output: ::JSON.parse(%([
|
677
677
|
{
|
678
678
|
"@id": "http://example.com/people/markus",
|
679
679
|
"@reverse": {
|
@@ -697,7 +697,7 @@ describe JSON::LD::API do
|
|
697
697
|
]))
|
698
698
|
},
|
699
699
|
"expand-0043" => {
|
700
|
-
:
|
700
|
+
input: ::JSON.parse(%({
|
701
701
|
"@context": {
|
702
702
|
"name": "http://xmlns.com/foaf/0.1/name",
|
703
703
|
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
|
@@ -717,7 +717,7 @@ describe JSON::LD::API do
|
|
717
717
|
]
|
718
718
|
}
|
719
719
|
})),
|
720
|
-
:
|
720
|
+
output: ::JSON.parse(%([
|
721
721
|
{
|
722
722
|
"@id": "http://example.com/people/markus",
|
723
723
|
"http://xmlns.com/foaf/0.1/knows": [
|
@@ -748,7 +748,7 @@ describe JSON::LD::API do
|
|
748
748
|
},
|
749
749
|
}.each do |title, params|
|
750
750
|
it title do
|
751
|
-
jld = JSON::LD::API.expand(params[:input], :
|
751
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug)
|
752
752
|
expect(jld).to produce(params[:output], @debug)
|
753
753
|
end
|
754
754
|
end
|
@@ -757,7 +757,7 @@ describe JSON::LD::API do
|
|
757
757
|
context "@index" do
|
758
758
|
{
|
759
759
|
"string annotation" => {
|
760
|
-
:
|
760
|
+
input: {
|
761
761
|
"@context" => {
|
762
762
|
"container" => {
|
763
763
|
"@id" => "http://example.com/container",
|
@@ -770,7 +770,7 @@ describe JSON::LD::API do
|
|
770
770
|
"de" => [ "Die Königin", "Ihre Majestät" ]
|
771
771
|
}
|
772
772
|
},
|
773
|
-
:
|
773
|
+
output: [
|
774
774
|
{
|
775
775
|
"@id" => "http://example.com/annotationsTest",
|
776
776
|
"http://example.com/container" => [
|
@@ -783,7 +783,7 @@ describe JSON::LD::API do
|
|
783
783
|
},
|
784
784
|
}.each do |title, params|
|
785
785
|
it title do
|
786
|
-
jld = JSON::LD::API.expand(params[:input], :
|
786
|
+
jld = JSON::LD::API.expand(params[:input], debug: @debug)
|
787
787
|
expect(jld).to produce(params[:output], @debug)
|
788
788
|
end
|
789
789
|
end
|
@@ -792,51 +792,51 @@ describe JSON::LD::API do
|
|
792
792
|
context "exceptions" do
|
793
793
|
{
|
794
794
|
"non-null @value and null @type" => {
|
795
|
-
:
|
796
|
-
:
|
795
|
+
input: {"http://example.com/foo" => {"@value" => "foo", "@type" => nil}},
|
796
|
+
exception: JSON::LD::JsonLdError::InvalidTypeValue
|
797
797
|
},
|
798
798
|
"non-null @value and null @language" => {
|
799
|
-
:
|
800
|
-
:
|
799
|
+
input: {"http://example.com/foo" => {"@value" => "foo", "@language" => nil}},
|
800
|
+
exception: JSON::LD::JsonLdError::InvalidLanguageTaggedString
|
801
801
|
},
|
802
802
|
"value with null language" => {
|
803
|
-
:
|
803
|
+
input: {
|
804
804
|
"@context" => {"@language" => "en"},
|
805
805
|
"http://example.org/nolang" => {"@value" => "no language", "@language" => nil}
|
806
806
|
},
|
807
|
-
:
|
807
|
+
exception: JSON::LD::JsonLdError::InvalidLanguageTaggedString
|
808
808
|
},
|
809
809
|
"@list containing @list" => {
|
810
|
-
:
|
810
|
+
input: {
|
811
811
|
"http://example.com/foo" => {"@list" => [{"@list" => ["baz"]}]}
|
812
812
|
},
|
813
|
-
:
|
813
|
+
exception: JSON::LD::JsonLdError::ListOfLists
|
814
814
|
},
|
815
815
|
"@list containing @list (with coercion)" => {
|
816
|
-
:
|
816
|
+
input: {
|
817
817
|
"@context" => {"foo" => {"@id" => "http://example.com/foo", "@container" => "@list"}},
|
818
818
|
"foo" => [{"@list" => ["baz"]}]
|
819
819
|
},
|
820
|
-
:
|
820
|
+
exception: JSON::LD::JsonLdError::ListOfLists
|
821
821
|
},
|
822
822
|
"coerced @list containing an array" => {
|
823
|
-
:
|
823
|
+
input: {
|
824
824
|
"@context" => {"foo" => {"@id" => "http://example.com/foo", "@container" => "@list"}},
|
825
825
|
"foo" => [["baz"]]
|
826
826
|
},
|
827
|
-
:
|
827
|
+
exception: JSON::LD::JsonLdError::ListOfLists
|
828
828
|
},
|
829
829
|
"@reverse object with an @id property" => {
|
830
|
-
:
|
830
|
+
input: JSON.parse(%({
|
831
831
|
"@id": "http://example/foo",
|
832
832
|
"@reverse": {
|
833
833
|
"@id": "http://example/bar"
|
834
834
|
}
|
835
835
|
})),
|
836
|
-
:
|
836
|
+
exception: JSON::LD::JsonLdError::InvalidReversePropertyMap,
|
837
837
|
},
|
838
838
|
"colliding keywords" => {
|
839
|
-
:
|
839
|
+
input: JSON.parse(%({
|
840
840
|
"@context": {
|
841
841
|
"id": "@id",
|
842
842
|
"ID": "@id"
|
@@ -844,11 +844,11 @@ describe JSON::LD::API do
|
|
844
844
|
"id": "http://example/foo",
|
845
845
|
"ID": "http://example/bar"
|
846
846
|
})),
|
847
|
-
:
|
847
|
+
exception: JSON::LD::JsonLdError::CollidingKeywords,
|
848
848
|
}
|
849
849
|
}.each do |title, params|
|
850
850
|
it title do
|
851
|
-
#JSON::LD::API.expand(params[:input], :
|
851
|
+
#JSON::LD::API.expand(params[:input], debug: @debug).should produce([], @debug)
|
852
852
|
expect {JSON::LD::API.expand(params[:input])}.to raise_error(params[:exception])
|
853
853
|
end
|
854
854
|
end
|