I found the solution. The problem came because I generated my app using orats
and it preconfigures ActionCable detached from web server (as a separate docker container).
Added the following to make it work:
# rails_helper.rb
Capybara.server = :puma
# docker-compose.yml
services:
...
tests:
depends_on:
- 'redis'
- 'postgres'
- 'box'
build: .
volumes:
- '.:/app'
volumes_from:
- box # busybox image to cache bundle install
env_file:
- '.env'
environment:
RAILS_ENV: test
ACTION_CABLE_MOUNT: '/cable'
command: /bin/true
# config/environments/test.rb
config.action_cable.url = nil
config.action_cable.mount_path = ENV["ACTION_CABLE_MOUNT"]
Then run
docker-compose run tests bundle exec rspec
Voila!