/
spec_server.rb
78 lines (65 loc) · 1.64 KB
/
spec_server.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
require File.dirname(__FILE__) + '/gems'
Puggernaut::Gems.activate %w(sinatra)
require 'sinatra/base'
$:.unshift File.expand_path('../../', __FILE__)
require 'puggernaut/client'
class SpecServer < Sinatra::Base
set :environment, :test
set :root, File.expand_path("../../../", __FILE__)
set :public, "#{root}/public"
set :logging, true
set :static, true
get '/pulse' do
'OK'
end
get '/' do
redirect '/spec.html'
end
get '/single' do
begin
client = Puggernaut::Client.new("localhost:8101")
client.push :single => "single message"
client.close
rescue Exception => e
e.message
end
end
get '/join_leave_join' do
begin
client = Puggernaut::Client.new("localhost:8101")
client.push :single => [
"!PUGJOINtest", "!PUGLEAVEtest", "!PUGJOINtest"
]
client.close
rescue Exception => e
e.message
end
end
get '/multiple' do
begin
client = Puggernaut::Client.new("localhost:8101")
client.push :multiple => [ "multiple message 1", "multiple message 2" ]
client.close
rescue Exception => e
e.message
end
end
get '/last/:count' do
begin
client = Puggernaut::Client.new("localhost:8101")
client.push :last => "last message #{params[:count]}"
client.close
rescue Exception => e
e.message
end
end
get '/multiple/channels' do
begin
client = Puggernaut::Client.new("localhost:8101")
client.push :single => "single message", :multiple => [ "multiple message 1", "multiple message 2" ]
client.close
rescue Exception => e
e.message
end
end
end