Sha256: 066ff2efa0568a53104d09e7c15e715f75e56e8e4b39b3044f7757e322218574

Contents?: true

Size: 1.07 KB

Versions: 14

Compression:

Stored size: 1.07 KB

Contents

require 'pathname'
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'

describe DataObjects::Sqlite3::Transaction do

  before :each do
    @connection = mock("connection")
    DataObjects::Connection.should_receive(:new).with("mock://mock/mock").once.and_return(@connection)
    @transaction = DataObjects::Sqlite3::Transaction.new("mock://mock/mock")
    @transaction.id.replace("id")
    @command = mock("command")
  end

  {
    :begin => "BEGIN",
    :commit => "COMMIT",
    :rollback => "ROLLBACK",
    :rollback_prepared => "ROLLBACK",
    :prepare => nil
  }.each do |method, commands|
    it "should execute #{commands.inspect} on ##{method}" do
      if commands.is_a?(String)
        @command.should_receive(:execute_non_query).once
        @connection.should_receive(:create_command).once.with(commands).and_return(@command)
        @transaction.send(method)
      elsif commands.nil?
        @command.should_not_receive(:execute_non_query)
        @connection.should_not_receive(:create_command)
        @transaction.send(method)
      end
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
do_sqlite3-0.9.10.1 spec/unit/transaction_spec.rb
do_sqlite3-0.9.10 spec/unit/transaction_spec.rb
do_sqlite3-0.9.11-x86-mswin32-60 spec/unit/transaction_spec.rb
do_sqlite3-0.9.11 spec/unit/transaction_spec.rb
do_sqlite3-0.9.3 spec/unit/transaction_spec.rb
do_sqlite3-0.9.4 spec/unit/transaction_spec.rb
do_sqlite3-0.9.2 spec/unit/transaction_spec.rb
do_sqlite3-0.9.5 spec/unit/transaction_spec.rb
do_sqlite3-0.9.6-x86-mswin32-60 spec/unit/transaction_spec.rb
do_sqlite3-0.9.6 spec/unit/transaction_spec.rb
do_sqlite3-0.9.7 spec/unit/transaction_spec.rb
do_sqlite3-0.9.9 spec/unit/transaction_spec.rb
do_sqlite3-0.9.8 spec/unit/transaction_spec.rb
do_sqlite3-0.9.9-x86-mswin32-60 spec/unit/transaction_spec.rb