Sha256: 93162f772b5282ccf80ad73456d088a1f5d9b8acfdaac52ecf69cb42c42819f2
Contents?: true
Size: 1.31 KB
Versions: 11
Compression:
Stored size: 1.31 KB
Contents
require 'pathname' require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper' describe DataObjects::Mysql::Transaction do before :each do @connection = mock("connection") DataObjects::Connection.should_receive(:new).with("mock://mock/mock").once.and_return(@connection) @transaction = DataObjects::Mysql::Transaction.new("mock://mock/mock") @transaction.id.replace("id") @command = mock("command") end { :begin => "XA START 'id'", :commit => "XA COMMIT 'id'", :rollback => ["XA END 'id'", "XA ROLLBACK 'id'"], :rollback_prepared => "XA ROLLBACK 'id'", :prepare => ["XA END 'id'", "XA PREPARE 'id'"] }.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.is_a?(Array) && commands.size == 2 @command.should_receive(:execute_non_query).twice @connection.should_receive(:create_command).once.with(commands.first).and_return(@command) @connection.should_receive(:create_command).once.with(commands.last).and_return(@command) @transaction.send(method) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems