|
50 | 50 |
|
51 | 51 | it "should return nil if max recognizers exceeded" do
|
52 | 52 | $recognizer_pool = {:idle => []}
|
53 |
| - RecognizerPool::MAX_RECOGNIZERS = 0 |
| 53 | + CONFIG[:max_recognizers] = 0 |
54 | 54 | RecognizerPool.get_recognizer.should be_nil
|
55 | 55 | end
|
56 | 56 | end
|
57 | 57 |
|
58 | 58 | describe "organize_pool" do
|
59 | 59 | before(:each) do
|
60 |
| - RecognizerPool::MAX_RECOGNIZERS = 1 |
| 60 | + CONFIG[:max_recognizers] = 1 |
61 | 61 | $recognizer_pool = {:idle => []}
|
62 | 62 | end
|
63 | 63 |
|
64 | 64 | it "should close session if open time exceeded" do
|
65 |
| - time = (Time.now - (RecognizerPool::MAX_OPEN_TIME_IN_SECONDS + 10)) |
| 65 | + time = (Time.now - (CONFIG[:max_session_open_time] + 10)) |
66 | 66 | session = RecognizerSession.new
|
67 | 67 | session.stub!(:created_at).and_return(time)
|
68 | 68 | RecognizerPool.add_new_to_active_pool(session)
|
|
94 | 94 | end
|
95 | 95 |
|
96 | 96 | it "should remove session if maximum life time exceeded" do
|
97 |
| - time = (Time.now - (RecognizerPool::LIFE_CYCLE_IN_SECONDS + 10)) |
| 97 | + time = (Time.now - (CONFIG[:session_life_cycle] + 10)) |
98 | 98 | session = RecognizerSession.new
|
99 | 99 | session.stub!(:created_at).and_return(time)
|
100 | 100 | RecognizerPool.add_new_to_active_pool(session)
|
|
137 | 137 | end
|
138 | 138 |
|
139 | 139 | it "should not create new recognizer if max recognizers limit exceeded" do
|
140 |
| - RecognizerPool::MAX_RECOGNIZERS = 2 |
| 140 | + CONFIG[:max_recognizers] = 2 |
141 | 141 | $recognizer_pool = {:idle => []}
|
142 | 142 | current_idle_pool_size = RecognizerPool.pool[:idle].size
|
143 | 143 | RecognizerPool.should_receive(:active_recognizers).and_return([mock, mock])
|
|
156 | 156 | session_2 = RecognizerSession.new
|
157 | 157 | session_2.recognizer = recognizer_2
|
158 | 158 | $recognizer_pool = {
|
159 |
| - "1" => session_1, |
160 |
| - "2" => session_2, |
161 |
| - "3" => RecognizerSession.new, |
162 |
| - :idle => [mock]} |
| 159 | + "1" => session_1, |
| 160 | + "2" => session_2, |
| 161 | + "3" => RecognizerSession.new, |
| 162 | + :idle => [mock]} |
163 | 163 | active = RecognizerPool.active_recognizers
|
164 | 164 | active.size.should == 2
|
165 | 165 | active.include?(recognizer_1).should be_true
|
|
169 | 169 |
|
170 | 170 | describe "make_recognizer_idle_if_necessary" do
|
171 | 171 | before(:each) do
|
172 |
| - RecognizerPool::MAX_IDLE_RECOGNIZERS = 1 |
| 172 | + CONFIG[:max_idle_recognizers] = 1 |
173 | 173 | end
|
174 | 174 |
|
175 | 175 | it "should add to idle pool" do
|
|
0 commit comments