Created
December 26, 2010 15:00
-
-
Save rossta/755460 to your computer and use it in GitHub Desktop.
Testing an eventmachine server socket connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "opening a socket connection" do | |
it "should add players to game if available and respond READY" do | |
EM.run { | |
server = Server.new(:host => '0.0.0.0', :port => 12345) | |
server.start | |
# opens the socket client connection | |
socket = EM.connect('0.0.0.0', 12345, FakeSocketClient) | |
# assigning the onopen client callback directly | |
socket.onopen = lambda { | |
server.players.size.should == 1 | |
socket.data.last.chomp.should == "READY" | |
EM.stop | |
} | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment