Skip to content

Instantly share code, notes, and snippets.

@jimsynz
Created January 1, 2012 19:35
Show Gist options
  • Save jimsynz/1548132 to your computer and use it in GitHub Desktop.
Save jimsynz/1548132 to your computer and use it in GitHub Desktop.
For the life of me I can't make this work...
shared_examples_for "a Faye server" do
self.use_transactional_fixtures = false
it "should have Event Machine reactor running" do
EM.reactor_running?.should be_true
end # Passes.
it "should be able to subscribe to channel" do
channel = "/random/#{rand(65534).to_s}"
message = "Successful subscription."
result = "Unsuccessful subscription."
Fiber.new do
client.subscribe(channel) do |msg|
result = msg
Fiber.current.resume
end
EM.defer do
FayeRails.client.publish(channel, message)
end
EM.add_timer(5) do
result = "Subscription timed out."
Fiber.current.resume
end
Fiber.yield
end.resume
result.should == message
end # Fails
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment