質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Travis CI

Travis CIは、Githubアカウントでログインして使用するCIサービスです。CIしたいリポジトリーを選択すればGithubのコミットを取得し、設定ファイル通りにテストを実行します。テストが失敗した場合、メールで結果を送信することも可能です。

Q&A

0回答

975閲覧

Docker-composeのrailsアプリのtravisCIでの結合テストエラー

退会済みユーザー

退会済みユーザー

総合スコア0

docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Travis CI

Travis CIは、Githubアカウントでログインして使用するCIサービスです。CIしたいリポジトリーを選択すればGithubのコミットを取得し、設定ファイル通りにテストを実行します。テストが失敗した場合、メールで結果を送信することも可能です。

0グッド

0クリップ

投稿2021/01/06 01:17

前提・実現したいこと

docker上で作成したrailsアプリのテストをtravisCIと連携して行っているのですが、
モデルの単体テストはうまくいくものの、結合テストの実施でエラーが出ています。
※ローカル上ではすべてのテストが問題なく実行されています。

発生している問題・エラーメッセージ

travisCI上のエラーは膨大な量のため一部を載せます。
エラーが出ているのは、画面上で何らかの要素を取得・入力などする場合です。

Failures: 1) 投稿 新規投稿ができる時 ログインしたユーザーはレシピの新規投稿ができる Failure/Error: fill_in 'login_email', with: @user.email Capybara::ElementNotFound: Unable to find field "login_email" that is not disabled # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/node/finders.rb:303:in `block in synced_resolve' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/node/base.rb:83:in `synchronize' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/node/finders.rb:292:in `synced_resolve' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/node/finders.rb:53:in `find' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/node/actions.rb:91:in `fill_in' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/session.rb:768:in `block (2 levels) in <class:Session>' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/dsl.rb:58:in `block (2 levels) in <module:DSL>' # ./spec/support/sign_in_support.rb:7:in `sign_in' # ./spec/system/recipes_spec.rb:12:in `block (3 levels) in <main>' 2) 詳細 ログインしたユーザーは詳細ページに遷移してコメント投稿欄・コミュニケーション欄が表示される Failure/Error: fill_in 'login_email', with: @user.email Capybara::ElementNotFound: Unable to find field "login_email" that is not disabled # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/node/finders.rb:303:in `block in synced_resolve' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/node/base.rb:83:in `synchronize' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/node/finders.rb:292:in `synced_resolve' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/node/finders.rb:53:in `find' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/node/actions.rb:91:in `fill_in' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/session.rb:768:in `block (2 levels) in <class:Session>' # /usr/local/bundle/gems/capybara-3.34.0/lib/capybara/dsl.rb:58:in `block (2 levels) in <module:DSL>' # ./spec/support/sign_in_support.rb:7:in `sign_in' # ./spec/system/recipes_spec.rb:54:in `block (2 levels) in <main>' 3) 詳細 ログインしていないユーザーは詳細ページに遷移できるがコメント投稿欄・コミュニケーション欄は表示されない Failure/Error: expect(page).to have_content("#{@recipe.title}") expected to find text "test-title" in "Sprockets::FileNotFound at /recipes/21 ====================================== couldn't find file 'trix/dist/trix' with type 'text/css' Checked in these paths: /screpi/app/assets/config /screpi/app/assets/images /screpi/app/assets/stylesheets /usr/local/bundle/gems/actioncable-6.0.3.4/app/assets/javascripts /usr/local/bundle/gems/activestorage-6.0.3.4/app/assets/javascripts /usr/local/bundle/gems/actionview-6.0.3.4/lib/assets/compiled /usr/local/bundle/gems/turbolinks-source-5.2.0/lib/assets/javascripts /screpi/node_modules > To access an interactive console with this error, point your browser to: /__better_errors app/assets/stylesheets/actiontext.scss, line 6 ---------------------------------------------- ``` ruby 1 // 2 // Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and 3 // the trix-editor content (whether displayed or under editing). Feel free to incorporate this 4 // inclusion directly in any other asset bundle and remove this file. 5 // > 6 //= require trix/dist/trix 7 8 // We need to override trix.css’s image gallery styles to accommodate the 9 // element we wrap around attachments. Otherwise, 10 // images in galleries will be squished by the max-width: 33%; rule. 11 ``` App backtrace ------------- - app/assets/stylesheets/actiontext.scss:6:in `' - app/views/shared/_top-content.html.erb:15:in `_app_views_shared__top_content_html_erb___3840752795268377587_47139238910780' - app/views/recipes/show.html.erb:2:in `_app_views_recipes_show_html_erb__162942296445914804_47139253700140' - spec/system/recipes_spec.rb:72:in `block (2 levels) in ' Full backtrace -------------- - app/assets/stylesheets/actiontext.scss:6:in `' - sprockets (3.7.2) lib/sprockets/resolve.rb:65:in `resolve!' - sprockets (3.7.2) lib/sprockets/directive_processor.rb:399:in `resolve' - sprockets (3.7.2) # 中略 # ./spec/system/recipes_spec.rb:75:in `block (2 levels) in <main>'

これ以降も同様のエラーが続きます。

.travis.yml

sudo: required env: - DOCKER_COMPOSE_VERSION=1.27.4 before_install: - docker-compose up --build -d script: - docker-compose exec --env 'RAILS_ENV=test' app rails db:create - docker-compose exec --env 'RAILS_ENV=test' app rails db:migrate - docker-compose exec --env 'RAILS_ENV=test' app bundle exec rspec

Dockerfile

FROM ruby:2.6.5 RUN apt-get update && \ apt-get install -y mariadb-client nodejs vim --no-install-recommends && \ rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install -y curl apt-transport-https wget && \ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ apt-get update && apt-get install -y yarn RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - && \ apt-get install nodejs RUN mkdir /screpi WORKDIR /screpi COPY Gemfile Gemfile.lock /screpi/ RUN gem install bundler RUN bundle install COPY . /screpi COPY entrypoint.sh /usr/bin/ RUN chmod +x /usr/bin/entrypoint.sh ENTRYPOINT ["entrypoint.sh"] EXPOSE 3000 # Start the main process. CMD ["rails", "server", "-b", "0.0.0.0"]

docker-compose.yml

version: "3" services: db: image: mysql:5.6 environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: root volumes: - mysql-data:/var/lib/mysql ports: - '4306:3306' app: tty: true stdin_open: true build: . command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - '.:/screpi' - 'bundle:/usr/local/bundle' ports: - "3000:3000" links: - db depends_on: - db - chrome environment: - "SELENIUM_DRIVER_URL=http://selenium_chrome:4444/wd/hub" chrome: image: selenium/standalone-chrome-debug logging: driver: none volumes: mysql-data: bundle:

試したこと

①結合テストの画面操作をする部分がうまくいっていないため、seleniumのコンテナとの連携がうまくできていないのではないかと考え、docker-compose.yml内の以下記述を追記しましたが、うまくいきませんでした。

depends_on: - db - chrome ## 追記  #中略 chrome: image: selenium/standalone-chrome-debug logging: driver: none

②travisCI上のエラーの中で

expected to find text "新規登録" in "Sprockets::FileNotFound at / ============================ couldn't find file 'trix/dist/trix' with type 'text/css' Checked in these paths:

という記述があり、調べてみたところyarnをいれずにActionTextをインストールしようとすると起こりうるエラーのようですが、yarnはインストール済みの認識であり、trixおよびActionTextもインストールできていると認識しています。

pacjage.json

{ "name": "screpi", "private": true, "dependencies": { "@rails/actioncable": "^6.0.0-alpha", "@rails/actiontext": "^6.0.3-4", "@rails/activestorage": "^6.0.0-alpha", "@rails/ujs": "^6.0.0-alpha", "@rails/webpacker": "4.3.0", "trix": "^1.2.0", "turbolinks": "^5.2.0" }, "version": "0.1.0", "devDependencies": { "webpack-dev-server": "^3.11.0" } }

補足情報(FW/ツールのバージョンなど)

・ruby 2.6.5
・Rails 6.0.0
・mysql2 0.4.4
・Docker 19.03.13
・Docker Compose 1.27.4

お手数ですがエラー解決のため修正すべき部分等ありましたらご教示いただきたく、よろしくお願いいたします。
記載情報に不足等ございましたら申し訳ございません。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問