Sha256: 182c737d1f250326ca97e74fea685d867f96c6f45a449ff662399b987eff018d

Contents?: true

Size: 955 Bytes

Versions: 5

Compression:

Stored size: 955 Bytes

Contents

require 'mt-libuv'


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

		@reactor = MTLibuv::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

5 entries across 5 versions & 1 rubygems

Version Path
mt-libuv-4.1.04 spec/idle_spec.rb
mt-libuv-4.1.03 spec/idle_spec.rb
mt-libuv-4.1.02 spec/idle_spec.rb
mt-libuv-4.1.01 spec/idle_spec.rb
mt-libuv-4.1.0 spec/idle_spec.rb