Permalink
Browse files

Fix bad test to not use mocks, but instead, a real connection

  • Loading branch information...
1 parent 2227224 commit 2f5f86cabe46e0c472fb0c542950b4d89a58b03b @nicksieger nicksieger committed Jan 28, 2012
Showing with 4 additions and 8 deletions.
  1. +4 −8 test/jndi_callbacks_test.rb
@@ -6,32 +6,28 @@
class JndiConnectionPoolCallbacksTest < Test::Unit::TestCase
def setup
- @connection = mock "JdbcConnection"
- @connection.stubs(:jndi_connection?).returns(true)
- @connection.stubs(:adapter=)
@logger = stub_everything "logger"
@config = JNDI_CONFIG
+ @connection = ActiveRecord::ConnectionAdapters::JdbcConnection.new @config
Entry.connection_pool.disconnect!
assert !Entry.connection_pool.connected?
class << Entry.connection_pool; public :instance_variable_set; end
end
def teardown
- @connection.stubs(:disconnect!)
Entry.connection_pool.disconnect!
end
def test_should_call_hooks_on_checkout_and_checkin
- @connection.stubs(:active?).returns(true)
- @connection.expects(:disconnect!)
@adapter = ActiveRecord::ConnectionAdapters::JdbcAdapter.new @connection, @logger, @config
Entry.connection_pool.instance_variable_set "@connections", [@adapter]
+ assert !@connection.active?
- @connection.expects(:reconnect!)
Entry.connection_pool.checkout
+ assert @connection.active?
- @connection.expects(:disconnect!)
Entry.connection_pool.checkin @adapter
+ assert !@connection.active?
end
end

0 comments on commit 2f5f86c

Please sign in to comment.