Capybara not working with action_cable

I use Rails 5 beta 3 with an action cable, the integration works fine in development, but when I try to run a function test through capybara, it does not seem to affect the channel actions.

I am using Portergeist and configured puma as capybara server. I also use es5-shim and es6-shim.

Has anyone else experienced this or know a workaround?

Thanks!

Edit

I use this capybara branch to configure Puma in Capybara

Capybara.register_server :puma do |app, port, host| require 'puma' Puma::Server.new(app).tap do |s| s.add_tcp_listener host, port end.run.join end 

I did not set anything in config.action_cable.allowed_request_origins

+8
ruby-on-rails ruby-on-rails-5 rspec capybara actioncable
source share
2 answers

To test actioncable with Capybara you need to use a multithreaded web server. Since you are using the current migration request to Capybara, which supports registering named drivers, you need to specify a named server to use

 Capybara.server = :puma 

For those who are not using the capybara branch with named servers, you can do

 Capybara.server {|app, port| require 'puma' Puma::Server.new(app).tap do |s| s.add_tcp_listener Capybara.server_host, port end.run.join } 
+11
source share

From Capybara v2.7.0, the passing block to Capybara::server is deprecated ( commit ).

Resignation Message : DEPRECATED: Passing a block to Capybara::server is deprecated, please use Capybara::register_server instead

To register a new web server (e.g. puma ) use:

  Capybara.register_server :puma do |app, port, host| require 'puma' Puma::Server.new(app).tap do |s| s.add_tcp_listener host, port end.run.join end 

Documentation Link

+6
source share

All Articles