rdf-spec 1.1.13 → 1.99.0
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rdf/spec.rb +1 -0
- data/lib/rdf/spec/countable.rb +11 -11
- data/lib/rdf/spec/durable.rb +6 -6
- data/lib/rdf/spec/enumerable.rb +170 -148
- data/lib/rdf/spec/format.rb +3 -3
- data/lib/rdf/spec/http_adapter.rb +28 -6
- data/lib/rdf/spec/indexable.rb +6 -8
- data/lib/rdf/spec/inferable.rb +1 -1
- data/lib/rdf/spec/inspects.rb +71 -0
- data/lib/rdf/spec/literal.rb +7 -6
- data/lib/rdf/spec/matchers.rb +21 -0
- data/lib/rdf/spec/mutable.rb +85 -73
- data/lib/rdf/spec/queryable.rb +73 -41
- data/lib/rdf/spec/reader.rb +20 -20
- data/lib/rdf/spec/transaction.rb +24 -13
- data/lib/rdf/spec/writable.rb +97 -63
- data/lib/rdf/spec/writer.rb +18 -18
- data/spec/spec_helper.rb +2 -2
- data/spec/version_spec.rb +1 -1
- metadata +6 -5
data/lib/rdf/spec/writable.rb
CHANGED
@@ -2,114 +2,148 @@ require 'rdf/spec'
|
|
2
2
|
|
3
3
|
RSpec.shared_examples 'an RDF::Writable' do
|
4
4
|
include RDF::Spec::Matchers
|
5
|
+
let(:filename) {RDF::Spec::TRIPLES_FILE}
|
6
|
+
let(:statements) {RDF::NTriples::Reader.new(File.open(filename)).to_a}
|
7
|
+
let(:supports_graph_name) {writable.respond_to?(:supports?) && writable.supports?(:graph_name)}
|
5
8
|
|
6
9
|
before :each do
|
7
10
|
raise 'writable must be defined in with let(:readable)' unless
|
8
11
|
defined? writable
|
9
|
-
|
10
|
-
@filename = RDF::Spec::TRIPLES_FILE
|
11
|
-
@statements = RDF::NTriples::Reader.new(File.open(@filename)).to_a
|
12
|
-
|
13
|
-
@supports_context = writable.respond_to?(:supports?) && writable.supports?(:context)
|
14
12
|
end
|
15
13
|
|
16
14
|
subject { writable }
|
17
|
-
let(:statement) {
|
18
|
-
let(:count) {
|
15
|
+
let(:statement) {statements.detect {|s| s.to_a.all? {|r| r.uri?}}}
|
16
|
+
let(:count) {statements.size}
|
19
17
|
|
20
|
-
it {
|
21
|
-
its(:writable?) {
|
18
|
+
it {is_expected.to respond_to(:writable?)}
|
19
|
+
its(:writable?) {is_expected.to eq !!subject.writable?}
|
22
20
|
|
23
21
|
describe "#<<" do
|
24
22
|
it "inserts a reader" do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
if subject.writable?
|
24
|
+
reader = RDF::NTriples::Reader.new(File.open(filename)).to_a
|
25
|
+
subject << reader
|
26
|
+
is_expected.to have_statement(statement)
|
27
|
+
expect(subject.count).to eq count
|
28
|
+
end
|
30
29
|
end
|
31
30
|
|
32
31
|
it "inserts a graph" do
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
if subject.writable?
|
33
|
+
graph = RDF::Graph.new << statements
|
34
|
+
subject << graph
|
35
|
+
is_expected.to have_statement(statement)
|
36
|
+
expect(subject.count).to eq count
|
37
|
+
end
|
38
38
|
end
|
39
39
|
|
40
40
|
it "inserts an enumerable" do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
if subject.writable?
|
42
|
+
enumerable = statements.dup.extend(RDF::Enumerable)
|
43
|
+
subject << enumerable
|
44
|
+
is_expected.to have_statement(statement)
|
45
|
+
expect(subject.count).to eq count
|
46
|
+
end
|
46
47
|
end
|
47
48
|
|
48
49
|
it "inserts data responding to #to_rdf" do
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
if subject.writable?
|
51
|
+
mock = double('mock')
|
52
|
+
allow(mock).to receive(:to_rdf).and_return(statements)
|
53
|
+
subject << mock
|
54
|
+
is_expected.to have_statement(statement)
|
55
|
+
expect(subject.count).to eq count
|
56
|
+
end
|
55
57
|
end
|
56
58
|
|
57
59
|
it "inserts a statement" do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
if subject.writable?
|
61
|
+
subject << statement
|
62
|
+
is_expected.to have_statement(statement)
|
63
|
+
expect(subject.count).to eq 1
|
64
|
+
end
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|
65
68
|
context "when inserting statements" do
|
66
69
|
it "should support #insert" do
|
67
|
-
|
68
|
-
expect(subject).to respond_to(:insert)
|
70
|
+
is_expected.to respond_to(:insert) if subject.writable?
|
69
71
|
end
|
70
72
|
|
71
73
|
it "should not raise errors" do
|
72
|
-
|
73
|
-
expect { subject.insert(statement) }.not_to raise_error
|
74
|
+
expect { subject.insert(statement) }.not_to raise_error if subject.writable?
|
74
75
|
end
|
75
76
|
|
76
77
|
it "should support inserting one statement at a time" do
|
77
|
-
|
78
|
-
|
79
|
-
|
78
|
+
if subject.writable?
|
79
|
+
subject.insert(statement)
|
80
|
+
is_expected.to have_statement(statement)
|
81
|
+
end
|
80
82
|
end
|
81
83
|
|
82
84
|
it "should support inserting multiple statements at a time" do
|
83
|
-
|
84
|
-
|
85
|
+
if subject.writable?
|
86
|
+
subject.insert(*statements)
|
87
|
+
statements.each do |statement|
|
88
|
+
is_expected.to have_statement(statement) unless statement.to_a.any?(&:node?)
|
89
|
+
end
|
90
|
+
end
|
85
91
|
end
|
86
92
|
|
87
93
|
it "should insert statements successfully" do
|
88
|
-
|
89
|
-
|
90
|
-
|
94
|
+
if subject.writable?
|
95
|
+
subject.insert(*statements)
|
96
|
+
expect(subject.count).to eq count
|
97
|
+
end
|
91
98
|
end
|
92
99
|
|
93
100
|
it "should not insert a statement twice" do
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
101
|
+
if subject.writable?
|
102
|
+
subject.insert(statement)
|
103
|
+
subject.insert(statement)
|
104
|
+
expect(subject.count).to eq 1
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should not insert an incomplete statement" do
|
109
|
+
if subject.writable?
|
110
|
+
expect {subject.insert(RDF::Statement.from(statement.to_hash.merge(subject: nil)))}.to raise_error(ArgumentError)
|
111
|
+
expect {subject.insert(RDF::Statement.from(statement.to_hash.merge(predicate: nil)))}.to raise_error(ArgumentError)
|
112
|
+
expect {subject.insert(RDF::Statement.from(statement.to_hash.merge(object: nil)))}.to raise_error(ArgumentError)
|
113
|
+
expect(subject.count).to eql 0
|
114
|
+
end
|
98
115
|
end
|
99
116
|
|
100
|
-
it "should treat statements with a different context as distinct" do
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
117
|
+
it "should treat statements with a different context as distinct", unless: RDF::VERSION.to_s >= "1.99" do
|
118
|
+
if subject.writable?
|
119
|
+
s1 = statement.dup
|
120
|
+
s1.context = nil
|
121
|
+
s2 = statement.dup
|
122
|
+
s2.context = RDF::URI.new("urn:context:1")
|
123
|
+
s3 = statement.dup
|
124
|
+
s3.context = RDF::URI.new("urn:context:2")
|
125
|
+
subject.insert(s1)
|
126
|
+
subject.insert(s2)
|
127
|
+
subject.insert(s3)
|
128
|
+
# If contexts are not suported, all three are redundant
|
129
|
+
expect(subject.count).to eq (supports_graph_name ? 3 : 1)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should treat statements with a different graph_name as distinct", if: RDF::VERSION.to_s >= "1.99" do
|
134
|
+
if subject.writable?
|
135
|
+
s1 = statement.dup
|
136
|
+
s1.graph_name = nil
|
137
|
+
s2 = statement.dup
|
138
|
+
s2.graph_name = RDF::URI.new("urn:context:1")
|
139
|
+
s3 = statement.dup
|
140
|
+
s3.graph_name = RDF::URI.new("urn:context:2")
|
141
|
+
subject.insert(s1)
|
142
|
+
subject.insert(s2)
|
143
|
+
subject.insert(s3)
|
144
|
+
# If graph_names are not suported, all three are redundant
|
145
|
+
expect(subject.count).to eq (supports_graph_name ? 3 : 1)
|
146
|
+
end
|
113
147
|
end
|
114
148
|
end
|
115
149
|
end
|
data/lib/rdf/spec/writer.rb
CHANGED
@@ -3,7 +3,7 @@ require 'fileutils'
|
|
3
3
|
require 'tmpdir'
|
4
4
|
|
5
5
|
RSpec.shared_examples 'an RDF::Writer' do
|
6
|
-
|
6
|
+
include RDF::Spec::Matchers
|
7
7
|
|
8
8
|
before(:each) do
|
9
9
|
raise 'writer must be defined with let(:writer)' unless
|
@@ -44,7 +44,7 @@ RSpec.shared_examples 'an RDF::Writer' do
|
|
44
44
|
f.file_extensions.each_pair do |sym, content_type|
|
45
45
|
writer_mock = double("writer")
|
46
46
|
expect(writer_mock).to receive(:got_here)
|
47
|
-
expect(writer_class).to receive(:for).with(:
|
47
|
+
expect(writer_class).to receive(:for).with(file_name: "#{@basename}.#{sym}").and_return(writer_class)
|
48
48
|
writer_class.open("#{@basename}.#{sym}") do |r|
|
49
49
|
expect(r).to be_a(RDF::Writer)
|
50
50
|
writer_mock.got_here
|
@@ -59,20 +59,20 @@ RSpec.shared_examples 'an RDF::Writer' do
|
|
59
59
|
writer_mock = double("writer")
|
60
60
|
expect(writer_mock).to receive(:got_here)
|
61
61
|
expect(writer_class).to receive(:for).with(sym).and_return(writer_class)
|
62
|
-
writer_class.open("#{@basename}.#{sym}", :
|
62
|
+
writer_class.open("#{@basename}.#{sym}", format: sym) do |r|
|
63
63
|
expect(r).to be_a(RDF::Writer)
|
64
64
|
writer_mock.got_here
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
it "yields writer given {:
|
69
|
+
it "yields writer given {file_name: file_name}" do
|
70
70
|
writer_class.format.each do |f|
|
71
71
|
f.file_extensions.each_pair do |sym, content_type|
|
72
72
|
writer_mock = double("writer")
|
73
73
|
expect(writer_mock).to receive(:got_here)
|
74
|
-
expect(writer_class).to receive(:for).with(:
|
75
|
-
writer_class.open("#{@basename}.#{sym}", :
|
74
|
+
expect(writer_class).to receive(:for).with(file_name: "#{@basename}.#{sym}").and_return(writer_class)
|
75
|
+
writer_class.open("#{@basename}.#{sym}", file_name: "#{@basename}.#{sym}") do |r|
|
76
76
|
expect(r).to be_a(RDF::Writer)
|
77
77
|
writer_mock.got_here
|
78
78
|
end
|
@@ -80,13 +80,13 @@ RSpec.shared_examples 'an RDF::Writer' do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
it "yields writer given {:
|
83
|
+
it "yields writer given {content_type: 'a/b'}" do
|
84
84
|
writer_class.format.each do |f|
|
85
85
|
f.content_types.each_pair do |content_type, formats|
|
86
86
|
writer_mock = double("writer")
|
87
87
|
expect(writer_mock).to receive(:got_here)
|
88
|
-
expect(writer_class).to receive(:for).with(:
|
89
|
-
writer_class.open(@basename, :
|
88
|
+
expect(writer_class).to receive(:for).with(content_type: content_type, file_name: @basename).and_return(writer_class)
|
89
|
+
writer_class.open(@basename, content_type: content_type) do |r|
|
90
90
|
expect(r).to be_a(RDF::Writer)
|
91
91
|
writer_mock.got_here
|
92
92
|
end
|
@@ -125,19 +125,19 @@ RSpec.shared_examples 'an RDF::Writer' do
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
it "sets prefixes given :
|
128
|
+
it "sets prefixes given prefixes: {}" do
|
129
129
|
writer_mock = double("writer")
|
130
130
|
expect(writer_mock).to receive(:got_here)
|
131
|
-
writer_class.new(StringIO.new, :
|
131
|
+
writer_class.new(StringIO.new, prefixes: {a: "b"}) do |r|
|
132
132
|
writer_mock.got_here
|
133
|
-
expect(r.prefixes).to eq({:
|
133
|
+
expect(r.prefixes).to eq({a: "b"})
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
137
|
#it "calls #write_prologue" do
|
138
138
|
# writer_mock = double("writer")
|
139
|
-
# writer_mock.
|
140
|
-
# writer_class.any_instance.
|
139
|
+
# writer_mock.is_expected.to_receive(:got_here)
|
140
|
+
# writer_class.any_instance.is_expected.to_receive(:write_prologue)
|
141
141
|
# writer_class.new(StringIO.new) do |r|
|
142
142
|
# writer_mock.got_here
|
143
143
|
# end
|
@@ -145,8 +145,8 @@ RSpec.shared_examples 'an RDF::Writer' do
|
|
145
145
|
#
|
146
146
|
#it "calls #write_epilogue" do
|
147
147
|
# writer_mock = double("writer")
|
148
|
-
# writer_mock.
|
149
|
-
# writer_class.any_instance.
|
148
|
+
# writer_mock.is_expected.to_receive(:got_here)
|
149
|
+
# writer_class.any_instance.is_expected.to_receive(:write_epilogue)
|
150
150
|
# writer_class.new(StringIO.new) do |r|
|
151
151
|
# writer_mock.got_here
|
152
152
|
# end
|
@@ -155,8 +155,8 @@ RSpec.shared_examples 'an RDF::Writer' do
|
|
155
155
|
|
156
156
|
describe "#prefixes=" do
|
157
157
|
it "sets prefixes from hash" do
|
158
|
-
writer.prefixes = {:
|
159
|
-
expect(writer.prefixes).to eq({:
|
158
|
+
writer.prefixes = {a: "b"}
|
159
|
+
expect(writer.prefixes).to eq({a: "b"})
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
data/spec/spec_helper.rb
CHANGED
@@ -5,9 +5,9 @@ require 'rdf/spec/matchers'
|
|
5
5
|
|
6
6
|
RSpec.configure do |config|
|
7
7
|
config.include(RDF::Spec::Matchers)
|
8
|
-
config.filter_run :
|
8
|
+
config.filter_run focus: true
|
9
9
|
config.run_all_when_everything_filtered = true
|
10
|
-
config.exclusion_filter = {:
|
10
|
+
config.exclusion_filter = {ruby: lambda { |version|
|
11
11
|
RUBY_VERSION.to_s !~ /^#{version}/
|
12
12
|
}}
|
13
13
|
end
|
data/spec/version_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
2
|
|
3
3
|
describe 'RDF::Spec::VERSION' do
|
4
|
-
it "
|
4
|
+
it "is_expected.to match the VERSION file" do
|
5
5
|
expect(RDF::Spec::VERSION.to_s).to eq File.read(File.join(File.dirname(__FILE__), '..', 'VERSION')).chomp
|
6
6
|
end
|
7
7
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.99.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arto Bendiken
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rdf
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
21
|
+
version: '1.99'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '1.
|
28
|
+
version: '1.99'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rspec
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/rdf/spec/http_adapter.rb
|
110
110
|
- lib/rdf/spec/indexable.rb
|
111
111
|
- lib/rdf/spec/inferable.rb
|
112
|
+
- lib/rdf/spec/inspects.rb
|
112
113
|
- lib/rdf/spec/literal.rb
|
113
114
|
- lib/rdf/spec/matchers.rb
|
114
115
|
- lib/rdf/spec/mutable.rb
|
@@ -142,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
145
|
rubyforge_project: rdf
|
145
|
-
rubygems_version: 2.4.
|
146
|
+
rubygems_version: 2.4.5.1
|
146
147
|
signing_key:
|
147
148
|
specification_version: 4
|
148
149
|
summary: RSpec extensions for RDF.rb.
|