Sha256: 4fd63517da03817e9050b6454ce527fe2bc731aec8484ca6d006e7adda93bdfd
Contents?: true
Size: 1.33 KB
Versions: 41
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' module Startback module Support describe TransactionManager do subject do TransactionManager.new(db).call(nil, op) do op.call end end class FakeDatabase def initialize @called = false end attr_reader :called def transaction @called = true yield end end let(:db) do FakeDatabase.new end context 'when called with a default operation' do class OperationNotManagingTransactions < Startback::Operation def call 12 end end let(:op) do OperationNotManagingTransactions.new end it 'calls db.transaction' do expect(subject).to eql(12) expect(db.called).to eql(true) end end context 'when called with an operation that manages the transactions itself' do class OperationManagingTransactions < Startback::Operation self.transaction_policy = :within_call def call 12 end end let(:op) do OperationManagingTransactions.new end it 'calls db.transaction' do expect(subject).to eql(12) expect(db.called).to eql(false) end end end end end
Version data entries
41 entries across 41 versions & 3 rubygems