test/test_cometio.rb in sinatra-cometio-0.3.9 vs test/test_cometio.rb in sinatra-cometio-0.4.0
- old
+ new
@@ -9,11 +9,11 @@
def teardown
App.stop
end
def test_simple
- client = CometIO::Client.new(App.cometio_url).connect
+ client = Sinatra::CometIO::Client.new(App.cometio_url).connect
post_data = {:time => Time.now.to_s, :msg => 'hello!!'}
res = nil
client.on :broadcast do |data|
res = data
end
@@ -33,20 +33,20 @@
end
def test_client_to_client2
## client --> server --> client2
- client = CometIO::Client.new(App.cometio_url).connect
+ client = Sinatra::CometIO::Client.new(App.cometio_url).connect
post_data = {:time => Time.now.to_s, :msg => 'hello!!', :to => nil}
res = nil
client.on :message do |data|
res = data
end
res2 = nil
client.on :connect do |session|
- client2 = CometIO::Client.new(App.cometio_url).connect
+ client2 = Sinatra::CometIO::Client.new(App.cometio_url).connect
client2.on :connect do |session2|
post_data['to'] = session2
client.push :message, post_data
end
client2.on :message do |data|
@@ -67,20 +67,20 @@
end
def test_broadcast
## client --> server --> client&client2
- client = CometIO::Client.new(App.cometio_url).connect
+ client = Sinatra::CometIO::Client.new(App.cometio_url).connect
post_data = {:time => Time.now.to_s, :msg => 'hello!!'}
res = nil
client.on :broadcast do |data|
res = data
client.close
end
res2 = nil
client.on :connect do |session|
- client2 = CometIO::Client.new(App.cometio_url).connect
+ client2 = Sinatra::CometIO::Client.new(App.cometio_url).connect
client2.on :connect do |session2|
client.push :broadcast, post_data
end
client2.on :broadcast do |data|
res2 = data