Sha256: 5a233c71be2db9ae060160488378b533c40d36f17daf614b77cb411d7f5ef634

Contents?: true

Size: 723 Bytes

Versions: 30

Compression:

Stored size: 723 Bytes

Contents

# -*- rspec -*-
#encoding: utf-8

require_relative '../helpers'

context "running with sync_* methods" do
	before :each do
		PG::Connection.async_api = false
	end

	after :each do
		PG::Connection.async_api = true
	end

	fname = File.expand_path("../connection_spec.rb", __FILE__)
	eval File.read(fname, encoding: __ENCODING__), binding, fname


	it "enables/disables async/sync methods by #async_api" do
		[true, false].each do |async|
			PG::Connection.async_api = async

			start = Time.now
			t = Thread.new do
				@conn.exec( 'select pg_sleep(1)' )
			end
			sleep 0.1

			t.kill
			t.join
			dt = Time.now - start

			if async
				expect( dt ).to be < 1.0
			else
				expect( dt ).to be >= 1.0
			end
		end
	end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
pg-1.1.2 spec/pg/connection_sync_spec.rb
pg-1.1.1-x86-mingw32 spec/pg/connection_sync_spec.rb
pg-1.1.1-x64-mingw32 spec/pg/connection_sync_spec.rb
pg-1.1.1 spec/pg/connection_sync_spec.rb
pg-1.1.0-x86-mingw32 spec/pg/connection_sync_spec.rb
pg-1.1.0-x64-mingw32 spec/pg/connection_sync_spec.rb
pg-1.1.0 spec/pg/connection_sync_spec.rb
pg-1.1.0.pre20180730171000-x86-mingw32 spec/pg/connection_sync_spec.rb
pg-1.1.0.pre20180730171000-x64-mingw32 spec/pg/connection_sync_spec.rb
pg-1.1.0.pre20180730171000 spec/pg/connection_sync_spec.rb