Skip to content

Commit

Permalink
Change back #transaction tests, but don't try to do updating transact…
Browse files Browse the repository at this point in the history
…ion unless the subject is mutable.
  • Loading branch information
gkellogg committed Feb 12, 2016
1 parent 67107a2 commit 93e4172
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions lib/rdf/spec/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,23 @@
end
end

describe '#transaction' do
it 'is not implemented when #supports(:transactions) is false' do
unless subject.supports?(:transactions)
expect { subject.transaction }.to raise_error NotImplementedError
end
end
end

context "with transaction support" do
before {skip "Does not support Transactions" unless subject.supports?(:transactions)}
describe "#transaction'" do
it 'gives an immutable transaction' do
expect { subject.transaction { insert([]) } }.to raise_error TypeError
end

it 'commits a successful transaction' do
subject.clear!
statement = RDF::Statement(:s, RDF.type, :o)
expect(subject).to receive(:commit_transaction).and_call_original
if subject.mutable?
subject.clear!
statement = RDF::Statement(:s, RDF.type, :o)
expect(subject).to receive(:commit_transaction).and_call_original

expect do
subject.transaction(mutable: true) do
insert(statement)
end
end.to change { subject.statements }.to contain_exactly(statement)
expect do
subject.transaction(mutable: true) do
insert(statement)
end
end.to change { subject.statements }.to contain_exactly(statement)
end
end

it 'rolls back a failed transaction' do
Expand Down

0 comments on commit 93e4172

Please sign in to comment.