Skip to content

Instantly share code, notes, and snippets.

View rossta's full-sized avatar
💭
Being curious

Ross Kaffenberger rossta

💭
Being curious
View GitHub Profile
@rossta
rossta / socket_spec.rb
Created December 26, 2010 15:00
Testing an eventmachine server socket connection
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)
@rossta
rossta / fake_socket_client.rb
Created December 25, 2010 05:26
eventmachine socket client mock
class FakeSocketClient < EventMachine::Connection
attr_writer :onopen, :onclose, :onmessage
attr_reader :data
def initialize
@state = :new
@data = []
end
#! /usr/bin/env ruby
raise "Argument to 'take' not specfied.\n\n\tUsage: take [dump]\n" if ARGV.length == 0
module Take
class BathroomClosedForCleaningError < RuntimeError; end
end
case ARGV[0].downcase
when 'dump'
remarks = []
beforeEach(function() {
this.addMatchers({
toBeA: function(expected) { return this.env.equals_(this.actual, jasmine.any(expected)); }
});
});