earl-report 0.5.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@
10
10
  -# "assertions": ["./rdf.rb-earl.ttl"],
11
11
  -# "testSubjects": [
12
12
  -# {
13
- -# "@id": "http://rubygems.org/gems/rdf-turtle",
13
+ -# "@id": "https://rubygems.org/gems/rdf-turtle",
14
14
  -# "@type": "earl:TestSubject",
15
15
  -# "name": "RDF::Turtle"
16
16
  -# },
@@ -27,9 +27,9 @@
27
27
  -# "assertions": [
28
28
  -# {
29
29
  -# "@type": "earl:Assertion",
30
- -# "assertedBy": "http://greggkellogg.net/foaf#me",
30
+ -# "assertedBy": "https://greggkellogg.net/foaf#me",
31
31
  -# "test": "http://svn.apache.org/repos/asf/jena/Experimental/riot-reader/testing/RIOT/Lang/TurtleSubm/manifest.ttl#testeval00",
32
- -# "subject": "http://rubygems.org/gems/rdf-turtle",
32
+ -# "subject": "https://rubygems.org/gems/rdf-turtle",
33
33
  -# "result": {
34
34
  -# "@type": "earl:TestResult",
35
35
  -# "outcome": "earl:passed"
@@ -40,8 +40,8 @@
40
40
  -# }
41
41
  - require 'cgi'
42
42
  - require 'digest'
43
- - editors = [{ name: "Gregg Kellogg", url: "http://greggkellogg.net/"}]
44
- - foaf = {name: "Gregg Kellogg", url: "http://greggkellogg.net/foaf#me" }
43
+ - editors = [{ name: "Gregg Kellogg", url: "https://greggkellogg.net/"}]
44
+ - foaf = {name: "Gregg Kellogg", url: "https://greggkellogg.net/foaf#me" }
45
45
 
46
46
  !!! 5
47
47
  %html
@@ -333,7 +333,7 @@
333
333
  - assertion = test['assertions'].detect {|a| a['subject'] == subject['@id']}
334
334
  - pass_fail = assertion['result']['outcome'].split(':').last.upcase.sub(/(PASS|FAIL)ED$/, '\1')
335
335
  - passed_tests[ndx2][ndx] = (passed_tests[ndx2][ndx] || 0) + (pass_fail == 'PASS' ? 1 : 0)
336
- %td{class: pass_fail, property: "earl:assertions", typeof: assertion['@type']}
336
+ %td{class: pass_fail, typeof: assertion['@type']}
337
337
  - if assertion['assertedBy'] && !assertion['assertedBy'].start_with?('_:')
338
338
  %link{property: "earl:assertedBy", href: assertion['assertedBy']}
339
339
  - if assertion['test'] && !assertion['test'].start_with?('_:')
@@ -418,7 +418,7 @@
418
418
  %td{class: (pct == 100.0 ? 'passed-all' : (pct >= 85.0 ? 'passed-most' : 'passed-some'))}
419
419
  = "#{passed}/#{total} (#{'%.1f' % pct}%)"
420
420
  - unless tests['assertions'].empty?
421
- %section.appendix#individual-test-results{rel: "xhv:related earl:assertions"}
421
+ %section.appendix#individual-test-results{rel: "xhv:related mf:report"}
422
422
  %h2
423
423
  %span.secno="B."
424
424
  Individual Test Results
@@ -474,9 +474,9 @@
474
474
  application. More information is available at
475
475
  %a{property: "doap:homepage", href: doap['homepage']}<=doap['homepage']
476
476
  = "."
477
- %p{property: "doap:developer", resource: "http://greggkellogg.net/foaf#me", typeof: "foaf:Person"}
477
+ %p{property: "doap:developer", resource: "https://greggkellogg.net/foaf#me", typeof: "foaf:Person"}
478
478
  This software is provided by
479
- %a{property: "foaf:homepage", href: "http://greggkellogg.net/"}<
480
- %span{about: "http://greggkellogg.net/foaf#me", property: "foaf:name"}<
479
+ %a{property: "foaf:homepage", href: "https://greggkellogg.net/"}<
480
+ %span{about: "https://greggkellogg.net/foaf#me", property: "foaf:name"}<
481
481
  Gregg Kellogg
482
482
  in hopes that it might make the lives of conformance testers easier.
@@ -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"))
@@ -79,12 +83,24 @@ describe EarlReport do
79
83
  end
80
84
 
81
85
  it "loads doap" do
82
- expect(subject.graph.subjects.to_a).to include(RDF::URI("http://rubygems.org/gems/rdf-turtle"))
86
+ expect(subject.graph.subjects.to_a).to include(RDF::URI("https://rubygems.org/gems/rdf-turtle"))
83
87
  end
84
88
 
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
@@ -96,15 +112,15 @@ describe EarlReport do
96
112
  .with(File.expand_path("../test-files/report-no-doap.ttl", __FILE__))
97
113
  .and_return(reportNoDoap)
98
114
  expect(RDF::Graph).to receive(:load)
99
- .with("http://rubygems.org/gems/rdf-turtle")
115
+ .with("https://rubygems.org/gems/rdf-turtle")
100
116
  .and_return(doap)
101
117
  end
102
118
 
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"))
@@ -116,12 +132,24 @@ describe EarlReport do
116
132
  end
117
133
 
118
134
  it "loads doap" do
119
- expect(subject.graph.subjects.to_a).to include(RDF::URI("http://rubygems.org/gems/rdf-turtle"))
135
+ expect(subject.graph.subjects.to_a).to include(RDF::URI("https://rubygems.org/gems/rdf-turtle"))
120
136
  end
121
137
 
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
@@ -133,15 +161,15 @@ describe EarlReport do
133
161
  .with(File.expand_path("../test-files/report-no-foaf.ttl", __FILE__))
134
162
  .and_return(reportNoFoaf)
135
163
  expect(RDF::Graph).to receive(:load)
136
- .with("http://greggkellogg.net/foaf#me")
164
+ .with("https://greggkellogg.net/foaf#me")
137
165
  .and_return(foaf)
138
166
  end
139
167
 
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"))
@@ -153,12 +181,73 @@ describe EarlReport do
153
181
  end
154
182
 
155
183
  it "loads doap" do
156
- expect(subject.graph.subjects.to_a).to include(RDF::URI("http://rubygems.org/gems/rdf-turtle"))
184
+ expect(subject.graph.subjects.to_a).to include(RDF::URI("https://rubygems.org/gems/rdf-turtle"))
157
185
  end
158
186
 
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
@@ -240,7 +329,7 @@ describe EarlReport do
240
329
 
241
330
  context "prefixes" do
242
331
  %w(dc doap earl foaf mf rdf rdfs xsd).each do |pfx|
243
- specify {is_expected.to match(/@prefix #{pfx}: </)}
332
+ specify {is_expected.to match(/@prefix #{pfx}:\s+</)}
244
333
  end
245
334
  end
246
335
 
@@ -264,7 +353,7 @@ describe EarlReport do
264
353
  end
265
354
 
266
355
  context "Assertion" do
267
- specify {is_expected.to match(/\sa earl:Assertion;$/)}
356
+ specify {is_expected.to match(/\sa earl:Assertion\s*;$/)}
268
357
  end
269
358
 
270
359
  context "parsing to RDF" do
@@ -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,8 +476,8 @@ describe EarlReport do
383
476
  doap:name "Turtle Test Results";
384
477
  dc:bibliographicCitation "[[TURTLE]]";
385
478
  earl:generatedBy ?generatedBy;
386
- earl:assertions ?assertionFile;
387
- earl:testSubjects <http://rubygems.org/gems/rdf-turtle>;
479
+ mf:report ?assertionFile;
480
+ earl:testSubjects <https://rubygems.org/gems/rdf-turtle>;
388
481
  mf:entries (<http://example/manifest.ttl>) .
389
482
 
390
483
  <http://example/manifest.ttl> a earl:Report, mf:Manifest;
@@ -401,11 +494,11 @@ describe EarlReport do
401
494
  PREFIX earl: <http://www.w3.org/ns/earl#>
402
495
 
403
496
  ASK WHERE {
404
- <http://rubygems.org/gems/rdf-turtle> a earl:TestSubject, doap:Project;
497
+ <https://rubygems.org/gems/rdf-turtle> a earl:TestSubject, doap:Project;
405
498
  doap:name "RDF::Turtle";
406
499
  doap:description """RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite."""@en;
407
500
  doap:programming-language "Ruby";
408
- doap:developer <http://greggkellogg.net/foaf#me> .
501
+ doap:developer <https://greggkellogg.net/foaf#me> .
409
502
  }
410
503
  )
411
504
 
@@ -413,9 +506,9 @@ describe EarlReport do
413
506
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
414
507
 
415
508
  ASK WHERE {
416
- <http://greggkellogg.net/foaf#me> a foaf:Person;
509
+ <https://greggkellogg.net/foaf#me> a foaf:Person;
417
510
  foaf:name "Gregg Kellogg";
418
- foaf:homepage <http://greggkellogg.net/> .
511
+ foaf:homepage <https://greggkellogg.net/> .
419
512
  }
420
513
  )
421
514
 
@@ -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 <http://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
 
@@ -438,9 +534,9 @@ describe EarlReport do
438
534
 
439
535
  ASK WHERE {
440
536
  [ a earl:Assertion;
441
- earl:assertedBy <http://greggkellogg.net/foaf#me>;
537
+ earl:assertedBy <https://greggkellogg.net/foaf#me>;
442
538
  earl:test <http://example/manifest.ttl#testeval00>;
443
- earl:subject <http://rubygems.org/gems/rdf-turtle>;
539
+ earl:subject <https://rubygems.org/gems/rdf-turtle>;
444
540
  earl:mode earl:automatic;
445
541
  earl:result [ a earl:TestResult; earl:outcome earl:passed] ] .
446
542
  }
data/spec/spec_helper.rb CHANGED
@@ -4,16 +4,23 @@ $:.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
- require 'awesome_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/"
7
+ require 'amazing_print'
8
+ require 'nokogumbo'
9
+
10
+ begin
11
+ require 'simplecov'
12
+ require 'coveralls'
13
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
14
+ SimpleCov::Formatter::HTMLFormatter,
15
+ Coveralls::SimpleCov::Formatter
16
+ ])
17
+ SimpleCov.start do
18
+ add_filter "/spec/"
19
+ end
20
+ rescue LoadError => e
21
+ STDERR.puts "Coverage Skipped: #{e.message}"
16
22
  end
23
+
17
24
  require 'earl_report'
18
25
 
19
26
  JSON_STATE = JSON::State.new(
@@ -28,3 +35,15 @@ JSON_STATE = JSON::State.new(
28
35
  c.filter_run :focus => true
29
36
  c.run_all_when_everything_filtered = true
30
37
  end
38
+
39
+ RSpec::Matchers.define :be_valid_html do
40
+ match do |actual|
41
+ root = Nokogiri::HTML5(actual, max_parse_errors: 1000)
42
+ @errors = Array(root && root.errors.map(&:to_s))
43
+ @errors.empty?
44
+ end
45
+
46
+ failure_message do |actual|
47
+ "expected no errors, was #{@errors.join("\n")}"
48
+ end
49
+ end
@@ -7,10 +7,10 @@
7
7
  @prefix ex: <http://example.org/> .
8
8
  @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
9
9
 
10
- <http://rubygems.org/gems/rdf-turtle> a doap:Project, earl:TestSubject, earl:Software ;
10
+ <https://rubygems.org/gems/rdf-turtle> a doap:Project, earl:TestSubject, earl:Software ;
11
11
  doap:name "RDF::Turtle" ;
12
12
  doap:homepage <http://ruby-rdf.github.com/rdf-turtle> ;
13
- doap:license <http://creativecommons.org/licenses/publicdomain/> ;
13
+ doap:license <http://creativecommons.org/publicdomain/zero/1.0/> ;
14
14
  doap:shortdesc "Turtle reader/writer for Ruby."@en ;
15
15
  doap:description "RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite."@en ;
16
16
  doap:created "2011-08-29"^^xsd:date;
@@ -18,16 +18,16 @@
18
18
  doap:implements <http://www.w3.org/TR/turtle/> ;
19
19
  doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
20
20
  <http://dbpedia.org/resource/Ruby_(programming_language)> ;
21
- doap:download-page <http://rubygems.org/gems/rdf-turtle> ;
21
+ doap:download-page <https://rubygems.org/gems/rdf-turtle> ;
22
22
  doap:mailing-list <http://lists.w3.org/Archives/Public/public-rdf-ruby/> ;
23
- doap:bug-database <http://github.com/ruby-rdf/rdf-turtle/issues> ;
24
- doap:blog <http://greggkellogg.net/> ;
25
- doap:developer <http://greggkellogg.net/foaf#me> ;
26
- doap:maintainer <http://greggkellogg.net/foaf#me> ;
27
- doap:documenter <http://greggkellogg.net/foaf#me> ;
28
- foaf:maker <http://greggkellogg.net/foaf#me> ;
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
29
  dc:title "RDF::Turtle" ;
30
30
  dc:description "RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite."@en ;
31
31
  dc:date "2011-08-29"^^xsd:date;
32
- dc:creator <http://greggkellogg.net/foaf#me>;
33
- dc:isPartOf <http://rubygems.org/gems/rdf> .
32
+ dc:creator <https://greggkellogg.net/foaf#me>;
33
+ dc:isPartOf <https://rubygems.org/gems/rdf> .