File: transaction_spec.rb

package info (click to toggle)
libdataobjects-ruby 0.10.2-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 336 kB
  • ctags: 200
  • sloc: ruby: 2,729; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,281 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))

describe DataObjects::Transaction do

  before do
    @connection = mock("connection")
    DataObjects::Connection.expects(:new).with("mock://mock/mock").once.returns(@connection)
    @transaction = DataObjects::Transaction.new("mock://mock/mock")
  end

  it "should have a HOST constant" do
    DataObjects::Transaction::HOST.should.not == nil?
  end

  describe "#initialize" do
    it "should provide a connection" do
      @transaction.connection.should == @connection
    end
    it "should provide an id" do
      @transaction.id.should.not == nil
    end
    it "should provide a unique id" do
      DataObjects::Connection.expects(:new).with("mock://mock/mock2").once.returns(@connection)
      @transaction.id.should.not == DataObjects::Transaction.new("mock://mock/mock2").id
    end
  end

  describe "#close" do
    it "should close its connection" do
      @connection.expects(:close).once
      should.not.raise(DataObjects::TransactionError) { @transaction.close }
    end
  end

  [:prepare, :commit_prepared, :rollback_prepared].each do |meth|
    it "should raise NotImplementedError on #{meth}" do
      should.raise(NotImplementedError) { @transaction.send(meth) }
    end
  end

end