forked from avalanche123/uvrb
- Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathidle_spec.rb
44 lines (36 loc) · 948 Bytes
/
idle_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require'libuv'
describeLibuv::Idledo
before:eachdo
@log=[]
@general_failure=[]
@reactor=Libuv::Reactor.default
@reactor.notifierdo |error,context|
begin
@general_failure << "Log called: #{context}\n#{error.message}\n#{error.backtrace.join("\n")iferror.backtrace}\n"
rescueException=>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).tobe >= 4
}
expect(@general_failure).toeq([])
expect((@idle_calls > 0)).toeq(true)
end
end