|
20 | 20 | {:content_type => 'application/x-ld+json'}, |
21 | 21 | ].each do |arg| |
22 | 22 | it "discovers with #{arg.inspect}" do |
23 | | - RDF::Reader.for(arg).should == JSON::LD::Reader |
| 23 | + expect(RDF::Reader.for(arg)).to eql JSON::LD::Reader |
24 | 24 | end |
25 | 25 | end |
26 | 26 | end |
27 | 27 |
|
28 | 28 | context "simple tests" do |
29 | 29 | it "should use full URIs without base" do |
30 | 30 | input = %(<http://a/b> <http://a/c> <http://a/d> .) |
31 | | - serialize(input).should produce([{ |
| 31 | + expect(serialize(input)).to produce([{ |
32 | 32 | '@id' => "http://a/b", |
33 | 33 | "http://a/c" => [{"@id" => "http://a/d"}] |
34 | 34 | }], @debug) |
35 | 35 | end |
36 | 36 |
|
37 | 37 | it "should use qname URIs with standard prefix" do |
38 | 38 | input = %(<http://xmlns.com/foaf/0.1/b> <http://xmlns.com/foaf/0.1/c> <http://xmlns.com/foaf/0.1/d> .) |
39 | | - serialize(input, :standard_prefixes => true). |
40 | | - should produce({ |
| 39 | + expect(serialize(input, :standard_prefixes => true)).to produce({ |
41 | 40 | '@context' => { |
42 | 41 | "foaf" => "http://xmlns.com/foaf/0.1/", |
43 | 42 | }, |
|
53 | 52 | <https://senet.org/gm> <https://senet.org/ns#unofficialTitle> "Rhythm Tengoku"@en . |
54 | 53 | <https://senet.org/gm> <https://senet.org/ns#urlkey> "rhythm-tengoku" . |
55 | 54 | ) |
56 | | - serialize(input, :prefixes => { |
| 55 | + expect(serialize(input, :prefixes => { |
57 | 56 | :dc => "http://purl.org/dc/terms/", |
58 | 57 | :frbr => "http://vocab.org/frbr/core#", |
59 | 58 | :senet => "https://senet.org/ns#", |
60 | | - }). |
61 | | - should produce({ |
| 59 | + })).to produce({ |
62 | 60 | '@context' => { |
63 | 61 | "dc" => "http://purl.org/dc/terms/", |
64 | 62 | "frbr" => "http://vocab.org/frbr/core#", |
|
75 | 73 | it "should use CURIEs with empty prefix" do |
76 | 74 | input = %(<http://xmlns.com/foaf/0.1/b> <http://xmlns.com/foaf/0.1/c> <http://xmlns.com/foaf/0.1/d> .) |
77 | 75 | begin |
78 | | - serialize(input, :prefixes => { "" => RDF::FOAF}). |
79 | | - should produce({ |
| 76 | + expect(serialize(input, :prefixes => { "" => RDF::FOAF})). |
| 77 | + to produce({ |
80 | 78 | "@context" => { |
81 | 79 | "" => "http://xmlns.com/foaf/0.1/" |
82 | 80 | }, |
|
92 | 90 |
|
93 | 91 | it "should not use terms if no suffix" do |
94 | 92 | input = %(<http://xmlns.com/foaf/0.1/> <http://xmlns.com/foaf/0.1/> <http://xmlns.com/foaf/0.1/> .) |
95 | | - serialize(input, :standard_prefixes => true). |
96 | | - should_not produce({ |
| 93 | + expect(serialize(input, :standard_prefixes => true)). |
| 94 | + not_to produce({ |
97 | 95 | "@context" => {"foaf" => "http://xmlns.com/foaf/0.1/"}, |
98 | 96 | '@id' => "foaf", |
99 | 97 | "foaf" => {"@id" => "foaf"} |
|
107 | 105 | db:Michael_Jackson dbo:artistOf <http://dbpedia.org/resource/%28I_Can%27t_Make_It%29_Another_Day> . |
108 | 106 | ) |
109 | 107 |
|
110 | | - serialize(input, :prefixes => { |
| 108 | + expect(serialize(input, :prefixes => { |
111 | 109 | "db" => RDF::URI("http://dbpedia.org/resource/"), |
112 | | - "dbo" => RDF::URI("http://dbpedia.org/ontology/")}). |
113 | | - should produce({ |
| 110 | + "dbo" => RDF::URI("http://dbpedia.org/ontology/")})). |
| 111 | + to produce({ |
114 | 112 | "@context" => { |
115 | 113 | "db" => "http://dbpedia.org/resource/", |
116 | 114 | "dbo" => "http://dbpedia.org/ontology/" |
|
120 | 118 | }, @debug) |
121 | 119 | end |
122 | 120 |
|
| 121 | + it "should not use provided node identifiers if :unique_bnodes set" do |
| 122 | + input = %(_:a <http://example.com/foo> _:b \.) |
| 123 | + result = serialize(input, unique_bnodes: true, context: {}) |
| 124 | + expect(result.to_json).to match(%r(_:g\w+)) |
| 125 | + end |
| 126 | + |
123 | 127 | it "serializes multiple subjects" do |
124 | 128 | input = %q( |
125 | 129 | @prefix : <http://www.w3.org/2006/03/test-description#> . |
126 | 130 | @prefix dc: <http://purl.org/dc/terms/> . |
127 | 131 | <http://example.com/test-cases/0001> a :TestCase . |
128 | 132 | <http://example.com/test-cases/0002> a :TestCase . |
129 | 133 | ) |
130 | | - serialize(input, :prefixes => {"" => "http://www.w3.org/2006/03/test-description#"}). |
131 | | - should produce({ |
| 134 | + expect(serialize(input, :prefixes => {"" => "http://www.w3.org/2006/03/test-description#"})). |
| 135 | + to produce({ |
132 | 136 | '@context' => { |
133 | 137 | "" => "http://www.w3.org/2006/03/test-description#", |
134 | 138 | "dc" => RDF::DC.to_s |
|
154 | 158 | owl:onClass <http://data.wikia.com/terms#Element>; |
155 | 159 | owl:onProperty <http://data.wikia.com/terms#characterIn> . |
156 | 160 | ) |
157 | | - serialize(input, :rename_bnodes => false, :prefixes => { |
| 161 | + expect(serialize(input, :rename_bnodes => false, :prefixes => { |
158 | 162 | :owl => "http://www.w3.org/2002/07/owl#", |
159 | 163 | :rdfs => "http://www.w3.org/2000/01/rdf-schema#", |
160 | 164 | :xsd => "http://www.w3.org/2001/XMLSchema#" |
161 | | - }). |
162 | | - should produce({ |
| 165 | + })). |
| 166 | + to produce({ |
163 | 167 | '@context' => { |
164 | 168 | "owl" => "http://www.w3.org/2002/07/owl#", |
165 | 169 | "rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", |
|
0 commit comments