diff --git a/spec/helpers.rb b/spec/helpers.rb index 4362750..9b064ea 100755 --- a/spec/helpers.rb +++ b/spec/helpers.rb @@ -199,8 +199,8 @@ module PG::TestingHelpers @test_pgdata = TEST_DIRECTORY + 'data' @test_pgdata.mkpath - @port = 54321 - ENV['PGPORT'] = @port.to_s + ENV['PGPORT'] ||= "54321" + @port = ENV['PGPORT'].to_i ENV['PGHOST'] = 'localhost' @conninfo = "host=localhost port=#{@port} dbname=test" diff --git a/spec/pg/connection_spec.rb b/spec/pg/connection_spec.rb index a1d7e42..1f6cd8d 100755 --- a/spec/pg/connection_spec.rb +++ b/spec/pg/connection_spec.rb @@ -241,7 +241,7 @@ describe PG::Connection do expect( @conn.db ).to eq( "test" ) expect( @conn.user ).to be_a_kind_of( String ) expect( @conn.pass ).to eq( "" ) - expect( @conn.port ).to eq( 54321 ) + expect( @conn.port ).to eq( @port ) expect( @conn.tty ).to eq( "" ) expect( @conn.options ).to eq( "" ) end @@ -741,7 +741,7 @@ describe PG::Connection do it "can return the default connection options as a Hash" do expect( described_class.conndefaults_hash ).to be_a( Hash ) expect( described_class.conndefaults_hash ).to include( :user, :password, :dbname, :host, :port ) - expect( ['5432', '54321'] ).to include( described_class.conndefaults_hash[:port] ) + expect( ['5432', '54321', @port.to_s] ).to include( described_class.conndefaults_hash[:port] ) expect( @conn.conndefaults_hash ).to eq( described_class.conndefaults_hash ) end -- 2.21.0