spec/integration/logging_spec.rb in do_mysql-0.9.9 vs spec/integration/logging_spec.rb in do_mysql-0.9.10
- old
+ new
@@ -2,15 +2,11 @@
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
describe DataObjects::Mysql::Command do
before(:each) do
- @connection = if JRUBY
- DataObjects::Connection.new(DO_MYSQL_SPEC_JDBC_URI)
- else
- DataObjects::Connection.new(DO_MYSQL_SPEC_URI)
- end
+ @connection = DataObjects::Connection.new(DO_MYSQL_SPEC_URI)
end
after(:each) do
@connection.close
end
@@ -19,11 +15,11 @@
it "should log reader queries when the level is Debug (0)" do
command = @connection.create_command("SELECT * FROM widgets WHERE name = ?")
@mock_logger = mock('MockLogger', :level => 0)
DataObjects::Mysql.should_receive(:logger).and_return(@mock_logger)
- @mock_logger.should_receive(:debug).with("SELECT * FROM widgets WHERE name = 'Scott'")
+ @mock_logger.should_receive(:debug).with(/\([\d.]+\) SELECT \* FROM widgets WHERE name = 'Scott'/)
command.execute_reader('Scott').close # Readers must be closed!
end
it "shouldn't log reader queries when the level isn't Debug (0)" do
@@ -38,10 +34,10 @@
describe "Executing a Non-Query" do
it "should log non-query statements when the level is Debug (0)" do
command = @connection.create_command("INSERT INTO invoices (invoice_number) VALUES (?)")
@mock_logger = mock('MockLogger', :level => 0)
DataObjects::Mysql.should_receive(:logger).and_return(@mock_logger)
- @mock_logger.should_receive(:debug).with("INSERT INTO invoices (invoice_number) VALUES (1234)")
+ @mock_logger.should_receive(:debug).with(/\([\d.]+\) INSERT INTO invoices \(invoice_number\) VALUES \(1234\)/)
command.execute_non_query(1234)
end
it "shouldn't log non-query statements when the level isn't Debug (0)" do
command = @connection.create_command("INSERT INTO invoices (invoice_number) VALUES (?)")