Ruby/Rails: Capybara-webkit throws an error Capybara::Webkit::ConnectionError

The capybara-webkit gem installed successfully but throws following error

Logging in unconfirmed user returning after 10 days should not deny access to protected urls
      Failure/Error: visit '/'
      
      Capybara::Webkit::ConnectionError:
        /home/circleci/project/vendor/bundle/gems/capybara-webkit-1.11.1/bin/webkit_server failed to start.
      # ./spec/features/login_spec.rb:15:in `block (3 levels) in <top (required)>'

Here’s my circle config:

version: 2
jobs:
  build:
    docker:
      - image: circleci/ruby:2.2-node
        environment:
          BUNDLE_JOBS: 3
          BUNDLE_RETRY: 3
          BUNDLE_PATH: vendor/bundle
          PGHOST: 127.0.0.1
          PGUSER: circleci-demo-ruby
          RAILS_ENV: test
      - image: circleci/postgres:9.5-alpine
        environment:
          POSTGRES_USER: circleci-demo-ruby
          POSTGRES_DB: rails_blog
          POSTGRES_PASSWORD: ""
      - image: redis:4.0.6
      - image: fxposter/qt-ruby
    steps:
      - checkout

      # path
      - run:
          name: Which path
          command: pwd

      # Which version of bundler? 
      - run:
          name: Which bundler?
          command: bundle -v

      # Restore bundle cache
      - restore_cache:
          keys:
            - rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
            - rails-demo-bundle-v2-

      - run:
          name: Install nokogiri
          command: bundle config build.nokogiri --use-system-libraries

      - run:
          name: Install capybara-webkit
          command: sudo apt-get update; sudo apt-get install -y software-properties-common; sudo apt install -y gcc g++ make qt5-default libqt5webkit5-dev ruby-dev zlib1g-dev
      
      - run:
          name: Install capybara and pg dependent libraries
          command: sudo apt-get install libqt4-dev libqtwebkit-dev postgresql-client qtdeclarative5-dev qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x

      - run:
          name: Bundle Install
          command: bundle check || bundle install

      # Store bundle cache
      - save_cache:
          key: rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle

      # Only necessary if app uses webpacker or yarn in some other way
      - restore_cache:
          keys:
            - rails-demo-yarn-{{ checksum "yarn.lock" }}
            - rails-demo-yarn-

      - run:
          name: Yarn Install
          command: yarn install --cache-folder ~/.cache/yarn

      # Store yarn / webpacker cache
      - save_cache:
          key: rails-demo-yarn-{{ checksum "yarn.lock" }}
          paths:
            - ~/.cache/yarn

      - run:
          name: Wait for DB
          command: dockerize -wait tcp://localhost:5432 -timeout 1m

      - run:
          name: Database setup
          command: bundle exec rake db:create db:structure:load --trace

      # Run rspec in parallel
      - run:
          name: Run rspec in parallel
          command: |
            bundle exec rspec --profile 10 \
                              --format RspecJunitFormatter \
                              --out test_results/rspec.xml \
                              --format progress \
                              $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
      # Save test results for timing analysis
      - store_test_results:
          path: test_results

That may not be enough information for people to identify the problem. See if you have any server logs that give a more comprehensive issue report.

That has been resolved by adding xvfb-run -a

 - run:
          name: Run rspec in parallel
          command: |
            xvfb-run -a bundle exec rspec --profile 10 \
                              --format RspecJunitFormatter \
                              --out test_results/rspec.xml \
                              --format progress \
                              $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.