machine:
  services:
    - docker

dependencies:
  cache_directories:
    - "~/docker"
    - .bundle
    - node_modules
    - public/assets
  override:
    - if [[ -e ~/docker/image.tar ]]; then docker load -i ~/docker/image.tar; fi
    - sudo pip install --upgrade docker-compose==1.5.2
    - docker pull ultrayoshi/ruby-node-phantomjs:2.1.1
    - docker pull postgres
    - docker pull redis
    - cp .env.example .env
    - docker-compose build
    - docker-compose run app bundle install
    - docker-compose run app npm install
    - docker-compose run app webpack 
    - mkdir -p ~/docker; docker save ultrayoshi/ruby-node-phantomjs:2.1.1 postgres redis > ~/docker/image.tar
    - docker-compose run app rake db:setup
    - docker-compose run -e RAILS_ENV=test app bundle exec rake assets:precompile

database:
  override:
    - echo 'done'

test:
  override:
    - docker-compose run -e CI=true -e CI_PULL_REQUEST=$CI_PULL_REQUEST -e CI_PULL_REQUESTS=$CI_PULL_REQUESTS -e COVERALLS_REPO_TOKEN=$COVERALLS_REPO_TOKEN -e COVERALLS_PARALLEL=true app bundle exec rspec:
        parallel: true
        files:
          - spec/**/*_spec.rb

machine:
  services:
    - docker

dependencies:
  cache_directories:
    - "~/docker"
    - .bundle
    - node_modules
    - public/assets
  override:
    - if [[ -e ~/docker/image.tar ]]; then docker load -i ~/docker/image.tar; fi
    - sudo pip install --upgrade docker-compose==1.5.2
    - docker pull ultrayoshi/ruby-node-phantomjs:2.1.1
    - docker pull postgres
    - docker pull redis
    - cp .env.example .env
    - docker-compose build
    - docker-compose run app bundle install
    - docker-compose run app npm install
    - docker-compose run app webpack 
    - mkdir -p ~/docker; docker save ultrayoshi/ruby-node-phantomjs:2.1.1 postgres redis > ~/docker/image.tar
    - docker-compose run app rake db:setup
    - docker-compose run -e RAILS_ENV=test app bundle exec rake assets:precompile

database:
  override:
    - echo 'done'

test:
  override:
    - docker-compose run -e CI=true -e CI_PULL_REQUEST=$CI_PULL_REQUEST -e CI_PULL_REQUESTS=$CI_PULL_REQUESTS -e COVERALLS_REPO_TOKEN=$COVERALLS_REPO_TOKEN -e COVERALLS_PARALLEL=true app bundle exec rspec:
        parallel: true
        files:
          - spec/**/*_spec.rb
    - docker-compose run app npm test:
        parallel: true
        files:
          - app/frontend/**/*.test.js

Add CircleCI configuration for npm test
Add CircleCI configuration for npm test
