|
20 | 20 | require 'rdf/spec/queryable' |
21 | 21 | let(:queryable) do |
22 | 22 | repository.insert(*RDF::Spec.quads) |
23 | | - q = klass.new(repository, mutable: true) |
| 23 | + klass.new(repository) |
24 | 24 | end |
25 | 25 | 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 |
26 | 46 | end |
27 | 47 |
|
28 | 48 | describe "#initialize" do |
|
128 | 148 | expect(subject.repository).to have_statement(st) |
129 | 149 | end |
130 | 150 |
|
131 | | - it 'retains existing graph names' do |
| 151 | + it 'overwrites existing graph names' do |
132 | 152 | st.graph_name = RDF::URI('g') |
133 | 153 | repository.insert(st) |
134 | 154 |
|
135 | 155 | expect do |
136 | 156 | subject.delete(st) |
137 | 157 | subject.execute |
138 | | - end.to change { subject.repository.statements }.to be_empty |
| 158 | + end.not_to change { subject.repository.statements } |
139 | 159 | end |
140 | 160 |
|
141 | | - it 'retains existing default graph name' do |
| 161 | + it 'overwrites existing default graph name' do |
142 | 162 | st.graph_name = false |
143 | 163 |
|
144 | 164 | repository.insert(st) |
145 | 165 |
|
146 | 166 | expect do |
147 | 167 | subject.delete(st) |
148 | 168 | subject.execute |
149 | | - end.to change { subject.repository.statements }.to be_empty |
| 169 | + end.not_to change { subject.repository.statements } |
150 | 170 | end |
151 | 171 | end |
152 | 172 | end |
|
200 | 220 | expect(subject.repository).to have_statement(with_name) |
201 | 221 | end |
202 | 222 |
|
203 | | - it 'retains existing graph names' do |
| 223 | + it 'overwrites existing graph names' do |
204 | 224 | st.graph_name = RDF::URI('g') |
205 | | - |
| 225 | + with_name = st.dup |
| 226 | + with_name.graph_name = graph_uri |
| 227 | + |
206 | 228 | expect do |
207 | 229 | subject.insert(st) |
208 | 230 | subject.execute |
209 | 231 | end.to change { subject.repository.statements } |
210 | 232 |
|
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) |
212 | 235 | end |
213 | 236 |
|
214 | | - it 'retains existing default graph name' do |
| 237 | + it 'overwrites existing default graph name' do |
215 | 238 | st.graph_name = false |
216 | | - |
217 | | - expect do |
| 239 | + with_name = st.dup |
| 240 | + with_name.graph_name = graph_uri |
| 241 | + |
| 242 | + expect do |
218 | 243 | subject.insert(st) |
219 | 244 | subject.execute |
220 | 245 | 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) |
223 | 249 | end |
224 | 250 | end |
225 | 251 | end |
|
0 commit comments