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/queryable.rb
CHANGED
@@ -30,7 +30,7 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
30
30
|
##
|
31
31
|
# @see RDF::Queryable#query
|
32
32
|
describe "#query" do
|
33
|
-
it {
|
33
|
+
it {is_expected.to respond_to(:query)}
|
34
34
|
|
35
35
|
context "when called" do
|
36
36
|
it "requires an argument" do
|
@@ -63,7 +63,7 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "does not alter a given hash argument" do
|
66
|
-
query = {:
|
66
|
+
query = {subject: resource, predicate: RDF::URI("http://usefulinc.com/ns/doap#name"), object: RDF::URI("http://xmlns.com/foaf/0.1/Person")}
|
67
67
|
original_query = query.dup
|
68
68
|
subject.query(query)
|
69
69
|
expect(query).to eq original_query
|
@@ -83,8 +83,8 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it "calls #query_pattern" do
|
86
|
-
|
87
|
-
|
86
|
+
is_expected.to receive(:query_pattern)
|
87
|
+
is_expected.not_to receive(:query_execute)
|
88
88
|
subject.query([:s, :p, :o]) {}
|
89
89
|
end
|
90
90
|
end
|
@@ -98,8 +98,8 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
it "calls #query_execute" do
|
101
|
-
|
102
|
-
|
101
|
+
is_expected.to receive(:query_execute)
|
102
|
+
is_expected.not_to receive(:query_pattern)
|
103
103
|
subject.query(query) {}
|
104
104
|
end
|
105
105
|
end
|
@@ -107,15 +107,11 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
107
107
|
|
108
108
|
context "without a block" do
|
109
109
|
context "with a triple argument" do
|
110
|
-
it "returns an
|
111
|
-
expect(subject.query([nil, nil, nil])).to be_an_enumerator
|
112
|
-
end
|
113
|
-
|
114
|
-
it "returns an enumerable enumerator" do
|
110
|
+
it "returns an enumerable" do
|
115
111
|
expect(subject.query([nil, nil, nil])).to be_enumerable
|
116
112
|
end
|
117
113
|
|
118
|
-
it "returns a queryable
|
114
|
+
it "returns a queryable" do
|
119
115
|
expect(subject.query([nil, nil, nil])).to be_queryable
|
120
116
|
end
|
121
117
|
|
@@ -151,15 +147,15 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
151
147
|
expect(subject.query([nil, nil, nil]).size).to eq @statements.size
|
152
148
|
expect(subject.query([resource, nil, nil]).size).to eq File.readlines(@doap).grep(/^<http:\/\/rubygems\.org\/gems\/rdf>/).size
|
153
149
|
expect(subject.query([RDF::URI("http://ar.to/#self"), nil, nil]).size).to eq File.readlines(@doap).grep(/^<http:\/\/ar.to\/\#self>/).size
|
154
|
-
expect(subject.query([resource, RDF::
|
155
|
-
expect(subject.query([nil, nil, RDF::
|
150
|
+
expect(subject.query([resource, RDF::URI("http://usefulinc.com/ns/doap#name"), nil]).size).to eq 1
|
151
|
+
expect(subject.query([nil, nil, RDF::URI("http://usefulinc.com/ns/doap#Project")]).size).to eq 1
|
156
152
|
end
|
157
153
|
|
158
154
|
it "returns the correct number of results for hash queries" do
|
159
155
|
expect(subject.query({}).size).to eq @statements.size
|
160
|
-
expect(subject.query(:
|
161
|
-
expect(subject.query(:
|
162
|
-
expect(subject.query(:
|
156
|
+
expect(subject.query(subject: resource).size).to eq File.readlines(@doap).grep(/^<http:\/\/rubygems\.org\/gems\/rdf>/).size
|
157
|
+
expect(subject.query(subject: resource, predicate: RDF::URI("http://usefulinc.com/ns/doap#name")).size).to eq 1
|
158
|
+
expect(subject.query(object: RDF::URI("http://usefulinc.com/ns/doap#Project")).size).to eq 1
|
163
159
|
end
|
164
160
|
|
165
161
|
it "returns the correct number of results for query queries" do
|
@@ -171,13 +167,13 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
171
167
|
context "with specific patterns from SPARQL" do
|
172
168
|
context "triple pattern combinations" do
|
173
169
|
it "?s p o" do
|
174
|
-
expect(subject.query(:
|
170
|
+
expect(subject.query(predicate: RDF::URI("http://example.org/p"), object: RDF::Literal.new(1)).to_a).to(
|
175
171
|
include *[RDF::Statement.new(RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1), RDF::Statement.new(RDF::URI("http://example.org/xi2"), RDF::URI("http://example.org/p"), 1)]
|
176
172
|
)
|
177
173
|
end
|
178
174
|
|
179
175
|
it "s ?p o" do
|
180
|
-
expect(subject.query(:
|
176
|
+
expect(subject.query(subject: RDF::URI("http://example.org/xi2"), object: RDF::Literal.new(1)).to_a).to(
|
181
177
|
include *[RDF::Statement.new(RDF::URI("http://example.org/xi2"), RDF::URI("http://example.org/p"), 1)]
|
182
178
|
)
|
183
179
|
end
|
@@ -187,8 +183,8 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
187
183
|
context "data/r2/expr-equals" do
|
188
184
|
context "graph-1" do
|
189
185
|
let(:result) do
|
190
|
-
queryable.query(:
|
191
|
-
:
|
186
|
+
queryable.query(predicate: RDF::URI("http://example.org/p"),
|
187
|
+
object: RDF::Literal::Integer.new(1)).to_a
|
192
188
|
end
|
193
189
|
|
194
190
|
it 'has two solutions' do
|
@@ -206,8 +202,8 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
206
202
|
|
207
203
|
context "graph-2" do
|
208
204
|
let(:result) do
|
209
|
-
queryable.query(:
|
210
|
-
:
|
205
|
+
queryable.query(predicate: RDF::URI("http://example.org/p"),
|
206
|
+
object: RDF::Literal::Double.new("1.0e0"))
|
211
207
|
.to_a
|
212
208
|
end
|
213
209
|
|
@@ -289,16 +285,16 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
289
285
|
end
|
290
286
|
end
|
291
287
|
|
292
|
-
context "with context" do
|
288
|
+
context "with context", unless: RDF::VERSION.to_s >= "1.99" do
|
293
289
|
it "returns statements from all contexts with no context" do
|
294
|
-
pattern = RDF::Query::Pattern.new(nil, nil, nil, :
|
290
|
+
pattern = RDF::Query::Pattern.new(nil, nil, nil, context: nil)
|
295
291
|
solutions = []
|
296
292
|
subject.send(:query_pattern, pattern) {|s| solutions << s}
|
297
293
|
expect(solutions.size).to eq @statements.size
|
298
294
|
end
|
299
295
|
|
300
296
|
it "returns statements from unnamed contexts with false context" do
|
301
|
-
pattern = RDF::Query::Pattern.new(nil, nil, nil, :
|
297
|
+
pattern = RDF::Query::Pattern.new(nil, nil, nil, context: false)
|
302
298
|
solutions = []
|
303
299
|
subject.send(:query_pattern, pattern) {|s| solutions << s}
|
304
300
|
context_statements = subject.statements.reject {|st| st.has_context?}.length
|
@@ -307,7 +303,7 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
307
303
|
|
308
304
|
it "returns statements from named contexts with variable context" do
|
309
305
|
unless subject.contexts.to_a.empty?
|
310
|
-
pattern = RDF::Query::Pattern.new(nil, nil, nil, :
|
306
|
+
pattern = RDF::Query::Pattern.new(nil, nil, nil, context: :c)
|
311
307
|
solutions = []
|
312
308
|
subject.send(:query_pattern, pattern) {|s| solutions << s}
|
313
309
|
context_statements = subject.statements.select {|st| st.has_context?}.length
|
@@ -317,7 +313,43 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
317
313
|
|
318
314
|
it "returns statements from specific context with URI context" do
|
319
315
|
unless subject.contexts.to_a.empty?
|
320
|
-
pattern = RDF::Query::Pattern.new(nil, nil, nil, :
|
316
|
+
pattern = RDF::Query::Pattern.new(nil, nil, nil, context: RDF::URI("http://ar.to/#self"))
|
317
|
+
solutions = []
|
318
|
+
subject.send(:query_pattern, pattern) {|s| solutions << s}
|
319
|
+
expect(solutions.size).to eq File.readlines(@doap).grep(/^<http:\/\/ar.to\/\#self>/).size
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
context "with graph_name", if: RDF::VERSION.to_s >= "1.99" do
|
325
|
+
it "returns statements from all graphs with no graph_name" do
|
326
|
+
pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: nil)
|
327
|
+
solutions = []
|
328
|
+
subject.send(:query_pattern, pattern) {|s| solutions << s}
|
329
|
+
expect(solutions.size).to eq @statements.size
|
330
|
+
end
|
331
|
+
|
332
|
+
it "returns statements from unnamed graphss with false graph_name" do
|
333
|
+
pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: false)
|
334
|
+
solutions = []
|
335
|
+
subject.send(:query_pattern, pattern) {|s| solutions << s}
|
336
|
+
named_statements = subject.statements.reject {|st| st.has_name?}.length
|
337
|
+
expect(solutions.size).to eq named_statements
|
338
|
+
end
|
339
|
+
|
340
|
+
it "returns statements from named graphss with variable graph_name" do
|
341
|
+
unless subject.graph_names.to_a.empty?
|
342
|
+
pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: :c)
|
343
|
+
solutions = []
|
344
|
+
subject.send(:query_pattern, pattern) {|s| solutions << s}
|
345
|
+
named_statements = subject.statements.select {|st| st.has_name?}.length
|
346
|
+
expect(solutions.size).to eq named_statements
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
it "returns statements from specific graph with URI graph_name" do
|
351
|
+
unless subject.graph_names.to_a.empty?
|
352
|
+
pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: RDF::URI("http://ar.to/#self"))
|
321
353
|
solutions = []
|
322
354
|
subject.send(:query_pattern, pattern) {|s| solutions << s}
|
323
355
|
expect(solutions.size).to eq File.readlines(@doap).grep(/^<http:\/\/ar.to\/\#self>/).size
|
@@ -333,16 +365,16 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
333
365
|
let(:failing_pattern) {[RDF::URI("http://no-such-resource"), RDF.type, RDF::Node.new]}
|
334
366
|
|
335
367
|
it "should respond to #first" do
|
336
|
-
|
368
|
+
is_expected.to respond_to(:first)
|
337
369
|
end
|
338
370
|
|
339
|
-
it "returns
|
371
|
+
it "returns a statement or solution" do
|
340
372
|
expect { subject.first }.not_to raise_error
|
341
|
-
expect(subject.first).to
|
373
|
+
expect(subject.first).to be_a_statement
|
342
374
|
end
|
343
375
|
|
344
376
|
it "returns the correct value when the pattern matches" do
|
345
|
-
matching_patterns = [[nil, nil, nil], subject.
|
377
|
+
matching_patterns = [[nil, nil, nil], subject.detect {|s| s.to_a.none? {|r| r.node?}}]
|
346
378
|
matching_patterns.each do |matching_pattern|
|
347
379
|
expect(subject.first(matching_pattern)).to eq subject.query(matching_pattern).each.first
|
348
380
|
end
|
@@ -365,7 +397,7 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
365
397
|
let(:failing_pattern) {[RDF::URI("http://no-such-resource"), nil, nil]}
|
366
398
|
|
367
399
|
it "should respond to #first_subject" do
|
368
|
-
|
400
|
+
is_expected.to respond_to(:first_subject)
|
369
401
|
end
|
370
402
|
|
371
403
|
it "returns enumerator without a pattern" do
|
@@ -397,7 +429,7 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
397
429
|
describe "#first_predicate" do
|
398
430
|
let(:failing_pattern) {[nil, RDF::URI("http://no-such-resource"), nil]}
|
399
431
|
|
400
|
-
it {
|
432
|
+
it {is_expected.to respond_to(:first_predicate)}
|
401
433
|
|
402
434
|
it "returns enumerator without a pattern" do
|
403
435
|
expect { subject.first_predicate }.not_to raise_error
|
@@ -427,7 +459,7 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
427
459
|
|
428
460
|
describe "#first_object" do
|
429
461
|
let(:failing_pattern) {[nil, nil, RDF::URI("http://no-such-resource")]}
|
430
|
-
it {
|
462
|
+
it {is_expected.to respond_to(:first_object)}
|
431
463
|
|
432
464
|
it "returns enurator without a pattern" do
|
433
465
|
expect { subject.first_object }.not_to raise_error
|
@@ -460,12 +492,12 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
460
492
|
let(:resource) {RDF::Node.new}
|
461
493
|
subject {
|
462
494
|
RDF::Graph.new do |graph|
|
463
|
-
graph << [resource, RDF.type, RDF::
|
464
|
-
graph << [resource, RDF::
|
465
|
-
graph << [resource, RDF::
|
495
|
+
graph << [resource, RDF.type, RDF::URI("http://usefulinc.com/ns/doap#Project")]
|
496
|
+
graph << [resource, RDF::URI("http://purl.org/dc/terms/creator"), RDF::URI.new('http://example.org/#jhacker')]
|
497
|
+
graph << [resource, RDF::URI("http://purl.org/dc/terms/creator"), literal]
|
466
498
|
end
|
467
499
|
}
|
468
|
-
it {
|
500
|
+
it {is_expected.to respond_to(:first_literal)}
|
469
501
|
|
470
502
|
it "returns a literal without a pattern" do
|
471
503
|
expect { subject.first_literal }.not_to raise_error
|
@@ -473,7 +505,7 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
473
505
|
end
|
474
506
|
|
475
507
|
it "returns the correct value when the pattern matches" do
|
476
|
-
matching_patterns = [[nil, nil, nil], [resource, nil, nil], [nil, RDF::
|
508
|
+
matching_patterns = [[nil, nil, nil], [resource, nil, nil], [nil, RDF::URI("http://purl.org/dc/terms/creator"), nil], [nil, nil, literal]]
|
477
509
|
matching_patterns.each do |matching_pattern|
|
478
510
|
expect(subject.first_literal(matching_pattern)).to eq literal
|
479
511
|
end
|
@@ -495,7 +527,7 @@ RSpec.shared_examples 'an RDF::Queryable' do
|
|
495
527
|
|
496
528
|
describe "#first_value" do
|
497
529
|
let(:failing_pattern) {[nil, nil, RDF::Node.new]}
|
498
|
-
it {
|
530
|
+
it {is_expected.to respond_to(:first_value)}
|
499
531
|
|
500
532
|
it "returns first literal without a pattern" do
|
501
533
|
expect { subject.first_value }.not_to raise_error
|
data/lib/rdf/spec/reader.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rdf/spec'
|
2
2
|
|
3
3
|
RSpec.shared_examples 'an RDF::Reader' do
|
4
|
-
|
4
|
+
include RDF::Spec::Matchers
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
raise 'reader must be defined with let(:reader)' unless defined? reader
|
@@ -29,7 +29,7 @@ RSpec.shared_examples 'an RDF::Reader' do
|
|
29
29
|
f.file_extensions.each_pair do |sym, content_type|
|
30
30
|
reader_mock = double("reader")
|
31
31
|
expect(reader_mock).to receive(:got_here)
|
32
|
-
expect(reader_class).to receive(:for).with(:
|
32
|
+
expect(reader_class).to receive(:for).with(file_name: "foo.#{sym}").and_return(reader_class)
|
33
33
|
reader_class.open("foo.#{sym}") do |r|
|
34
34
|
expect(r).to be_a(RDF::Reader)
|
35
35
|
reader_mock.got_here
|
@@ -44,20 +44,20 @@ RSpec.shared_examples 'an RDF::Reader' do
|
|
44
44
|
reader_mock = double("reader")
|
45
45
|
expect(reader_mock).to receive(:got_here)
|
46
46
|
expect(reader_class).to receive(:for).with(sym).and_return(reader_class)
|
47
|
-
reader_class.open("foo.#{sym}", :
|
47
|
+
reader_class.open("foo.#{sym}", format: sym) do |r|
|
48
48
|
expect(r).to be_a(RDF::Reader)
|
49
49
|
reader_mock.got_here
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
it "yields reader given {:
|
54
|
+
it "yields reader given {file_name: file_name}" do
|
55
55
|
reader_class.format.each do |f|
|
56
56
|
f.file_extensions.each_pair do |sym, content_type|
|
57
57
|
reader_mock = double("reader")
|
58
58
|
expect(reader_mock).to receive(:got_here)
|
59
|
-
expect(reader_class).to receive(:for).with(:
|
60
|
-
reader_class.open("foo.#{sym}", :
|
59
|
+
expect(reader_class).to receive(:for).with(file_name: "foo.#{sym}").and_return(reader_class)
|
60
|
+
reader_class.open("foo.#{sym}", file_name: "foo.#{sym}") do |r|
|
61
61
|
expect(r).to be_a(RDF::Reader)
|
62
62
|
reader_mock.got_here
|
63
63
|
end
|
@@ -65,13 +65,13 @@ RSpec.shared_examples 'an RDF::Reader' do
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
it "yields reader given {:
|
68
|
+
it "yields reader given {content_type: 'a/b'}" do
|
69
69
|
reader_class.format.each do |f|
|
70
70
|
f.content_types.each_pair do |content_type, formats|
|
71
71
|
reader_mock = double("reader")
|
72
72
|
expect(reader_mock).to receive(:got_here)
|
73
|
-
expect(reader_class).to receive(:for).with(:
|
74
|
-
reader_class.open("foo", :
|
73
|
+
expect(reader_class).to receive(:for).with(content_type: content_type, file_name: "foo").and_return(reader_class)
|
74
|
+
reader_class.open("foo", content_type: content_type) do |r|
|
75
75
|
expect(r).to be_a(RDF::Reader)
|
76
76
|
reader_mock.got_here
|
77
77
|
end
|
@@ -107,44 +107,44 @@ RSpec.shared_examples 'an RDF::Reader' do
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
it "sets validate given :
|
111
|
-
reader_class.new(reader_input, :
|
110
|
+
it "sets validate given validate: true" do
|
111
|
+
reader_class.new(reader_input, validate: true) do |r|
|
112
112
|
expect(r).to be_valid
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
-
it "sets canonicalize given :
|
116
|
+
it "sets canonicalize given canonicalize: true" do
|
117
117
|
reader_mock = double("reader")
|
118
118
|
expect(reader_mock).to receive(:got_here)
|
119
|
-
reader_class.new(reader_input, :
|
119
|
+
reader_class.new(reader_input, canonicalize: true) do |r|
|
120
120
|
reader_mock.got_here
|
121
121
|
expect(r).to be_canonicalize
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
it "sets intern given :
|
125
|
+
it "sets intern given intern: true" do
|
126
126
|
reader_mock = double("reader")
|
127
127
|
expect(reader_mock).to receive(:got_here)
|
128
|
-
reader_class.new(reader_input, :
|
128
|
+
reader_class.new(reader_input, intern: true) do |r|
|
129
129
|
reader_mock.got_here
|
130
130
|
expect(r).to be_intern
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
it "sets prefixes given :
|
134
|
+
it "sets prefixes given prefixes: {}" do
|
135
135
|
reader_mock = double("reader")
|
136
136
|
expect(reader_mock).to receive(:got_here)
|
137
|
-
reader_class.new(reader_input, :
|
137
|
+
reader_class.new(reader_input, prefixes: {a: "b"}) do |r|
|
138
138
|
reader_mock.got_here
|
139
|
-
expect(r.prefixes).to eq({:
|
139
|
+
expect(r.prefixes).to eq({a: "b"})
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
144
|
describe "#prefixes=" do
|
145
145
|
it "sets prefixes from hash" do
|
146
|
-
reader.prefixes = {:
|
147
|
-
expect(reader.prefixes).to eq({:
|
146
|
+
reader.prefixes = {a: "b"}
|
147
|
+
expect(reader.prefixes).to eq({a: "b"})
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
data/lib/rdf/spec/transaction.rb
CHANGED
@@ -6,44 +6,55 @@ require 'rdf/spec'
|
|
6
6
|
shared_examples "an RDF::Transaction" do |klass|
|
7
7
|
include RDF::Spec::Matchers
|
8
8
|
|
9
|
-
subject {klass.new(:
|
9
|
+
subject {klass.new(graph_name: RDF::URI("name"), inser: RDF::Graph.new, delete: RDF::Graph.new)}
|
10
10
|
|
11
11
|
describe "#initialize" do
|
12
12
|
subject {klass}
|
13
13
|
it "accepts a graph" do
|
14
14
|
g = double("graph")
|
15
|
-
this = subject.new(:
|
15
|
+
this = subject.new(graph: g)
|
16
16
|
expect(this.graph).to eq g
|
17
17
|
end
|
18
18
|
|
19
|
-
it "accepts a context" do
|
19
|
+
it "accepts a context", unless: RDF::VERSION.to_s >= "1.99" do
|
20
20
|
c = double("context")
|
21
|
-
this = subject.new(:
|
21
|
+
this = subject.new(graph: c)
|
22
22
|
expect(this.graph).to eq c
|
23
23
|
expect(this.context).to eq c
|
24
24
|
|
25
|
-
this = subject.new(:
|
25
|
+
this = subject.new(context: c)
|
26
26
|
expect(this.graph).to eq c
|
27
27
|
expect(this.context).to eq c
|
28
28
|
end
|
29
29
|
|
30
|
+
it "accepts a graph_name", if: RDF::VERSION.to_s >= "1.99" do
|
31
|
+
c = double("graph_name")
|
32
|
+
this = subject.new(graph: c)
|
33
|
+
expect(this.graph).to eq c
|
34
|
+
expect(this.graph_name).to eq c
|
35
|
+
|
36
|
+
this = subject.new(graph_name: c)
|
37
|
+
expect(this.graph).to eq c
|
38
|
+
expect(this.graph_name).to eq c
|
39
|
+
end
|
40
|
+
|
30
41
|
it "accepts inserts" do
|
31
42
|
g = double("inserts")
|
32
|
-
this = subject.new(:
|
43
|
+
this = subject.new(insert: g)
|
33
44
|
expect(this.inserts).to eq g
|
34
45
|
end
|
35
46
|
|
36
47
|
it "accepts deletes" do
|
37
48
|
g = double("deletes")
|
38
|
-
this = subject.new(:
|
49
|
+
this = subject.new(delete: g)
|
39
50
|
expect(this.deletes).to eq g
|
40
51
|
end
|
41
52
|
end
|
42
53
|
|
43
|
-
its(:deletes) {
|
44
|
-
its(:inserts) {
|
45
|
-
it {
|
46
|
-
it {
|
54
|
+
its(:deletes) {is_expected.to be_a(RDF::Enumerable)}
|
55
|
+
its(:inserts) {is_expected.to be_a(RDF::Enumerable)}
|
56
|
+
it {is_expected.to be_mutable}
|
57
|
+
it {is_expected.to_not be_readable}
|
47
58
|
|
48
59
|
it "does not respond to #load" do
|
49
60
|
expect {subject.load("http://example/")}.to raise_error(NoMethodError)
|
@@ -76,12 +87,12 @@ shared_examples "an RDF::Transaction" do |klass|
|
|
76
87
|
end
|
77
88
|
|
78
89
|
it "calls before_execute" do
|
79
|
-
|
90
|
+
is_expected.to receive(:before_execute).with(r, {})
|
80
91
|
subject.execute(r)
|
81
92
|
end
|
82
93
|
|
83
94
|
it "calls after_execute" do
|
84
|
-
|
95
|
+
is_expected.to receive(:after_execute).with(r, {})
|
85
96
|
subject.execute(r)
|
86
97
|
end
|
87
98
|
|