test/angelo/websocket_spec.rb in angelo-0.1.8 vs test/angelo/websocket_spec.rb in angelo-0.1.9
- old
+ new
@@ -1,12 +1,12 @@
require_relative '../spec_helper'
describe Angelo::WebsocketResponder do
- def socket_wait_for path, latch, expectation, key = :swf, &block
+ def websocket_wait_for path, latch, expectation, key = :swf, &block
Reactor.testers[key] = Array.new(CONCURRENCY).map do
- wsh = socket path
+ wsh = websocket_helper path
wsh.on_message = ->(e) {
expectation[e] if Proc === expectation
latch.count_down
}
wsh.init
@@ -38,11 +38,11 @@
end
end
end
it 'responds on websockets properly' do
- socket '/' do |wsh|
+ websocket_helper '/' do |wsh|
latch = CountDownLatch.new 500
wsh.on_message = ->(e) {
assert_match /hi there \d/, e.data
latch.count_down
@@ -68,11 +68,11 @@
it 'responds on multiple websockets properly' do
latch = CountDownLatch.new CONCURRENCY * 500
Reactor.testers[:wshs] = Array.new(CONCURRENCY).map do
- wsh = socket '/'
+ wsh = websocket_helper '/'
wsh.on_message = ->(e) {
assert_match /hi there \d/, e.data
latch.count_down
}
wsh.init
@@ -130,11 +130,11 @@
expectation = ->(e){
assert_match /from http (#{Angelo::HTTPABLE.map(&:to_s).join('|')})/, e.data
}
- socket_wait_for '/concur', latch, expectation do
+ websocket_wait_for '/concur', latch, expectation do
Angelo::HTTPABLE.each {|m| __send__ m, '/concur', foo: 'http'}
latch.wait
end
end
@@ -185,22 +185,22 @@
end
it 'handles single context' do
latch = CountDownLatch.new CONCURRENCY
- socket_wait_for '/', latch, wait_for_block do
+ websocket_wait_for '/', latch, wait_for_block do
post '/', obj
latch.wait
end
end
it 'handles multiple contexts' do
latch = CountDownLatch.new CONCURRENCY
Reactor.testers[:hmc] = Array.new(CONCURRENCY).map do
- wsh = socket '/'
+ wsh = websocket_helper '/'
wsh.on_message = ->(e) {
wait_for_block[e]
latch.count_down
}
wsh.init
@@ -208,11 +208,11 @@
end
one_latch = CountDownLatch.new CONCURRENCY
Reactor.testers[:hmc_one] = Array.new(CONCURRENCY).map do
- wsh = socket '/one'
+ wsh = websocket_helper '/one'
wsh.on_message = ->(e) {
wait_for_block[e]
one_latch.count_down
}
wsh.init
@@ -220,10 +220,10 @@
end
other_latch = CountDownLatch.new CONCURRENCY
Reactor.testers[:hmc_other] = Array.new(CONCURRENCY).map do
- wsh = socket '/other'
+ wsh = websocket_helper '/other'
wsh.on_message = ->(e) {
wait_for_block[e]
other_latch.count_down
}
wsh.init