earl-report 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/VERSION +1 -1
- data/bin/earl-report +3 -6
- data/lib/earl_report.rb +114 -61
- data/lib/earl_report/views/earl_report.html.haml +113 -51
- data/spec/earl_report_spec.rb +181 -186
- data/spec/test-files/results.html +123 -79
- data/spec/test-files/results.jsonld +65 -48
- data/spec/test-files/results.ttl +18 -10
- metadata +3 -3
data/spec/earl_report_spec.rb
CHANGED
@@ -3,7 +3,7 @@ $:.unshift "."
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe EarlReport do
|
6
|
-
|
6
|
+
let!(:earl) {
|
7
7
|
EarlReport.new(
|
8
8
|
File.expand_path("../test-files/report-complete.ttl", __FILE__),
|
9
9
|
:bibRef => "[[TURTLE]]",
|
@@ -11,6 +11,7 @@ describe EarlReport do
|
|
11
11
|
:verbose => false,
|
12
12
|
:manifest => File.expand_path("../test-files/manifest.ttl", __FILE__))
|
13
13
|
}
|
14
|
+
subject {earl}
|
14
15
|
|
15
16
|
describe ".new" do
|
16
17
|
let(:manifest) {
|
@@ -33,7 +34,7 @@ describe EarlReport do
|
|
33
34
|
}
|
34
35
|
|
35
36
|
it "requires a :manifest option" do
|
36
|
-
lambda {EarlReport.new}.should raise_error("Test
|
37
|
+
lambda {EarlReport.new}.should raise_error("Test Manifests must be specified with :manifest option")
|
37
38
|
end
|
38
39
|
|
39
40
|
context "with base" do
|
@@ -162,28 +163,25 @@ describe EarlReport do
|
|
162
163
|
end
|
163
164
|
|
164
165
|
describe "#json_hash" do
|
165
|
-
let(:json) {
|
166
|
-
|
167
|
-
}
|
168
|
-
specify {json.should be_a(Hash)}
|
166
|
+
let(:json) {earl.send(:json_hash)}
|
167
|
+
subject {json}
|
168
|
+
it {should be_a(Hash)}
|
169
169
|
{
|
170
170
|
"@id" => "",
|
171
|
-
"@type" => "earl:
|
171
|
+
"@type" => ["earl:Software", "doap:Project"],
|
172
172
|
'bibRef' => "[[TURTLE]]",
|
173
|
-
'
|
173
|
+
'name' => "Turtle Test Results"
|
174
174
|
}.each do |prop, value|
|
175
|
-
specify(prop) {
|
175
|
+
specify(prop) {subject[prop].should == value}
|
176
176
|
end
|
177
177
|
|
178
|
-
%w(assertions generatedBy testSubjects
|
179
|
-
|
178
|
+
%w(assertions generatedBy testSubjects entries).each do |key|
|
179
|
+
its(:keys) {should include(key)}
|
180
180
|
end
|
181
181
|
|
182
182
|
context "parsing to RDF" do
|
183
|
-
let(:graph) do
|
184
|
-
|
185
|
-
RDF::Graph.new << JSON::LD::Reader.new(json.to_json, :base_uri => "http://example.com/report")
|
186
|
-
end
|
183
|
+
let!(:graph) do
|
184
|
+
RDF::Graph.new << JSON::LD::Reader.new(subject.to_json, :base_uri => "http://example.com/report")
|
187
185
|
end
|
188
186
|
|
189
187
|
it "has Report" do
|
@@ -209,9 +207,10 @@ describe EarlReport do
|
|
209
207
|
end
|
210
208
|
|
211
209
|
describe "#json_test_subject_info" do
|
212
|
-
let(:json) {
|
213
|
-
|
214
|
-
|
210
|
+
let(:json) {earl.send(:json_test_subject_info)}
|
211
|
+
subject {json}
|
212
|
+
it {should be_a(Array)}
|
213
|
+
its(:length) {should == 1}
|
215
214
|
|
216
215
|
context "test subject" do
|
217
216
|
let(:ts) {json.first}
|
@@ -240,51 +239,67 @@ describe EarlReport do
|
|
240
239
|
end
|
241
240
|
end
|
242
241
|
end
|
243
|
-
|
242
|
+
|
244
243
|
describe "#json_result_info" do
|
245
|
-
let(:json) {
|
246
|
-
|
247
|
-
|
244
|
+
let(:json) {earl.send(:json_result_info)}
|
245
|
+
subject {json}
|
246
|
+
it {should be_a(Array)}
|
247
|
+
its(:length) {should == 1}
|
248
248
|
|
249
|
-
context
|
250
|
-
let(:
|
249
|
+
context 'entries' do
|
250
|
+
let(:ts) {json.first}
|
251
251
|
{
|
252
|
-
"@id"
|
253
|
-
"@type" =>
|
254
|
-
title:
|
255
|
-
description: "Blank subject",
|
256
|
-
testAction: "http://example/test-00.ttl",
|
257
|
-
testResult: "http://example/test-00.out",
|
252
|
+
"@id" => "http://example/manifest.ttl",
|
253
|
+
"@type" => %w(earl:Report mf:Manifest),
|
254
|
+
title: "Example Test Cases"
|
258
255
|
}.each do |prop, value|
|
259
|
-
specify(prop) {
|
256
|
+
specify(prop) {ts[prop.to_s].should == value}
|
260
257
|
end
|
261
258
|
|
262
|
-
|
263
|
-
|
264
|
-
specify('has one entry') { tc['assertions'].length.should == 1}
|
259
|
+
it "should have two entries" do
|
260
|
+
ts['entries'].length.should == 2
|
265
261
|
end
|
266
262
|
|
267
|
-
context "
|
268
|
-
let(:
|
269
|
-
specify {as.should be_a(Hash)}
|
263
|
+
context "test case" do
|
264
|
+
let(:tc) {ts['entries'].first}
|
270
265
|
{
|
271
|
-
"@
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
266
|
+
"@id" => "http://example/manifest.ttl#testeval00",
|
267
|
+
"@type" => %w(earl:TestCriterion earl:TestCase http://www.w3.org/ns/rdftest#TestTurtleEval),
|
268
|
+
title: "subm-test-00",
|
269
|
+
description: "Blank subject",
|
270
|
+
testAction: "http://example/test-00.ttl",
|
271
|
+
testResult: "http://example/test-00.out",
|
276
272
|
}.each do |prop, value|
|
277
|
-
specify(prop) {
|
273
|
+
specify(prop) {tc[prop.to_s].should == value}
|
274
|
+
end
|
275
|
+
|
276
|
+
context('assertions') do
|
277
|
+
specify { tc['assertions'].should be_a(Array)}
|
278
|
+
specify('has one entry') { tc['assertions'].length.should == 1}
|
278
279
|
end
|
279
280
|
|
280
|
-
context "
|
281
|
-
let(:
|
282
|
-
specify {
|
281
|
+
context "assertion" do
|
282
|
+
let(:as) {tc['assertions'].first}
|
283
|
+
specify {as.should be_a(Hash)}
|
283
284
|
{
|
284
|
-
"@type" => %(earl:
|
285
|
-
|
285
|
+
"@type" => %(earl:Assertion),
|
286
|
+
assertedBy: "http://greggkellogg.net/foaf#me",
|
287
|
+
mode: "earl:automatic",
|
288
|
+
subject: "http://rubygems.org/gems/rdf-turtle",
|
289
|
+
test: "http://example/manifest.ttl#testeval00",
|
286
290
|
}.each do |prop, value|
|
287
|
-
specify(prop) {
|
291
|
+
specify(prop) {as[prop.to_s].should == value}
|
292
|
+
end
|
293
|
+
|
294
|
+
context "result" do
|
295
|
+
let(:rs) {as['result']}
|
296
|
+
specify {rs.should be_a(Hash)}
|
297
|
+
{
|
298
|
+
"@type" => %(earl:TestResult),
|
299
|
+
outcome: "earl:passed",
|
300
|
+
}.each do |prop, value|
|
301
|
+
specify(prop) {rs[prop.to_s].should == value}
|
302
|
+
end
|
288
303
|
end
|
289
304
|
end
|
290
305
|
end
|
@@ -292,176 +307,152 @@ describe EarlReport do
|
|
292
307
|
end
|
293
308
|
|
294
309
|
describe "#test_subject_turtle" do
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
'
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
ttl.should match(/ doap:programming-language "#{desc['language']}"\s*[;\.]$/)
|
325
|
-
end
|
326
|
-
it "has doap:developer" do
|
327
|
-
ttl.should match(/ doap:developer <#{desc['developer']['@id']}>/)
|
328
|
-
end
|
329
|
-
|
330
|
-
context "developer" do
|
331
|
-
let(:dev) {desc['developer']}
|
332
|
-
it "has subject subject" do
|
333
|
-
ttl.should match(/<#{dev['@id']}> a/)
|
334
|
-
end
|
335
|
-
it "has types" do
|
336
|
-
ttl.should match(/ a #{dev['@type'].join(', ')}\s*[;\.]$/)
|
337
|
-
end
|
338
|
-
it "has name" do
|
339
|
-
ttl.should match(/ foaf:name "#{dev['foaf:name']}"\s*[;\.]$/)
|
340
|
-
end
|
341
|
-
end
|
310
|
+
let(:desc) {{
|
311
|
+
"@id" => "http://rubygems.org/gems/rdf-turtle",
|
312
|
+
"@type" => %w(earl:TestSubject doap:Project),
|
313
|
+
'doapDesc' => "RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite.",
|
314
|
+
'homepage' => "http://ruby-rdf.github.com/rdf-turtle",
|
315
|
+
'language' => "Ruby",
|
316
|
+
'name' => "RDF::Turtle",
|
317
|
+
'developer' => {
|
318
|
+
'@id' => "http://greggkellogg.net/foaf#me",
|
319
|
+
'@type' => %w(foaf:Person earl:Assertor),
|
320
|
+
'foaf:name' => "Gregg Kellogg"
|
321
|
+
}
|
322
|
+
}}
|
323
|
+
let(:ttl) {earl.send(:test_subject_turtle, desc)}
|
324
|
+
subject {ttl}
|
325
|
+
|
326
|
+
its(:length) {should > 0}
|
327
|
+
specify {should match(/<#{desc['@id']}> a/)}
|
328
|
+
specify {should match(/ a #{desc['@type'].join(', ')}\s*[;\.]$/)}
|
329
|
+
specify {should match(/ doap:name "#{desc['name']}"\s*[;\.]$/)}
|
330
|
+
specify {should match(/ doap:description """#{desc['doapDesc']}"""@en\s*[;\.]$/)}
|
331
|
+
specify {should match(/ doap:programming-language "#{desc['language']}"\s*[;\.]$/)}
|
332
|
+
specify {should match(/ doap:developer <#{desc['developer']['@id']}>/)}
|
333
|
+
|
334
|
+
context "developer" do
|
335
|
+
let(:dev) {desc['developer']}
|
336
|
+
specify {should match(/<#{dev['@id']}> a/)}
|
337
|
+
specify {should match(/ a #{dev['@type'].join(', ')}\s*[;\.]$/)}
|
338
|
+
specify {should match(/ foaf:name "#{dev['foaf:name']}"\s*[;\.]$/)}
|
342
339
|
end
|
343
340
|
end
|
344
341
|
|
345
342
|
describe "#tc_turtle" do
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
'assertedBy' =>"http://greggkellogg.net/foaf#me",
|
357
|
-
'mode' => "earl:automatic",
|
358
|
-
'subject' => "http://rubygems.org/gems/rdf-turtle",
|
359
|
-
'test' => "http://example/manifest.ttl#testeval00",
|
360
|
-
'result' => {
|
361
|
-
"@type" => %(earl:TestResult),
|
362
|
-
'outcome' => "earl:passed",
|
363
|
-
}
|
364
|
-
}]
|
365
|
-
}}
|
366
|
-
let(:ttl) {subject.send(:tc_turtle, tc)}
|
367
|
-
specify {ttl.length.should > 0}
|
368
|
-
it "has subject subject" do
|
369
|
-
ttl.should match(/<#{tc['@id']}> a/)
|
370
|
-
end
|
371
|
-
it "has types" do
|
372
|
-
ttl.should match(/ a #{tc['@type'].join(', ')}\s*[;\.]$/)
|
373
|
-
end
|
374
|
-
it "has dc:title" do
|
375
|
-
ttl.should match(/ dc:title "#{tc['title']}"\s*[;\.]$/)
|
376
|
-
end
|
377
|
-
it "has dc:description" do
|
378
|
-
ttl.should match(/ dc:description """#{tc['description']}"""@en\s*[;\.]$/)
|
379
|
-
end
|
380
|
-
it "has mf:action" do
|
381
|
-
ttl.should match(/ mf:action <#{tc['testAction']}>\s*[;\.]$/)
|
382
|
-
end
|
383
|
-
it "has mf:result" do
|
384
|
-
ttl.should match(/ mf:result <#{tc['testResult']}>\s*[;\.]$/)
|
385
|
-
end
|
386
|
-
it "has earl:assertions" do
|
387
|
-
ttl.should match(/ earl:assertions \(\s*\[ a earl:Assertion/m)
|
388
|
-
end
|
389
|
-
end
|
390
|
-
end
|
391
|
-
|
392
|
-
describe "#as_turtle" do
|
393
|
-
context "assertion" do
|
394
|
-
let(:as) {{
|
395
|
-
"@type" => %w(earl:Assertion),
|
396
|
-
'assertedBy' => "http://greggkellogg.net/foaf#me",
|
343
|
+
let(:tc) {{
|
344
|
+
"@id" => "http://example/manifest.ttl#testeval00",
|
345
|
+
"@type" => %w(earl:TestCriterion earl:TestCase),
|
346
|
+
'title' => "subm-test-00",
|
347
|
+
'description' => "Blank subject",
|
348
|
+
'testAction' => "http://example/test-00.ttl",
|
349
|
+
'testResult' => "http://example/test-00.out",
|
350
|
+
'assertions' => [{
|
351
|
+
"@type" => %(earl:Assertion),
|
352
|
+
'assertedBy' =>"http://greggkellogg.net/foaf#me",
|
397
353
|
'mode' => "earl:automatic",
|
398
354
|
'subject' => "http://rubygems.org/gems/rdf-turtle",
|
399
355
|
'test' => "http://example/manifest.ttl#testeval00",
|
400
356
|
'result' => {
|
401
|
-
|
402
|
-
'outcome' =>
|
357
|
+
"@type" => %(earl:TestResult),
|
358
|
+
'outcome' => "earl:passed",
|
403
359
|
}
|
404
|
-
}
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
360
|
+
}]
|
361
|
+
}}
|
362
|
+
let(:ttl) {earl.send(:tc_turtle, tc)}
|
363
|
+
subject {ttl}
|
364
|
+
its(:length) {should > 0}
|
365
|
+
specify {should match(/<#{tc['@id']}> a/)}
|
366
|
+
specify {should match(/ a #{tc['@type'].join(', ')}\s*[;\.]$/)}
|
367
|
+
specify {should match(/ dc:title "#{tc['title']}"\s*[;\.]$/)}
|
368
|
+
specify {should match(/ dc:description """#{tc['description']}"""@en\s*[;\.]$/)}
|
369
|
+
specify {should match(/ mf:action <#{tc['testAction']}>\s*[;\.]$/)}
|
370
|
+
specify {should match(/ mf:result <#{tc['testResult']}>\s*[;\.]$/)}
|
371
|
+
specify {should match(/ earl:assertions \(\s*\[ a earl:Assertion/m)}
|
372
|
+
end
|
373
|
+
|
374
|
+
describe "#as_turtle" do
|
375
|
+
let(:as) {{
|
376
|
+
"@type" => %w(earl:Assertion),
|
377
|
+
'assertedBy' => "http://greggkellogg.net/foaf#me",
|
378
|
+
'mode' => "earl:automatic",
|
379
|
+
'subject' => "http://rubygems.org/gems/rdf-turtle",
|
380
|
+
'test' => "http://example/manifest.ttl#testeval00",
|
381
|
+
'result' => {
|
382
|
+
'@type' => 'earl:TestResult',
|
383
|
+
'outcome' => 'earl:passed'
|
384
|
+
}
|
385
|
+
}}
|
386
|
+
let(:ttl) {earl.send(:as_turtle, as)}
|
387
|
+
subject {ttl}
|
388
|
+
its(:length) {should > 0}
|
389
|
+
specify {should match(/ a #{as['@type'].join(', ')}\s*[;\.]$/)}
|
390
|
+
specify {should match(/ earl:assertedBy <#{as['assertedBy']}>\s*[;\.]$/)}
|
391
|
+
specify {should match(/ earl:test <#{as['test']}>\s*[;\.]$/)}
|
392
|
+
specify {should match(/ earl:subject <#{as['subject']}>\s*[;\.]$/)}
|
393
|
+
specify {should match(/ earl:mode #{as['mode']}\s*[;\.]$/)}
|
394
|
+
specify {should match(/ earl:result \[ a #{as['result']['@type']}; earl:outcome #{as['result']['outcome']} \]\]/)}
|
395
|
+
it "has type" do
|
396
|
+
ttl.should match(/ a #{as['@type'].join(', ')}\s*[;\.]$/)
|
397
|
+
end
|
398
|
+
it "has earl:assertedBy" do
|
399
|
+
ttl.should match(/ earl:assertedBy <#{as['assertedBy']}>\s*[;\.]$/)
|
400
|
+
end
|
401
|
+
it "has earl:test" do
|
402
|
+
ttl.should match(/ earl:test <#{as['test']}>\s*[;\.]$/)
|
403
|
+
end
|
404
|
+
it "has earl:subject" do
|
405
|
+
ttl.should match(/ earl:subject <#{as['subject']}>\s*[;\.]$/)
|
406
|
+
end
|
407
|
+
it "has earl:mode" do
|
408
|
+
ttl.should match(/ earl:mode #{as['mode']}\s*[;\.]$/)
|
409
|
+
end
|
410
|
+
it "has earl:result" do
|
411
|
+
ttl.should match(/ earl:result \[ a #{as['result']['@type']}; earl:outcome #{as['result']['outcome']} \]\]/)
|
425
412
|
end
|
426
413
|
end
|
427
414
|
|
428
415
|
describe "#earl_turtle" do
|
429
|
-
let(:json_hash) {
|
416
|
+
let(:json_hash) {earl.send(:json_hash)}
|
430
417
|
let(:output) {
|
431
418
|
@output ||= begin
|
432
419
|
sio = StringIO.new
|
433
|
-
|
420
|
+
earl.send(:earl_turtle, {io: sio})
|
434
421
|
sio.rewind
|
435
422
|
sio.read
|
436
423
|
end
|
437
424
|
}
|
425
|
+
subject {output}
|
438
426
|
let(:ts) {json_hash['testSubjects'].first}
|
439
|
-
let(:
|
427
|
+
let(:tm) {json_hash['entries'].first}
|
428
|
+
let(:tc) {tm['entries'].first}
|
440
429
|
let(:as) {tc['assertions'].first}
|
441
430
|
|
442
431
|
context "prefixes" do
|
443
432
|
%w(dc doap earl foaf mf owl rdf rdfs xsd).each do |pfx|
|
444
|
-
|
445
|
-
output.should match(/@prefix #{pfx}: </)
|
446
|
-
end
|
433
|
+
specify {should match(/@prefix #{pfx}: </)}
|
447
434
|
end
|
448
435
|
end
|
449
436
|
|
450
437
|
context "earl:Software" do
|
451
|
-
specify {
|
452
|
-
specify {
|
438
|
+
specify {should match(/<> a earl:Software, doap:Project\s*[;\.]$/)}
|
439
|
+
specify {should match(/ doap:name "#{json_hash['name']}"\s*[;\.]$/)}
|
453
440
|
end
|
454
441
|
|
455
442
|
context "Subject Definitions" do
|
456
|
-
specify {
|
443
|
+
specify {should match(/<#{ts['@id']}> a #{ts['@type'].join(', ')}\s*[;\.]$/)}
|
444
|
+
end
|
445
|
+
|
446
|
+
context "Manifest Definitions" do
|
447
|
+
specify {should match(/<#{tm['@id']}> a #{tm['@type'].join(', ')}\s*[;\.]$/)}
|
457
448
|
end
|
458
449
|
|
459
450
|
context "Test Case Definitions" do
|
460
|
-
specify {
|
451
|
+
specify {should match(/<#{tc['@id']}> a #{tc['@type'].join(', ')}\s*[;\.]$/)}
|
461
452
|
end
|
462
453
|
|
463
454
|
context "Assertion" do
|
464
|
-
specify {
|
455
|
+
specify {should match(/\[ a #{as['@type']}\s*[;\.]$/)}
|
465
456
|
end
|
466
457
|
|
467
458
|
context "parsing to RDF" do
|
@@ -533,15 +524,19 @@ describe EarlReport do
|
|
533
524
|
PREFIX dc: <http://purl.org/dc/terms/>
|
534
525
|
PREFIX doap: <http://usefulinc.com/ns/doap#>
|
535
526
|
PREFIX earl: <http://www.w3.org/ns/earl#>
|
536
|
-
|
527
|
+
PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>
|
528
|
+
|
537
529
|
ASK WHERE {
|
538
|
-
?uri a earl:
|
539
|
-
|
530
|
+
?uri a earl:Software, doap:Project;
|
531
|
+
doap:name "Turtle Test Results";
|
540
532
|
dc:bibliographicCitation "[[TURTLE]]";
|
541
533
|
earl:generatedBy ?generatedBy;
|
542
534
|
earl:assertions ?assertionFile;
|
543
535
|
earl:testSubjects (<http://rubygems.org/gems/rdf-turtle>);
|
544
|
-
|
536
|
+
mf:entries (<http://example/manifest.ttl>) .
|
537
|
+
|
538
|
+
<http://example/manifest.ttl> a earl:Report, mf:Manifest;
|
539
|
+
mf:entries (
|
545
540
|
<http://example/manifest.ttl#testeval00>
|
546
541
|
?test01
|
547
542
|
) .
|
@@ -578,7 +573,7 @@ describe EarlReport do
|
|
578
573
|
|
579
574
|
ASK WHERE {
|
580
575
|
<http://example/manifest.ttl#testeval00> a earl:TestCriterion, earl:TestCase;
|
581
|
-
dc:title "subm-test-00";
|
576
|
+
#dc:title "subm-test-00";
|
582
577
|
dc:description """Blank subject"""@en;
|
583
578
|
mf:action <http://example/test-00.ttl>;
|
584
579
|
mf:result <http://example/test-00.out>;
|