Sha256: c80cdef6513d19ebc0d5173a7a8f3a01af6fa6c8cc1eaff4cd0a246f5eacac69

Contents?: true

Size: 948 Bytes

Versions: 10

Compression:

Stored size: 948 Bytes

Contents

require 'libuv'


describe Libuv::Idle do
	before :each do
		@log = []
		@general_failure = []

		@reactor = Libuv::Reactor.default
		@reactor.notifier do |error, context|
			begin
				@general_failure << "Log called: #{context}\n#{error.message}\n#{error.backtrace.join("\n") if error.backtrace}\n"
			rescue Exception => e
				@general_failure << "error in logger #{e.inspect}"
			end
		end
		@timeout = @reactor.timer {
			@reactor.stop
			@general_failure << "test timed out"
		}.start(5000)
	end
	
	it "should increase the idle count when there is nothing to process" do
		@reactor.run { |reactor|
			@idle_calls = 0
  
			idle = @reactor.idle { |e|
				@idle_calls += 1
			}.start

			stopper = @reactor.timer {
				idle.stop.close
				stopper.close
				@timeout.close
				@reactor.stop
			}.start(1000)

			expect(@reactor.active_handles).to be >= 4
		}

		expect(@general_failure).to eq([])
		expect((@idle_calls > 0)).to eq(true)
	end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
libuv-4.0.9 spec/idle_spec.rb
libuv-4.0.2 spec/idle_spec.rb
libuv-4.0.1 spec/idle_spec.rb
libuv-4.0.0 spec/idle_spec.rb
libuv-3.3.0 spec/idle_spec.rb
libuv-3.2.4 spec/idle_spec.rb
libuv-3.2.3 spec/idle_spec.rb
libuv-3.2.2 spec/idle_spec.rb
libuv-3.2.1 spec/idle_spec.rb
libuv-3.2.0 spec/idle_spec.rb