earl-report 0.5.3 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,16 @@
1
1
  # coding: utf-8
2
2
  $:.unshift "."
3
3
  require 'spec_helper'
4
+ require 'rdf/rdfa'
4
5
 
5
6
  describe EarlReport do
6
7
  let!(:earl) {
7
8
  EarlReport.new(
8
9
  File.expand_path("../test-files/report-complete.ttl", __FILE__),
9
- :bibRef => "[[TURTLE]]",
10
- :name => "Turtle Test Results",
11
- :verbose => false,
12
- :manifest => File.expand_path("../test-files/manifest.ttl", __FILE__))
10
+ bibRef: "[[TURTLE]]",
11
+ name: "Turtle Test Results",
12
+ verbose: false,
13
+ manifest: File.expand_path("../test-files/manifest.ttl", __FILE__))
13
14
  }
14
15
  subject {earl}
15
16
 
@@ -26,6 +27,9 @@ describe EarlReport do
26
27
  let(:reportNoFoaf) {
27
28
  RDF::Graph.new << RDF::Turtle::Reader.new(File.open File.expand_path("../test-files/report-no-foaf.ttl", __FILE__))
28
29
  }
30
+ let(:reportNoTest) {
31
+ RDF::Graph.new << RDF::Turtle::Reader.new(File.open File.expand_path("../test-files/report-no-test.ttl", __FILE__))
32
+ }
29
33
  let(:doap) {
30
34
  RDF::Graph.new << RDF::Turtle::Reader.new(File.open File.expand_path("../test-files/doap.ttl", __FILE__))
31
35
  }
@@ -47,9 +51,9 @@ describe EarlReport do
47
51
  .and_return(reportComplete)
48
52
  EarlReport.new(
49
53
  File.expand_path("../test-files/report-complete.ttl", __FILE__),
50
- :verbose => false,
51
- :base => "http://example.com/base/",
52
- :manifest => File.expand_path("../test-files/manifest.ttl", __FILE__))
54
+ verbose: false,
55
+ base: "http://example.com/base/",
56
+ manifest: File.expand_path("../test-files/manifest.ttl", __FILE__))
53
57
  end
54
58
  end
55
59
 
@@ -66,8 +70,8 @@ describe EarlReport do
66
70
  subject {
67
71
  EarlReport.new(
68
72
  File.expand_path("../test-files/report-complete.ttl", __FILE__),
69
- :verbose => false,
70
- :manifest => File.expand_path("../test-files/manifest.ttl", __FILE__))
73
+ verbose: false,
74
+ manifest: File.expand_path("../test-files/manifest.ttl", __FILE__))
71
75
  }
72
76
  it "loads manifest" do
73
77
  expect(subject.graph.subjects.to_a).to include(RDF::URI("http://example/manifest.ttl"))
@@ -85,6 +89,18 @@ describe EarlReport do
85
89
  it "loads foaf" do
86
90
  expect(subject.graph.objects.to_a).to include(RDF::Vocab::FOAF.Person)
87
91
  end
92
+
93
+ it "does not raise an error if the strict option is used" do
94
+ expect do
95
+ expect do
96
+ EarlReport.new(
97
+ File.expand_path("../test-files/report-complete.ttl", __FILE__),
98
+ verbose: false,
99
+ strict: true,
100
+ manifest: File.expand_path("../test-files/manifest.ttl", __FILE__))
101
+ end.not_to raise_error
102
+ end.not_to output.to_stderr
103
+ end
88
104
  end
89
105
 
90
106
  context "no doap report" do
@@ -103,8 +119,8 @@ describe EarlReport do
103
119
  subject {
104
120
  EarlReport.new(
105
121
  File.expand_path("../test-files/report-no-doap.ttl", __FILE__),
106
- :verbose => false,
107
- :manifest => File.expand_path("../test-files/manifest.ttl", __FILE__))
122
+ verbose: false,
123
+ manifest: File.expand_path("../test-files/manifest.ttl", __FILE__))
108
124
  }
109
125
  it "loads manifest" do
110
126
  expect(subject.graph.subjects.to_a).to include(RDF::URI("http://example/manifest.ttl"))
@@ -122,6 +138,18 @@ describe EarlReport do
122
138
  it "loads foaf" do
123
139
  expect(subject.graph.objects.to_a).to include(RDF::Vocab::FOAF.Person)
124
140
  end
141
+
142
+ it "does not raise an error if the strict option is used" do
143
+ expect do
144
+ expect do
145
+ EarlReport.new(
146
+ File.expand_path("../test-files/report-no-doap.ttl", __FILE__),
147
+ verbose: false,
148
+ strict: true,
149
+ manifest: File.expand_path("../test-files/manifest.ttl", __FILE__))
150
+ end.not_to raise_error
151
+ end.not_to output.to_stderr
152
+ end
125
153
  end
126
154
 
127
155
  context "no foaf report" do
@@ -140,8 +168,8 @@ describe EarlReport do
140
168
  subject {
141
169
  EarlReport.new(
142
170
  File.expand_path("../test-files/report-no-foaf.ttl", __FILE__),
143
- :verbose => false,
144
- :manifest => File.expand_path("../test-files/manifest.ttl", __FILE__))
171
+ verbose: false,
172
+ manifest: File.expand_path("../test-files/manifest.ttl", __FILE__))
145
173
  }
146
174
  it "loads manifest" do
147
175
  expect(subject.graph.subjects.to_a).to include(RDF::URI("http://example/manifest.ttl"))
@@ -159,6 +187,67 @@ describe EarlReport do
159
187
  it "loads foaf" do
160
188
  expect(subject.graph.objects.to_a).to include(RDF::Vocab::FOAF.Person)
161
189
  end
190
+
191
+ it "does not raise an error if the strict option is used" do
192
+ expect do
193
+ expect do
194
+ EarlReport.new(
195
+ File.expand_path("../test-files/report-no-foaf.ttl", __FILE__),
196
+ verbose: false,
197
+ strict: true,
198
+ manifest: File.expand_path("../test-files/manifest.ttl", __FILE__))
199
+ end.not_to raise_error
200
+ end.not_to output.to_stderr
201
+ end
202
+ end
203
+
204
+ context "asserts a test not in manifest" do
205
+ before(:each) do
206
+ expect(RDF::Graph).to receive(:load)
207
+ .with(File.expand_path("../test-files/manifest.ttl", __FILE__), {unique_bnodes: true, })
208
+ .and_return(manifest)
209
+ expect(RDF::Graph).to receive(:load)
210
+ .with(File.expand_path("../test-files/report-no-test.ttl", __FILE__))
211
+ .and_return(reportNoTest)
212
+ end
213
+
214
+ subject {
215
+ expect do
216
+ @no_test_earl = EarlReport.new(
217
+ File.expand_path("../test-files/report-no-test.ttl", __FILE__),
218
+ verbose: false,
219
+ manifest: File.expand_path("../test-files/manifest.ttl", __FILE__))
220
+ end.to output.to_stderr
221
+ @no_test_earl
222
+ }
223
+ it "loads manifest" do
224
+ expect(subject.graph.subjects.to_a).to include(RDF::URI("http://example/manifest.ttl"))
225
+ expect(subject.graph.subjects.to_a).to include(RDF::URI("http://example/manifest.ttl#testeval00"))
226
+ end
227
+
228
+ it "loads report" do
229
+ expect(subject.graph.predicates.to_a).to include(RDF::URI("http://www.w3.org/ns/earl#generatedBy"))
230
+ end
231
+
232
+ it "loads doap" do
233
+ expect(subject.graph.subjects.to_a).to include(RDF::URI("https://rubygems.org/gems/rdf-turtle"))
234
+ end
235
+
236
+ it "loads foaf" do
237
+ expect(subject.graph.objects.to_a).to include(RDF::Vocab::FOAF.Person)
238
+ end
239
+
240
+ it "raises an error if the strict option is used" do
241
+ expect do
242
+ expect do
243
+ EarlReport.new(
244
+ File.expand_path("../test-files/report-no-test.ttl", __FILE__),
245
+ verbose: false,
246
+ strict: true,
247
+ manifest: File.expand_path("../test-files/manifest.ttl", __FILE__))
248
+ end.to raise_error(RuntimeError)
249
+ end.to output.to_stderr
250
+ end
162
251
  end
163
252
  end
164
253
 
@@ -227,7 +316,7 @@ describe EarlReport do
227
316
  let(:output) {
228
317
  @output ||= begin
229
318
  sio = StringIO.new
230
- earl.send(:earl_turtle, {io: sio})
319
+ earl.send(:earl_turtle, io: sio)
231
320
  sio.rewind
232
321
  sio.read
233
322
  end
@@ -311,6 +400,10 @@ describe EarlReport do
311
400
  end
312
401
  }
313
402
 
403
+ it "is valid HTML" do
404
+ expect(output).to be_valid_html
405
+ end
406
+
314
407
  context "parsing to RDF" do
315
408
  let(:graph) do
316
409
  @graph ||= begin
@@ -383,7 +476,7 @@ describe EarlReport do
383
476
  doap:name "Turtle Test Results";
384
477
  dc:bibliographicCitation "[[TURTLE]]";
385
478
  earl:generatedBy ?generatedBy;
386
- earl:assertions ?assertionFile;
479
+ mf:report ?assertionFile;
387
480
  earl:testSubjects <https://rubygems.org/gems/rdf-turtle>;
388
481
  mf:entries (<http://example/manifest.ttl>) .
389
482
 
@@ -428,8 +521,11 @@ describe EarlReport do
428
521
  <http://example/manifest.ttl#testeval00> a earl:TestCriterion, earl:TestCase;
429
522
  mf:name "subm-test-00";
430
523
  mf:action <http://example/test-00.ttl>;
431
- mf:result <http://example/test-00.out>;
432
- earl:assertions [ a earl:Assertion; earl:subject <https://rubygems.org/gems/rdf-turtle> ] .
524
+ mf:result <http://example/test-00.out>.
525
+ [ a earl:Assertion;
526
+ earl:subject <https://rubygems.org/gems/rdf-turtle>;
527
+ earl:test <http://example/manifest.ttl#testeval00>
528
+ ] .
433
529
  }
434
530
  )
435
531
 
data/spec/spec_helper.rb CHANGED
@@ -4,16 +4,29 @@ $:.unshift File.dirname(__FILE__)
4
4
  require "bundler/setup"
5
5
  require 'rspec'
6
6
  require 'rspec/its'
7
- require 'simplecov'
8
- require 'coveralls'
9
7
  require 'amazing_print'
10
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
11
- SimpleCov::Formatter::HTMLFormatter,
12
- Coveralls::SimpleCov::Formatter
13
- ])
14
- SimpleCov.start do
15
- add_filter "/spec/"
8
+ require 'nokogiri'
9
+
10
+ begin
11
+ require 'simplecov'
12
+ require 'simplecov-lcov'
13
+ SimpleCov::Formatter::LcovFormatter.config do |config|
14
+ #Coveralls is coverage by default/lcov. Send info results
15
+ config.report_with_single_file = true
16
+ config.single_report_path = 'coverage/lcov.info'
17
+ end
18
+
19
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
20
+ SimpleCov::Formatter::HTMLFormatter,
21
+ SimpleCov::Formatter::LcovFormatter
22
+ ])
23
+ SimpleCov.start do
24
+ add_filter "/spec/"
25
+ end
26
+ rescue LoadError => e
27
+ STDERR.puts "Coverage Skipped: #{e.message}"
16
28
  end
29
+
17
30
  require 'earl_report'
18
31
 
19
32
  JSON_STATE = JSON::State.new(
@@ -28,3 +41,15 @@ JSON_STATE = JSON::State.new(
28
41
  c.filter_run :focus => true
29
42
  c.run_all_when_everything_filtered = true
30
43
  end
44
+
45
+ RSpec::Matchers.define :be_valid_html do
46
+ match do |actual|
47
+ root = Nokogiri::HTML5(actual, max_parse_errors: 1000)
48
+ @errors = Array(root && root.errors.map(&:to_s))
49
+ @errors.empty?
50
+ end
51
+
52
+ failure_message do |actual|
53
+ "expected no errors, was #{@errors.join("\n")}"
54
+ end
55
+ end
@@ -0,0 +1,48 @@
1
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
2
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
3
+ @prefix dc: <http://purl.org/dc/terms/> .
4
+ @prefix earl: <http://www.w3.org/ns/earl#> .
5
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
6
+ @prefix doap: <http://usefulinc.com/ns/doap#> .
7
+ @prefix ex: <http://example.org/> .
8
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
9
+
10
+ <https://rubygems.org/gems/rdf-turtle> a doap:Project, earl:TestSubject, earl:Software ;
11
+ doap:name "RDF::Turtle" ;
12
+ doap:homepage <http://ruby-rdf.github.com/rdf-turtle> ;
13
+ doap:license <http://creativecommons.org/publicdomain/zero/1.0/> ;
14
+ doap:shortdesc "Turtle reader/writer for Ruby."@en ;
15
+ doap:description "RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite."@en ;
16
+ doap:created "2011-08-29"^^xsd:date;
17
+ doap:programming-language "Ruby" ;
18
+ doap:implements <http://www.w3.org/TR/turtle/> ;
19
+ doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
20
+ <http://dbpedia.org/resource/Ruby_(programming_language)> ;
21
+ doap:download-page <https://rubygems.org/gems/rdf-turtle> ;
22
+ doap:mailing-list <http://lists.w3.org/Archives/Public/public-rdf-ruby/> ;
23
+ doap:bug-database <https://github.com/ruby-rdf/rdf-turtle/issues> ;
24
+ doap:blog <https://greggkellogg.net/> ;
25
+ doap:developer <https://greggkellogg.net/foaf#me> ;
26
+ doap:maintainer <https://greggkellogg.net/foaf#me> ;
27
+ doap:documenter <https://greggkellogg.net/foaf#me> ;
28
+ foaf:maker <https://greggkellogg.net/foaf#me> ;
29
+ dc:title "RDF::Turtle" ;
30
+ dc:description "RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite."@en ;
31
+ dc:date "2011-08-29"^^xsd:date;
32
+ dc:creator <https://greggkellogg.net/foaf#me>;
33
+ dc:isPartOf <https://rubygems.org/gems/rdf> .
34
+
35
+ <https://greggkellogg.net/foaf#me> a foaf:Person, earl:Assertor;
36
+ foaf:name "Gregg Kellogg";
37
+ foaf:title "Implementor";
38
+ foaf:homepage <https://greggkellogg.net/> .
39
+
40
+ [ a earl:Assertion;
41
+ earl:assertedBy <https://greggkellogg.net/foaf#me>;
42
+ earl:subject <https://rubygems.org/gems/rdf-turtle>;
43
+ earl:test <http://example/manifest.ttl#notest>;
44
+ earl:result [
45
+ a earl:TestResult;
46
+ earl:outcome earl:passed;
47
+ dc:date "2012-11-06T19:23:29-08:00"^^xsd:dateTime];
48
+ earl:mode earl:automatic ] .
@@ -73,8 +73,8 @@ Implementation Report
73
73
  <h2 id='w3c-document-28-october-2015'>
74
74
  <abbr title='World Wide Web Consortium'>W3C</abbr>
75
75
  Document
76
- <time class='dt-published' datetime='2021-03-18' property='dc:issued'>
77
- 18 March 2021
76
+ <time class='dt-published' datetime='2021-12-18' property='dc:issued'>
77
+ 18 December 2021
78
78
  </time>
79
79
  </h2>
80
80
  <dl>
@@ -105,7 +105,7 @@ rules apply.
105
105
  </p>
106
106
  <hr />
107
107
  </div>
108
- <section about='' id='abstract' typeof='doap:Project Software'>
108
+ <section about='' id='abstract' typeof='Software doap:Project'>
109
109
  <h2>Abstract</h2>
110
110
  <p>
111
111
  This document report test subject conformance for and related specifications for
@@ -231,7 +231,7 @@ Report Generation Software
231
231
  <span class='secno'>2.</span>
232
232
  Test Manifests
233
233
  </h2>
234
- <section id='Description-for-Example-Test-Cases' resource='http://example/manifest.ttl' typeof='mf:Manifest Report'>
234
+ <section id='Description-for-Example-Test-Cases' resource='http://example/manifest.ttl' typeof='Report mf:Manifest'>
235
235
  <h2>
236
236
  <span class='secno'>2.1</span>
237
237
  <span property='dc:title mf:name'>Example Test Cases</span>
@@ -245,11 +245,11 @@ Test
245
245
  <a href='#subj_0'>RDF::Turtle</a>
246
246
  </th>
247
247
  </tr>
248
- <tr inlist='inlist' rel='mf:entries' resource='http://example/manifest.ttl#testeval00' typeof='http://www.w3.org/ns/rdftest#TestTurtleEval TestCriterion TestCase'>
248
+ <tr inlist='inlist' rel='mf:entries' resource='http://example/manifest.ttl#testeval00' typeof='TestCriterion http://www.w3.org/ns/rdftest#TestTurtleEval TestCase'>
249
249
  <td>
250
250
  <a href='#test_1fdd82ac4caf30510cabfdb0a5987ddd'>subm-test-00</a>
251
251
  </td>
252
- <td class='PASS' property='earl:assertions' typeof='Assertion'>
252
+ <td class='PASS' typeof='Assertion'>
253
253
  <link href='https://greggkellogg.net/foaf#me' property='earl:assertedBy' />
254
254
  <link href='http://example/manifest.ttl#testeval00' property='earl:test' />
255
255
  <link href='https://rubygems.org/gems/rdf-turtle' property='earl:subject' />
@@ -261,11 +261,11 @@ PASS
261
261
  </span>
262
262
  </td>
263
263
  </tr>
264
- <tr inlist='inlist' rel='mf:entries' resource='_:b0' typeof='http://www.w3.org/ns/rdftest#TestTurtleEval TestCriterion TestCase'>
264
+ <tr inlist='inlist' rel='mf:entries' resource='_:b1' typeof='TestCriterion http://www.w3.org/ns/rdftest#TestTurtleEval TestCase'>
265
265
  <td>
266
- <a href='#test_9616fad74c7bf0cfba5d70f087ed0a96'>subm-test-01</a>
266
+ <a href='#test_b4d4f9531721bf1a6e4562f27353abd3'>subm-test-01</a>
267
267
  </td>
268
- <td class='UNTESTED' property='earl:assertions' typeof='Assertion'>
268
+ <td class='UNTESTED' typeof='Assertion'>
269
269
  <link href='https://rubygems.org/gems/rdf-turtle' property='earl:subject' />
270
270
  <span property='earl:result' typeof='TestResult'>
271
271
  <span property='earl:outcome' resource='earl:untested'>
@@ -300,7 +300,7 @@ This report was tested using the following test subjects:
300
300
  <span about='https://rubygems.org/gems/rdf-turtle' property='doap:name'>RDF::Turtle</span>
301
301
  </a>
302
302
  </dt>
303
- <dd property='earl:testSubjects' resource='https://rubygems.org/gems/rdf-turtle' typeof='doap:Project Software TestSubject'>
303
+ <dd property='earl:testSubjects' resource='https://rubygems.org/gems/rdf-turtle' typeof='Software doap:Project TestSubject'>
304
304
  <dl>
305
305
  <dt>Description</dt>
306
306
  <dd lang='en' property='doap:description'>RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite.</dd>
@@ -346,7 +346,7 @@ Example Test Cases
346
346
  </dd>
347
347
  </dl>
348
348
  </section>
349
- <section class='appendix' id='individual-test-results' rel='xhv:related earl:assertions'>
349
+ <section class='appendix' id='individual-test-results' rel='xhv:related mf:report'>
350
350
  <h2>
351
351
  <span class='secno'>B.</span>
352
352
  Individual Test Results
@@ -376,11 +376,11 @@ Test
376
376
  <pre class='example actionDoc' property='mf:action' resource='http://example/test-00.ttl' title='subm-test-00 Input'>http://example/test-00.ttl not loaded</pre>
377
377
  <pre class='example resultDoc' property='mf:result' resource='http://example/test-00.out' title='subm-test-00 Result'>http://example/test-00.out not loaded</pre>
378
378
  </dd>
379
- <dt id='test_9616fad74c7bf0cfba5d70f087ed0a96' resource='_:b0'>
379
+ <dt id='test_b4d4f9531721bf1a6e4562f27353abd3' resource='_:b1'>
380
380
  Test
381
381
  <span property='dc:title mf:name'>subm-test-01</span>
382
382
  </dt>
383
- <dd resource='_:b0'>
383
+ <dd resource='_:b1'>
384
384
  <p property='dc:description rdfs:comment'></p>
385
385
  <pre class='example actionDoc' property='mf:action' resource='http://example/test-01.ttl' title='subm-test-01 Input'>http://example/test-01.ttl not loaded</pre>
386
386
  <pre class='example resultDoc' property='mf:result' resource='http://example/test-01.out' title='subm-test-01 Result'>http://example/test-01.out not loaded</pre>
@@ -388,7 +388,7 @@ Test
388
388
  </div>
389
389
  </dl>
390
390
  </section>
391
- <section class='appendix' id='report-generation-software' property='earl:generatedBy' resource='https://rubygems.org/gems/earl-report' typeof='doap:Project Software'>
391
+ <section class='appendix' id='report-generation-software' property='earl:generatedBy' resource='https://rubygems.org/gems/earl-report' typeof='Software doap:Project'>
392
392
  <h2>
393
393
  <span class='secno'>D.</span>
394
394
  Report Generation Software
@@ -399,9 +399,9 @@ This report generated by
399
399
  <meta content='Earl Report summary generator' property='doap:shortdesc' />
400
400
  <meta content='EarlReport generates HTML+RDFa rollups of multiple EARL reports' property='doap:description' />
401
401
  version
402
- <span property='doap:release' resource='https://github.com/gkellogg/earl-report/tree/0.5.2' typeof='doap:Version'>
403
- <span property='doap:revision'>0.5.2</span>
404
- <meta content='earl-report-0.5.2' property='doap:name' />
402
+ <span property='doap:release' resource='https://github.com/gkellogg/earl-report/tree/0.7.0' typeof='doap:Version'>
403
+ <span property='doap:revision'>0.7.0</span>
404
+ <meta content='earl-report-0.7.0' property='doap:name' />
405
405
  </span>
406
406
  an
407
407
  <a href='http://unlicense.org' property='doap:license'>Unlicensed</a>