Sha256: c7f9bf71bbcafeecd463ffca3fdae78b3db2c4b22f25195b4108e7e0335bb1ab

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

shared_examples 'transactions are not supported' do
  describe '#supports_transactions?' do
    it 'returns false' do
      expect(subject.supports_transactions?).to eq(false)
    end
  end
end

shared_examples 'transactions are supported' do
  describe '#supports_transactions?' do
    it 'returns true' do
      expect(subject.supports_transactions?).to eq(true)
    end
  end

  it { should respond_to :begin_transaction }
  it { should respond_to :commit_transaction }
  it { should respond_to :rollback_transaction }
  it { should respond_to :in_transaction? }

  describe '#in_transaction?' do
    it "returns false if you aren't in a transaction" do
      expect(subject.in_transaction?).to eq(false)
    end
  end

  it 'raises a MessageDriver::TransactionError error if you begin two transactions' do
    subject.begin_transaction
    expect {
      subject.begin_transaction
    }.to raise_error MessageDriver::TransactionError
  end
  it 'raises a MessageDriver::TransactionError error if you commit outside of a transaction' do
    expect {
      subject.commit_transaction
    }.to raise_error MessageDriver::TransactionError
  end
  it 'raises a MessageDriver::TransactionError error if you rollback outside of a transaction' do
    expect {
      subject.rollback_transaction
    }.to raise_error MessageDriver::TransactionError
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
message-driver-0.4.0 spec/support/shared/transaction_examples.rb