version: 2
jobs:
  build:
    working_directory: ~/tokite
    docker:
      - image: circleci/ruby:2.4.1-node
      - image: circleci/postgres:9.4.12-alpine
    steps:
      - checkout

      # Bundle install dependencies
      - run: bundle install --path vendor/bundle

      # Database setup
      - run: bundle exec rake db:create
      - run: RAILS_ENV=test bundle exec rails app:tokite:ridgepole:install app:tokite:ridgepole:apply

      # Run rspec in parallel
      - type: shell
        command: |
          bundle exec rspec --profile 10 \
                            --format RspecJunitFormatter \
                            --out /tmp/test-results/rspec.xml \
                            --format progress

      # Save artifacts
      - type: store_test_results
        path: /tmp/test-results

version: 2
jobs:
  build:
    working_directory: ~/tokite
    docker:
      - image: circleci/ruby:2.4.1-node
      - image: circleci/postgres:9.4.12-alpine
    steps:
      - checkout

      - type: cache-restore
        key: gemfile-{{ checksum "Gemfile" }}

      # Bundle install dependencies
      - run: bundle install --path vendor/bundle

      - type: cache-save
        key: gemfile-{{ checksum "Gemfile" }}
        paths:
          - vendor/bundle

      # Database setup
      - run: bundle exec rake db:create
      - run: RAILS_ENV=test bundle exec rails app:tokite:ridgepole:install app:tokite:ridgepole:apply

      # Run rspec in parallel
      - type: shell
        command: |
          bundle exec rspec --profile 10 \
                            --format RspecJunitFormatter \
                            --out /tmp/test-results/rspec.xml \
                            --format progress

      # Save artifacts
      - type: store_test_results
        path: /tmp/test-results

Save vendor/bundle cache on CircleCI
Save vendor/bundle cache on CircleCI
