LoginSignup
3
3

More than 5 years have passed since last update.

Rails + Chrome headless + Capybara + Circle CI でテスト環境を構築してみた

Last updated at Posted at 2017-09-25
1 / 15

題名通り作ってみたのでざっくり共有


次にcircle ciを導入

image.png


  • 左側のサイドバーのProjectsを選択
  • rails headless capybara の Setup Projectを選択

image.png


  • 以下の画面に変化します。僕はLinux、2.0,rubyを選択していきました。

スクリーンショット 2017-09-25 15.34.03.png


  • 同画面を下の方にスクロールしていくと「Next Steps」が出てくるので手順通りに進めていきます。

スクリーンショット 2017-09-25 15.36.49.png


Next Steps


1 まずは

mkdir .circleci
touch .circleci/config.yaml

でフォルダとファイルを作成します


2 『Copy to clipboard』でコピー
3 適当にブランチを切って、コピーしたものを config.yamlに貼り付ける
4 そのブランチを保存してプッシュします
5 『Start building』を選択します


こんな感じの画面が出れば成功
image.png


config.yamlの設定

プッシュしたコミット見ると「❌」ついてるのでエラー内容をみて見る!

rake aborted!
Don't know how to build task 'db:create' (see --tasks)

db:create 今回必要なかった〜と思い、 config.yaml の中の rake タスクを削除します


次にもう一回プッシュするとまた「❌」...

#!/bin/bash -eo pipefail
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

bundle exec rspec --format progress \
                --format RspecJunitFormatter \
                --out /tmp/test-results/rspec.xml \
                --format progress \
                "${TEST_FILES}"
Requested historical based timing, but they are not present.  Falling back to name based sorting
bundler: command not found: rspec
Install missing gem executables with `bundle instal

今度は必要じゃない rspecの設定でエラーが出てるので、 config.yaml

- run:
     name: run tests
     command: |

以下の設定を全て削除します!
そうすると、今度はテスト自体が走らないので

 - run:
     name: run tests
     command: |
      rails test test

rails test testを追加


これで今一度push!

#!/bin/bash -eo pipefail
rails test test
Run options: --seed 13377

# Running:

Puma starting in single mode...
* Version 3.9.1 (ruby 2.4.1-p111), codename: Private Caller
* Min threads: 0, max threads: 1
* Environment: test
* Listening on tcp://0.0.0.0:40662
Use Ctrl-C to stop
.

Finished in 1.557777s, 0.6419 runs/s, 0.6419 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

いぇ〜〜い成功✌️


*補足

home_test.rb
find('.foo').triger('click')

ここでエラーでる人は

home_test.rb
find('.foo').click

に変更してくださいね!

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3