diff --git a/spec/pg/connection_spec.rb b/spec/pg/connection_spec.rb index ecb8093ef..f1a7af745 100644 --- a/spec/pg/connection_spec.rb +++ b/spec/pg/connection_spec.rb @@ -766,12 +766,18 @@ end it "doesn't leave stale server connections after finish" do + res = @conn.exec(%[SELECT COUNT(*) AS n FROM pg_stat_activity + WHERE usename IS NOT NULL AND application_name != '']) + # there's still the global @conn, but should be no more + old_count = res[0]['n'] + described_class.connect(@conninfo).finish + sleep 0.5 res = @conn.exec(%[SELECT COUNT(*) AS n FROM pg_stat_activity WHERE usename IS NOT NULL AND application_name != '']) # there's still the global @conn, but should be no more - expect( res[0]['n'] ).to eq( '1' ) + expect( res[0]['n'] ).to eq( old_count ) end it "can retrieve it's connection parameters for the established connection" do