rdf-tabular 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/spec/suite_helper.rb CHANGED
@@ -93,6 +93,7 @@ module Fixtures
93
93
 
94
94
  class Entry < JSON::LD::Resource
95
95
  attr_accessor :debug
96
+ attr_accessor :warnings
96
97
  attr_accessor :metadata
97
98
 
98
99
  def id
@@ -140,6 +141,10 @@ module Fixtures
140
141
  type.include?("Validation")
141
142
  end
142
143
 
144
+ def warning?
145
+ type.include?("Warning")
146
+ end
147
+
143
148
  def positive_test?
144
149
  !negative_test?
145
150
  end
data/spec/suite_spec.rb CHANGED
@@ -18,53 +18,67 @@ describe RDF::Tabular::Reader do
18
18
  m.entries.each do |t|
19
19
  specify "#{t.id.split("/").last}: #{t.name} - #{t.comment}" do
20
20
  t.debug = []
21
- RDF::Tabular::Reader.open(t.action,
22
- t.reader_options.merge(
23
- base_uri: t.base,
24
- validate: t.validation?,
25
- debug: t.debug
26
- )
27
- ) do |reader|
28
- expect(reader).to be_a RDF::Reader
21
+ t.warnings = []
22
+ begin
23
+ RDF::Tabular::Reader.open(t.action,
24
+ t.reader_options.merge(
25
+ base_uri: t.base,
26
+ validate: t.validation?,
27
+ debug: t.debug,
28
+ warnings: t.warnings
29
+ )
30
+ ) do |reader|
31
+ expect(reader).to be_a RDF::Reader
29
32
 
30
- t.metadata = reader.metadata # for debug output
31
- t.metadata = t.metadata.parent if t.metadata && t.metadata.parent
33
+ t.metadata = reader.metadata # for debug output
34
+ t.metadata = t.metadata.parent if t.metadata && t.metadata.parent
32
35
 
33
- graph = RDF::Repository.new
36
+ graph = RDF::Repository.new
34
37
 
35
- if t.positive_test?
36
- if t.json?
37
- result = reader.to_json
38
- if t.evaluate?
39
- RDF::Util::File.open_file(t.result) do |res|
40
- expect(::JSON.parse(result)).to produce(::JSON.parse(res.read), t)
38
+ if t.positive_test?
39
+ if t.json?
40
+ result = reader.to_json
41
+ if t.evaluate?
42
+ RDF::Util::File.open_file(t.result) do |res|
43
+ expect(::JSON.parse(result)).to produce(::JSON.parse(res.read), t)
44
+ end
45
+ else
46
+ expect(::JSON.parse(result)).to be_a(Hash)
47
+ end
48
+ else # RDF or Validation
49
+ begin
50
+ graph << reader
51
+ rescue Exception => e
52
+ expect(e.message).to produce("Not exception #{e.inspect}\n#{e.backtrace.join("\n")}", t.debug)
41
53
  end
42
- else
43
- expect(::JSON.parse(result)).to be_a(Hash)
44
- end
45
- else # RDF or Validation
46
- begin
47
- graph << reader
48
- rescue Exception => e
49
- expect(e.message).to produce("Not exception #{e.inspect}\n#{e.backtrace.join("\n")}", t.debug)
50
- end
51
54
 
52
- if t.sparql?
53
- RDF::Util::File.open_file(t.result) do |query|
54
- expect(graph).to pass_query(query, t)
55
+ if t.sparql?
56
+ RDF::Util::File.open_file(t.result) do |query|
57
+ expect(graph).to pass_query(query, t)
58
+ end
59
+ elsif t.evaluate?
60
+ output_graph = RDF::Repository.load(t.result, format: :ttl, base_uri: t.base)
61
+ expect(graph).to be_equivalent_graph(output_graph, t)
62
+ elsif t.validation?
63
+ expect(graph).to be_a(RDF::Enumerable)
64
+
65
+ if t.warning?
66
+ expect(t.warnings.length).to produce 1, t
67
+ else
68
+ expect(t.warnings).to produce [], t
69
+ end
55
70
  end
56
- elsif t.evaluate?
57
- output_graph = RDF::Repository.load(t.result, format: :ttl, base_uri: t.base)
58
- expect(graph).to be_equivalent_graph(output_graph, t)
59
- else
60
- expect(graph).to be_a(RDF::Enumerable)
61
71
  end
72
+ else
73
+ expect {
74
+ graph << reader
75
+ expect(graph.dump(:ntriples)).to produce("not this", t.debug)
76
+ }.to raise_error(RDF::Tabular::Error)
62
77
  end
63
- else
64
- expect {
65
- graph << reader
66
- expect(graph.dump(:ntriples)).to produce("not this", t.debug)
67
- }.to raise_error(RDF::Tabular::Error)
78
+ end
79
+ rescue Exception => e
80
+ unless t.negative_test? && t.validation?
81
+ raise
68
82
  end
69
83
  end
70
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-tabular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-11 00:00:00.000000000 Z
11
+ date: 2015-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcp47