|
2 | 2 |
|
3 | 3 | # Pass in an instance of RDF::Transaction as follows: |
4 | 4 | # |
5 | | -# it_behaves_like "RDF::Transaction", RDF::Transaction |
| 5 | +# it_behaves_like "an RDF::Transaction", RDF::Transaction |
6 | 6 | shared_examples "an RDF::Transaction" do |klass| |
7 | 7 | include RDF::Spec::Matchers |
8 | 8 |
|
|
40 | 40 | it 'allows mutability' do |
41 | 41 | expect(klass.new(repository, mutable: true)).to be_mutable |
42 | 42 | end |
| 43 | + |
| 44 | + it 'accepts a graph_name' do |
| 45 | + graph_uri = RDF::URI('http://example.com/graph_1') |
| 46 | + |
| 47 | + expect(klass.new(repository, graph_name: graph_uri).graph_name) |
| 48 | + .to eq graph_uri |
| 49 | + end |
| 50 | + |
| 51 | + it 'defaults graph_name to nil' do |
| 52 | + expect(klass.new(repository).graph_name).to be_nil |
| 53 | + end |
43 | 54 | end |
44 | 55 |
|
45 | 56 | it "does not respond to #load" do |
|
96 | 107 | subject.execute |
97 | 108 | end.to change { subject.repository.empty? }.from(false).to(true) |
98 | 109 | end |
| 110 | + |
| 111 | + context 'with a graph_name' do |
| 112 | + subject { klass.new(repository, mutable: true, graph_name: graph_uri) } |
| 113 | + |
| 114 | + let(:graph_uri) { RDF::URI('http://example.com/graph_1') } |
| 115 | + |
| 116 | + it 'adds the graph_name to statements' do |
| 117 | + subject.repository.insert(st) |
| 118 | + with_name = st.dup |
| 119 | + with_name.graph_name = graph_uri |
| 120 | + subject.repository.insert(with_name) |
| 121 | + |
| 122 | + expect do |
| 123 | + subject.delete(st) |
| 124 | + subject.execute |
| 125 | + end.to change { subject.repository.statements } |
| 126 | + |
| 127 | + expect(subject.repository).not_to have_statement(with_name) |
| 128 | + expect(subject.repository).to have_statement(st) |
| 129 | + end |
| 130 | + end |
99 | 131 | end |
100 | 132 |
|
101 | 133 | describe "#insert" do |
|
129 | 161 | end.to change { subject.repository.statements } |
130 | 162 | .to contain_exactly(*sts) |
131 | 163 | end |
| 164 | + |
| 165 | + context 'with a graph_name' do |
| 166 | + subject { klass.new(repository, mutable: true, graph_name: graph_uri) } |
| 167 | + |
| 168 | + let(:graph_uri) { RDF::URI('http://example.com/graph_1') } |
| 169 | + |
| 170 | + it 'adds the graph_name to statements' do |
| 171 | + with_name = st.dup |
| 172 | + with_name.graph_name = graph_uri |
| 173 | + |
| 174 | + expect do |
| 175 | + subject.insert(st) |
| 176 | + subject.execute |
| 177 | + end.to change { subject.repository } |
| 178 | + |
| 179 | + expect(subject.repository).to have_statement(with_name) |
| 180 | + end |
| 181 | + |
| 182 | + it 'retains existing graph names' do |
| 183 | + st.graph_name = RDF::URI('g') |
| 184 | + |
| 185 | + expect do |
| 186 | + subject.insert(st) |
| 187 | + subject.execute |
| 188 | + end.to change { subject.repository.statements } |
| 189 | + |
| 190 | + expect(subject.repository).to have_statement(st) |
| 191 | + end |
| 192 | + end |
132 | 193 | end |
133 | 194 |
|
134 | 195 | describe '#execute' do |
|
0 commit comments