mercredi 15 avril 2015

How can I test faye rack server with rspec?

I have Faye-Rails integrated into my Rails Apps. And I want to ensure the default methods I built in the controller are available and behaves as expected when the rails app is running.


I've added the initializer to the application.rb:



config.middleware.delete Rack::Lock
config.middleware.use FayeRails::Middleware, mount: '/names, :timeout => 25 do
map '/client/*' => ClientWebsocketController
map default: :block
end


And I've created a controller to handle the requests:



require 'faye'
require 'json'

class ClientWebsocketController < FayeRails::Controller

channel '/client/*' do

monitor :subscribe do
puts "Client #{client_id} subscribed to #{channel}."
end
end


I've tryed testing with Rack::Test as per this answer:


How can I test Rack middleware?


I've tryed to replicate Faye-Rails test:


http://ift.tt/1FKiqq9


And did some research around in google:


http://ift.tt/1NIQ6ya


But none of this worked for me. I've been researching around this script which seems to do the job perfect. But I'm unable to extract the call sequence:


http://ift.tt/1FKiqqi


Any help or clue will be greatly appreciated.


Aucun commentaire:

Enregistrer un commentaire