-
Notifications
You must be signed in to change notification settings - Fork 79
Testing Faye with RSpec #76
Comments
OK, i know, that i have to use EventMachine, but now i have other problem. I want to test, that when I create new ChatMessage, it is published. When i subscribe to channel in my spec, messages published by model observer don't come. I wait for subscription and nothing happen. I put some prints to model observer and i see it is working. EventMachine.run do
client = Faye::Client.new('http://localhost:3000/faye')
sub = client.subscribe("/chat/1") do |message|
@message = message
EventMachine.stop_event_loop
end
sub.callback do
ChatMessage.create(content: "test message")
end
EventMachine.add_timer(4) do
EventMachine.stop_event_loop
end
end
expect(@message).not_to be_nil What I am doing wrong? THX form help. |
OK, the problem is, although client subscribe channel, and receive success, it really doesn't subscribe. Server receives good message, but outgoing message looks like {"id"=>"4", "channel"=>"/chat/1", "successful"=>true}, so i think it mean, nobody is subscribing that channel. Am I right? |
I have the same issue as you, have you resolved it ? |
Hi. The only way, to get this to work is to run your app before RSpec in 'test' env. You need also use DatabaseCleaner, and set in spec_helper.rb DatabaseCleaner.strategy = :deletion to avoid problems with data visibility. |
Thanks for you reply then |
Hi. Is it possible to test Faye with RSpec?
The text was updated successfully, but these errors were encountered: