rdf-rdfa 0.3.4.2 → 0.3.5.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.
@@ -1,68 +0,0 @@
1
- $:.unshift "."
2
- require File.join(File.dirname(__FILE__), 'spec_helper')
3
-
4
- describe RDF::RDFa::Profile do
5
- describe ".new" do
6
- describe "foaf" do
7
- subject { RDF::RDFa::Profile.new("http://example/") }
8
-
9
- it "has a URI" do
10
- subject.uri.should == RDF::URI("http://example/")
11
- end
12
-
13
- it "has no terms" do
14
- subject.terms.should be_empty
15
- end
16
-
17
- it "has no vocabulary" do
18
- subject.vocabulary.should be_nil
19
- end
20
-
21
- it "has no prefixes" do
22
- subject.prefixes.should be_empty
23
- end
24
- end
25
- end
26
-
27
- describe ".find" do
28
- describe "foaf" do
29
- subject { RDF::RDFa::Profile.find("http://rdfa.digitalbazaar.com/test-suite/profiles/foaf") }
30
-
31
- it "has 74 terms" do
32
- subject.terms.keys.length.should == 74
33
- end
34
-
35
- it "uses symbols for term lookup" do
36
- subject.terms.keys.all? {|k| k.is_a?(Symbol)}.should be_true
37
- end
38
-
39
- it "has no vocabulary" do
40
- subject.vocabulary.should be_nil
41
- end
42
-
43
- it "has no prefixes" do
44
- subject.prefixes.should be_empty
45
- end
46
- end
47
-
48
- describe "basic" do
49
- subject { RDF::RDFa::Profile.find("http://rdfa.digitalbazaar.com/test-suite/profiles/basic") }
50
-
51
- it "has no terms" do
52
- subject.terms.should be_empty
53
- end
54
-
55
- it "has no vocabulary" do
56
- subject.vocabulary.should be_nil
57
- end
58
-
59
- it "has 6 prefixes" do
60
- subject.prefixes.keys.length.should == 6
61
- end
62
-
63
- it "uses symbols for prefix lookup" do
64
- subject.prefixes.keys.all? {|k| k.is_a?(Symbol)}.should be_true
65
- end
66
- end
67
- end
68
- end
@@ -1,572 +0,0 @@
1
- $:.unshift "."
2
- require File.join(File.dirname(__FILE__), 'spec_helper')
3
-
4
- describe RDF::RDFa::Format do
5
- context "should be discover 'rdfa'" do
6
- [
7
- [:rdfa, RDF::RDFa::Format],
8
- ["etc/foaf.html", RDF::RDFa::Format],
9
- [{:file_name => "etc/foaf.html"}, RDF::RDFa::Format],
10
- [{:file_extension => "html"}, RDF::RDFa::Format],
11
- [{:file_extension => "xhtml"}, RDF::RDFa::XHTML],
12
- [{:file_extension => "svg"}, RDF::RDFa::SVG],
13
- [{:content_type => "text/html"}, RDF::RDFa::Format],
14
- [{:content_type => "application/xhtml+xml"}, RDF::RDFa::XHTML],
15
- [{:content_type => "image/svg+xml"}, RDF::RDFa::SVG],
16
- ].each do |(arg, format)|
17
- it "returns #{format} for #{arg.inspect}" do
18
- RDF::Format.for(arg).should == format
19
- end
20
- end
21
- end
22
-
23
- it "should discover 'html'" do
24
- RDF::Format.for(:html).reader.should == RDF::RDFa::Reader
25
- RDF::Format.for(:html).writer.should == RDF::RDFa::Writer
26
- end
27
-
28
- it "should discover 'xhtml'" do
29
- RDF::Format.for(:xhtml).reader.should == RDF::RDFa::Reader
30
- RDF::Format.for(:xhtml).writer.should == RDF::RDFa::Writer
31
- end
32
-
33
- it "should discover 'svg'" do
34
- RDF::Format.for(:svg).reader.should == RDF::RDFa::Reader
35
- RDF::Format.for(:svg).writer.should == RDF::RDFa::Writer
36
- end
37
- end
38
-
39
- describe "RDF::RDFa::Reader" do
40
- describe "discovery" do
41
- {
42
- "html" => RDF::Reader.for(:rdfa),
43
- "etc/foaf.html" => RDF::Reader.for("etc/foaf.html"),
44
- "foaf.html" => RDF::Reader.for(:file_name => "foaf.html"),
45
- ".html" => RDF::Reader.for(:file_extension => "html"),
46
- "application/xhtml+xml" => RDF::Reader.for(:content_type => "application/xhtml+xml"),
47
- }.each_pair do |label, format|
48
- it "should discover '#{label}'" do
49
- format.should == RDF::RDFa::Reader
50
- end
51
- end
52
- end
53
-
54
- describe :interface do
55
- before(:each) do
56
- @sampledoc = %(<?xml version="1.0" encoding="UTF-8"?>
57
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
58
- <html xmlns="http://www.w3.org/1999/xhtml"
59
- xmlns:dc="http://purl.org/dc/elements/1.1/">
60
- <head>
61
- <title>Test 0001</title>
62
- </head>
63
- <body>
64
- <p>This photo was taken by <span class="author" about="photo1.jpg" property="dc:creator">Mark Birbeck</span>.</p>
65
- </body>
66
- </html>
67
- )
68
- end
69
-
70
- it "should yield reader" do
71
- inner = mock("inner")
72
- inner.should_receive(:called).with(RDF::RDFa::Reader)
73
- RDF::RDFa::Reader.new(@sampledoc) do |reader|
74
- inner.called(reader.class)
75
- end
76
- end
77
-
78
- it "should return reader" do
79
- RDF::RDFa::Reader.new(@sampledoc).should be_a(RDF::RDFa::Reader)
80
- end
81
-
82
- it "should yield statements" do
83
- inner = mock("inner")
84
- inner.should_receive(:called).with(RDF::Statement)
85
- RDF::RDFa::Reader.new(@sampledoc).each_statement do |statement|
86
- inner.called(statement.class)
87
- end
88
- end
89
-
90
- it "should yield triples" do
91
- inner = mock("inner")
92
- inner.should_receive(:called).with(RDF::URI, RDF::URI, RDF::Literal)
93
- RDF::RDFa::Reader.new(@sampledoc).each_triple do |subject, predicate, object|
94
- inner.called(subject.class, predicate.class, object.class)
95
- end
96
- end
97
- end
98
-
99
- describe "parsing a simple doc" do
100
- before :each do
101
- sampledoc = %(<?xml version="1.0" encoding="UTF-8"?>
102
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
103
- <html xmlns="http://www.w3.org/1999/xhtml"
104
- xmlns:dc="http://purl.org/dc/elements/1.1/">
105
- <head>
106
- <title>Test 0001</title>
107
- </head>
108
- <body>
109
- <p>This photo was taken by <span class="author" about="photo1.jpg" property="dc:creator">Mark Birbeck</span>.</p>
110
- </body>
111
- </html>
112
- )
113
-
114
- @graph = parse(sampledoc, :base_uri => "http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0001.xhtml", :validate => true)
115
- @statement = @graph.statements.first
116
- end
117
-
118
- it "should return 1 triple" do
119
- @graph.size.should == 1
120
- end
121
-
122
- it "should have a subject with an expanded URI" do
123
- @statement.subject.should == RDF::URI('http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/photo1.jpg')
124
- end
125
-
126
- it "should have a predicate of dc:creator" do
127
- @statement.predicate.should == RDF::DC11.creator
128
- end
129
-
130
- it "should have an object of type literal and value 'Mark Birkbeck'" do
131
- @statement.object.should == RDF::Literal("Mark Birbeck")
132
- end
133
- end
134
-
135
- describe "parsing a simple doc without a base URI" do
136
- before :each do
137
- sampledoc = %(<?xml version="1.0" encoding="UTF-8"?>
138
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
139
- <html xmlns="http://www.w3.org/1999/xhtml"
140
- xmlns:dc="http://purl.org/dc/elements/1.1/">
141
- <body>
142
- <p>This photo was taken by <span class="author" about="_:photo" property="dc:creator">Mark Birbeck</span>.</p>
143
- </body>
144
- </html>
145
- )
146
-
147
- @graph = parse(sampledoc, :validate => true)
148
- @statement = @graph.statements.first
149
- end
150
-
151
- it "should return 1 triple" do
152
- @graph.size.should == 1
153
- end
154
-
155
- it "should have a Blank Node named 'photo' as the subject of the triple" do
156
- @statement.subject.should == RDF::Node('photo')
157
- end
158
-
159
- it "should have a predicate of dc:creator" do
160
- @statement.predicate.should == RDF::DC11.creator
161
- end
162
-
163
- it "should have an object of type literal and value 'Mark Birkbeck'" do
164
- @statement.object.should == RDF::Literal("Mark Birbeck")
165
- end
166
- end
167
-
168
- describe "parsing a document containing an XML Literal" do
169
- before :each do
170
- sampledoc = %(<?xml version="1.0" encoding="UTF-8"?>
171
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
172
- <html xmlns="http://www.w3.org/1999/xhtml"
173
- xmlns:dc="http://purl.org/dc/elements/1.1/"
174
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
175
- <head>
176
- <title>Test 0011</title>
177
- </head>
178
- <body>
179
- <div about="">
180
- Author: <span property="dc:creator">Albert Einstein</span>
181
- <h2 property="dc:title" datatype="rdf:XMLLiteral">E = mc<sup>2</sup>: The Most Urgent Problem of Our Time</h2>
182
- </div>
183
- </body>
184
- </html>
185
- )
186
-
187
- @graph = parse(sampledoc, :base_uri => "http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0011.xhtml", :validate => true)
188
- end
189
-
190
- it "should return 2 triples" do
191
- @graph.size.should == 2
192
- end
193
-
194
- it "should have a triple for the dc:creator of the document" do
195
- @graph.should have_triple([
196
- RDF::URI('http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0011.xhtml'),
197
- RDF::DC11.creator,
198
- "Albert Einstein"
199
- ])
200
- end
201
-
202
- it "should have an XML Literal for the dc:title of the document" do
203
- begin
204
- @graph.should have_triple([
205
- RDF::URI('http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0011.xhtml'),
206
- RDF::DC11.title,
207
- RDF::Literal(%(E = mc<sup xmlns="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">2</sup>: The Most Urgent Problem of Our Time), :datatype => RDF.XMLLiteral)
208
- ])
209
- rescue RSpec::Expectations::ExpectationNotMetError => e
210
- pending("XMLLiteral canonicalization not implemented yet")
211
- end
212
- end
213
- end
214
-
215
- describe "parsing a document containing sereral bnodes" do
216
- before :each do
217
- sampledoc = %(<?xml version="1.0" encoding="UTF-8"?>
218
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
219
- <html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.1"
220
- xmlns:foaf="http://xmlns.com/foaf/0.1/">
221
- <head>
222
- <title>Test 0017</title>
223
- </head>
224
- <body>
225
- <p>
226
- <span about="[_:a]" property="foaf:name">Manu Sporny</span>
227
- <span about="[_:a]" rel="foaf:knows" resource="[_:b]">knows</span>
228
- <span about="[_:b]" property="foaf:name">Ralph Swick</span>.
229
- </p>
230
- </body>
231
- </html>
232
- )
233
-
234
- @graph = parse(sampledoc, :base_uri => "http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0017.xhtml", :validate => true)
235
- end
236
-
237
- it "should return 3 triples" do
238
- @graph.size.should == 3
239
- end
240
-
241
- it "should have a triple for the foaf:name of BNode A" do
242
- @graph.should have_triple([
243
- RDF::Node('a'),
244
- RDF::FOAF.name,
245
- "Manu Sporny"
246
- ])
247
- end
248
-
249
- it "should have a triple for the foaf:name of BNode B" do
250
- @graph.should have_triple([
251
- RDF::Node('b'),
252
- RDF::FOAF.name,
253
- "Ralph Swick"
254
- ])
255
- end
256
-
257
- it "should have a triple for BNode A knows BNode B" do
258
- @graph.should have_triple([
259
- RDF::Node('a'),
260
- RDF::FOAF.knows,
261
- RDF::Node('b'),
262
- ])
263
- end
264
- end
265
-
266
- describe "parsing a document that uses the typeof attribute" do
267
- before :each do
268
- sampledoc = %(<?xml version="1.0" encoding="UTF-8"?>
269
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
270
- <html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.1"
271
- xmlns:foaf="http://xmlns.com/foaf/0.1/">
272
- <head>
273
- <title>Test 0049</title>
274
- </head>
275
- <body>
276
- <div about="http://www.example.org/#me" typeof="foaf:Person">
277
- <p property="foaf:name">John Doe</p>
278
- </div>
279
- </body>
280
- </html>
281
- )
282
-
283
- @graph = parse(sampledoc, :base_uri => "http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0049.xhtml", :validate => true)
284
- end
285
-
286
- it "should return 2 triples" do
287
- @graph.size.should == 2
288
- end
289
-
290
- it "should have a triple stating that #me is of type foaf:Person" do
291
- @graph.should have_triple([
292
- RDF::URI('http://www.example.org/#me'),
293
- RDF.type,
294
- RDF::FOAF.Person
295
- ])
296
- end
297
-
298
- it "should have a triple stating that #me has name 'John Doe'" do
299
- @graph.should have_triple([
300
- RDF::URI('http://www.example.org/#me'),
301
- RDF::FOAF.name,
302
- RDF::Literal("John Doe")
303
- ])
304
- end
305
- end
306
-
307
- describe "parsing a document with a <base> tag in the <head>" do
308
- before :each do
309
- sampledoc = %(<?xml version="1.0" encoding="UTF-8"?>
310
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
311
- <html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.1"
312
- xmlns:dc="http://purl.org/dc/elements/1.1/">
313
- <head>
314
- <base href="http://www.example.org/"></base>
315
- <title>Test 0072</title>
316
- </head>
317
- <body>
318
- <p about="faq">
319
- Learn more by reading the example.org
320
- <span property="dc:title">Example FAQ</span>.
321
- </p>
322
- </body>
323
- </html>
324
- )
325
-
326
- @graph = parse(sampledoc, :base_uri => "http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0072.xhtml", :validate => true)
327
- end
328
-
329
- it "should return 1 triple" do
330
- @graph.size.should == 1
331
- end
332
-
333
- it "should have the subject of the triple relative to the URI in base" do
334
- @graph.should have_subject RDF::URI('http://www.example.org/faq')
335
- end
336
- end
337
-
338
- describe "parsing a document with a profile containing a prefix mapping" do
339
- before :each do
340
- sampledoc = %(<?xml version="1.0" encoding="UTF-8"?>
341
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
342
- <html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.1">
343
- <head>
344
- <title>Test</title>
345
- <base href="http://example.org/"/>
346
- </head>
347
- <body profile="http://rdfa.digitalbazaar.com/test-suite/test-cases/tests/../../profiles/basic">
348
- <div about="#me">
349
- <p>
350
- <span property="foaf:name">Ivan Herman</span>
351
- </p>
352
- </div>
353
- </body>
354
- </html>
355
- )
356
-
357
- @graph = parse(sampledoc, :validate => true)
358
- @statement = @graph.statements.first
359
- end
360
-
361
- it "should return 1 triple" do
362
- @graph.size.should == 1
363
- end
364
-
365
- it "should have a subject of http://example.org/#me" do
366
- @statement.subject.should == RDF::URI('http://example.org/#me')
367
- end
368
-
369
- it "should have a predicate of foaf:name" do
370
- @statement.predicate.should == RDF::FOAF.name
371
- end
372
-
373
- it "should have an object with the literal 'Ivan Herman'" do
374
- @statement.object.should == RDF::Literal('Ivan Herman')
375
- end
376
- end
377
-
378
- describe "parsing a document with a profile containing a term mapping" do
379
- before :each do
380
- sampledoc = %(<?xml version="1.0" encoding="UTF-8"?>
381
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
382
- <html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.1">
383
- <head>
384
- <title>Test</title>
385
- <base href="http://example.org/"/>
386
- </head>
387
- <body profile="http://rdfa.digitalbazaar.com/test-suite/test-cases/tests/../../profiles/foaf">
388
- <div about="#me">
389
- <p>
390
- <span property="name">Ivan Herman</span>
391
- </p>
392
- </div>
393
- </body>
394
- </html>
395
- )
396
-
397
- @graph = parse(sampledoc, :validate => true)
398
- @statement = @graph.statements.first
399
- end
400
-
401
- it "should return 1 triple" do
402
- @graph.size.should == 1
403
- end
404
-
405
- it "should have a subject of http://example.org/#me" do
406
- @statement.subject.should == RDF::URI('http://example.org/#me')
407
- end
408
-
409
- it "should have a predicate of foaf:name" do
410
- @statement.predicate.should == RDF::FOAF.name
411
- end
412
-
413
- it "should have an object with the literal 'Ivan Herman'" do
414
- @statement.object.should == RDF::Literal('Ivan Herman')
415
- end
416
- end
417
-
418
- describe :profiles do
419
- before(:each) do
420
- @profile = StringIO.new(%q(<?xml version="1.0" encoding="UTF-8"?>
421
- <!DOCTYPE html>
422
- <html xmlns="http://www.w3.org/1999/xhtml">
423
- <head>
424
- <title>Test mappings</title>
425
- </head>
426
- <body prefix="rdfa: http://www.w3.org/ns/rdfa#">
427
- <p typeof=""><span property="rdfa:uri">http://example.org/</span><span property="rdfa:prefix">foo</span></p>
428
- <p typeof=""><span property="rdfa:uri">http://example.org/title</span><span property="rdfa:term">title</span></p>
429
- </body>
430
- </html>
431
- ))
432
- def @profile.content_type; "text/html"; end
433
- def @profile.base_uri; "http://example.com/profile"; end
434
-
435
- @doc = %(<?xml version="1.0" encoding="UTF-8"?>
436
- <!DOCTYPE html>
437
- <html xmlns="http://www.w3.org/1999/xhtml">
438
- <body profile="http://example.com/profile">
439
- <div about="http://example.com/doc" typeof="foo:Agent">
440
- <p property="title">A particular agent</p>
441
- </div>
442
- </body>
443
- </html>
444
- )
445
-
446
- RDF::Util::File.stub!(:open_file).and_yield(@profile)
447
-
448
- @profile_repository = RDF::Repository.new(:title => "Test Profile Repository")
449
- @debug = []
450
- @reader = RDF::RDFa::Reader.new(@doc, :profile_repository => @profile_repository, :debug => @debug, :validate => true)
451
-
452
- @expected = RDF::Graph.new
453
- @expected << [RDF::URI("http://example.com/doc"), RDF.type, RDF::URI("http://example.org/Agent")]
454
- @expected << [RDF::URI("http://example.com/doc"), RDF::URI("http://example.org/title"), "A particular agent"]
455
- end
456
-
457
- it "parses profile" do
458
- RDF::Reader.should_receive(:for).at_least(1).times.and_return(RDF::RDFa::Reader)
459
- g = RDF::Graph.load(@profile)
460
- g.count.should == 4
461
- end
462
-
463
- describe "new profile" do
464
- subject do
465
- # Clear vocabulary cache
466
- RDF::RDFa::Profile.cache.send(:initialize)
467
- RDF::Graph.new << @reader
468
- end
469
-
470
- it "matches expected" do
471
- subject.should be_equivalent_graph(@expected, :trace => @debug.join("\n"))
472
- end
473
- end
474
-
475
- describe "cached profile" do
476
- before(:each) do
477
- # Clear vocabulary cache
478
- RDF::RDFa::Profile.cache.send(:initialize)
479
- @reader.each {|s|}
480
- end
481
-
482
- it "should not re-parse profile" do
483
- RDF::RDFa::Profile.cache.send(:initialize)
484
- RDF::Reader.should_not_receive(:open).with("http://example.com/profile")
485
- RDF::RDFa::Reader.new(@doc, :profile_repository => @profile_repository).each {|p|}
486
- end
487
-
488
- it "should create vocab_cache" do
489
- RDF::RDFa::Profile.cache.should be_a(RDF::Util::Cache)
490
- end
491
- end
492
-
493
- describe "profile content" do
494
- before(:each) do
495
- bn_p = RDF::Node.new("prefix")
496
- bn_t = RDF::Node.new("term")
497
- ctx = RDF::URI("http://example.com/profile")
498
- @profile_repository << RDF::Statement.new(bn_p, RDF::RDFA.prefix, RDF::Literal.new("foo"), :context => ctx)
499
- @profile_repository << RDF::Statement.new(bn_p, RDF::RDFA.uri, RDF::Literal.new("http://example.org/"), :context => ctx)
500
- @profile_repository << RDF::Statement.new(bn_t, RDF::RDFA.term, RDF::Literal.new("title"), :context => ctx)
501
- @profile_repository << RDF::Statement.new(bn_t, RDF::RDFA.uri, RDF::Literal.new("http://example.org/title"), :context => ctx)
502
-
503
- # Clear vocabulary cache
504
- RDF::RDFa::Profile.cache.send(:initialize)
505
- end
506
-
507
- it "should not recieve RDF::Reader.open" do
508
- RDF::Reader.should_not_receive(:open).with("http://example.com/profile")
509
- @reader.each {|s|}
510
- end
511
-
512
- it "matches expected" do
513
- graph = RDF::Graph.new << @reader
514
- graph.should be_equivalent_graph(@expected, :trace => @debug.join("\n"))
515
- end
516
- end
517
- end
518
-
519
- # W3C Test suite from http://www.w3.org/2006/07/SWD/RDFa/testsuite/
520
- describe "w3c test cases" do
521
- require 'test_helper'
522
-
523
- Fixtures::TestCase::HOST_LANGUAGE_VERSION_SETS.each do |(host_language, version)|
524
- describe "for #{host_language} #{version}" do
525
- %w(required optional buggy).each do |classification|
526
- describe "that are #{classification}" do
527
- Fixtures::TestCase.for_specific(host_language, version, Fixtures::TestCase::Test.send(classification)) do |t|
528
- specify "test #{t.name}: #{t.title}#{", (negative test)" if t.expectedResults.false?}" do
529
- begin
530
- t.debug = []
531
- reader = RDF::Reader.open(t.input(host_language, version),
532
- :base_uri => t.input(host_language, version),
533
- :debug => t.debug,
534
- :format => :rdfa)
535
- reader.should be_a RDF::Reader
536
-
537
- # Make sure auto-detect works
538
- unless host_language =~ /svg/ || t.name == "0216" # due to http-equiv
539
- reader.host_language.should == host_language.to_sym
540
- reader.version.should == version.to_sym
541
- end
542
-
543
- graph = RDF::Graph.new << reader
544
- query = Kernel.open(t.results(host_language, version))
545
- graph.should pass_query(query, t)
546
- rescue RSpec::Expectations::ExpectationNotMetError => e
547
- if %w(0198).include?(t.name) || query =~ /XMLLiteral/m
548
- pending("XMLLiteral canonicalization not implemented yet")
549
- elsif classification != "required"
550
- pending("#{classification} test") { raise }
551
- else
552
- raise
553
- end
554
- end
555
- end
556
- end
557
- end
558
- end
559
- end
560
- end
561
- end
562
-
563
- def parse(input, options)
564
- @debug = options[:debug] || []
565
- graph = RDF::Graph.new
566
- RDF::RDFa::Reader.new(input, options.merge(:debug => @debug)).each do |statement|
567
- graph << statement
568
- end
569
- graph
570
- end
571
-
572
- end