Launching Capybara-Webkit on a dockerized Rails 5 app

孤人 提交于 2019-12-10 21:11:38

问题


I'm working on a brand new Rails 5 app, and I can't launch Capybara-Webkit. I'm following these indications.

My development process includes Docker-Compose, then CircleCI for building the Docker image and sending it to Google Cloud Registry.

The $ bundle install is fine, the $ docker build is done, but I can't even launch a spec locally with Webkit.

When I launch this command, it hangs out and freeze:

$ docker-compose run web xvfb-run -a bundle exec rspec

I can't find any many informations about the xvfb-run command, I'm assuming it's a launcher packaged in xvfb...

Here is my Dockerfile:

FROM ruby:2.4.1

RUN apt-get update -qq && apt-get install -y \
  build-essential \
  libpq-dev \
  nodejs \
  xvfb \
  qt5-default \
  libqt5webkit5-dev \
  gstreamer1.0-plugins-base \
  gstreamer1.0-tools \
  gstreamer1.0-x

RUN mkdir /app_dir
WORKDIR /app_dir

ADD Gemfile* /app_dir/

RUN bundle install

COPY . .

Edit 07/08/2017

I think I got misleaded by my dev environment. When I try to launch my spec with guard instead of directly with the rspec, I get another error:

Capybara::Webkit::ConnectionError:
  /usr/local/bundle/gems/capybara-webkit-1.14.0/bin/webkit_server failed to start.

This doesnt help me much. This Github issue makes me believe that I need to do something with xvfb.

I tried to launch webkit_server directly from the gem bin folder, and I got the following error:

QXcbConnection: Could not connect to display
Aborted

Edit #2 07/08/2017

I found a way to launch my test suite. If I first launch a bash terminal in my docker compose system, I can then use xvfb without problem.

$ docker-compose run web bash

then

$ xvfb-run -a bundle exec rspec spec

And everything work as expected. The initial problem remains: when I launch this command:

$ docker-compose run web xvfb-run -a bundle exec rspec

It stay on hold and never launch any spec. I'm looking into docker-compose configuration, I must have missed something.

Weird stuff: when I launch my specs via guard it's working... I have no idea why.

Edit #3 08/08/2017

I ended up writing an issue in Capybara-Webkit repo.

来源:https://stackoverflow.com/questions/45510512/launching-capybara-webkit-on-a-dockerized-rails-5-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!