Skip to content

Commit 4af8ed5

Browse files
author
Tom Johnson
committed
Add querable transactions scoped to graph_name
1 parent adca395 commit 4af8ed5

2 files changed

Lines changed: 40 additions & 14 deletions

File tree

lib/rdf/spec/queryable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
expect(solutions.size).to eq @statements.size
8686
end
8787

88-
it "returns statements from unnamed graphss with false graph_name" do
88+
it "returns statements from unnamed graphs with false graph_name" do
8989
pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: false)
9090
solutions = []
9191
subject.send(method, pattern) {|s| solutions << s}

lib/rdf/spec/transaction.rb

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,29 @@
2020
require 'rdf/spec/queryable'
2121
let(:queryable) do
2222
repository.insert(*RDF::Spec.quads)
23-
q = klass.new(repository, mutable: true)
23+
klass.new(repository)
2424
end
2525
it_behaves_like 'an RDF::Queryable'
26+
27+
context 'with a graph_name' do
28+
let(:queryable) do
29+
graph_name = RDF::URI('g')
30+
graph = RDF::Graph.new(graph_name: graph_name, data: repository)
31+
graph.insert(*RDF::Spec.quads)
32+
klass.new(repository, graph_name: graph_name)
33+
end
34+
it_behaves_like 'an RDF::Queryable'
35+
end
36+
37+
context 'with a false graph_name' do
38+
let(:queryable) do
39+
graph = RDF::Graph.new(data: repository)
40+
graph.insert(*RDF::Spec.quads)
41+
graph_name = false
42+
klass.new(repository, graph_name: graph_name)
43+
end
44+
it_behaves_like 'an RDF::Queryable'
45+
end
2646
end
2747

2848
describe "#initialize" do
@@ -128,25 +148,25 @@
128148
expect(subject.repository).to have_statement(st)
129149
end
130150

131-
it 'retains existing graph names' do
151+
it 'overwrites existing graph names' do
132152
st.graph_name = RDF::URI('g')
133153
repository.insert(st)
134154

135155
expect do
136156
subject.delete(st)
137157
subject.execute
138-
end.to change { subject.repository.statements }.to be_empty
158+
end.not_to change { subject.repository.statements }
139159
end
140160

141-
it 'retains existing default graph name' do
161+
it 'overwrites existing default graph name' do
142162
st.graph_name = false
143163

144164
repository.insert(st)
145165

146166
expect do
147167
subject.delete(st)
148168
subject.execute
149-
end.to change { subject.repository.statements }.to be_empty
169+
end.not_to change { subject.repository.statements }
150170
end
151171
end
152172
end
@@ -200,26 +220,32 @@
200220
expect(subject.repository).to have_statement(with_name)
201221
end
202222

203-
it 'retains existing graph names' do
223+
it 'overwrites existing graph names' do
204224
st.graph_name = RDF::URI('g')
205-
225+
with_name = st.dup
226+
with_name.graph_name = graph_uri
227+
206228
expect do
207229
subject.insert(st)
208230
subject.execute
209231
end.to change { subject.repository.statements }
210232

211-
expect(subject.repository).to have_statement(st)
233+
expect(subject.repository).not_to have_statement(st)
234+
expect(subject.repository).to have_statement(with_name)
212235
end
213236

214-
it 'retains existing default graph name' do
237+
it 'overwrites existing default graph name' do
215238
st.graph_name = false
216-
217-
expect do
239+
with_name = st.dup
240+
with_name.graph_name = graph_uri
241+
242+
expect do
218243
subject.insert(st)
219244
subject.execute
220245
end.to change { subject.repository.statements }
221-
222-
expect(subject.repository).to have_statement(st)
246+
247+
expect(subject.repository).not_to have_statement(st)
248+
expect(subject.repository).to have_statement(with_name)
223249
end
224250
end
225251
end

0 commit comments

Comments
 (0)