> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# medpeer/rails

An Orb for Rails projects. Source: https://github.com/medpeer-dev/rails-orbs


## Commands

### assets-precompile

Precompile assets with the `assets:precompile` task.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `key` | string | assets-v1 | The cache key prefix. |
| `rails_env` | string | test | RAILS_ENV when precompiling assets. |
| `restore_only` | boolean | false | Whether to skip assets:precompile and save_cache steps. |

### bundle-install

Install gems with Bundler.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `bundle_path` | string | vendor/bundle | The location to install gems. |
| `key` | string | gems-v1 | The cache key prefix. |
| `restore_only` | boolean | false | Whether to skip bundle-install and save_cache steps. |

### yarn-install

Install npm packages with Yarn.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `key` | string | node-deps-v1 | The cache key prefix. |
| `restore_only` | boolean | false | Whether to skip yarn-install and save_cache steps. |

## Jobs

### assets

Precompile assets with the `assets:precompile` task.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `before-steps` | steps |  | Steps to run before assets:precompile |
| `executor` | executor |  | Executor to use for this job |

### js-deps

Install npm packages with Yarn.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `before-steps` | steps |  | Steps to run before yarn-install |
| `executor` | executor |  | Executor to use for this job |

### rb-deps

Install gems with Bundler.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `before-steps` | steps |  | Steps to run before bundle-install |
| `executor` | executor |  | Executor to use for this job |

### rspec

Run tests with RSpec

| Parameter | Type | Default | Description |
|---|---|---|---|
| `before-steps` | steps |  | Steps to run before run tests |
| `db-port` | string |  | Port to wait for DB startup |
| `executor` | executor |  | Executor to use for this job |
| `parallelism` | integer | 1 |  |

## Examples

### rspec

Install gems and npm packages, precompile assets, and run tests in parallel.


```yaml
executors:
  ruby:
    docker:
      - image: circleci/ruby:2.7.0-node-browsers
  ruby_with_db:
    docker:
      - image: circleci/ruby:2.7.0-node-browsers
      - image: circleci/postgres:12.1-alpine-ram
    environment:
      DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432
orbs:
  rails: medpeer/rails@x.y.z
version: 2.1
workflows:
  rspec:
    jobs:
      - rails/rb-deps:
          executor: ruby
      - rails/js-deps:
          executor: ruby
      - rails/assets:
          executor: ruby
          requires:
            - rails/rb-deps
            - rails/js-deps
      - rails/rspec:
          db-port: '5432'
          executor: ruby_with_db
          parallelism: 4
          requires:
            - rails/assets
```

### rubocop

Install gems and run RuboCop in parallel.


```yaml
executors:
  ruby:
    docker:
      - image: circleci/ruby:2.7.0-node-browsers
jobs:
  rubocop:
    executor: ruby
    steps:
      - checkout
      - rails/bundle-install:
          restore_only: true
      - run: bundle exec rubocop --parallel
orbs:
  rails: medpeer/rails@x.y.z
version: 2.1
workflows:
  rspec:
    jobs:
      - rails/rb-deps:
          executor: ruby
      - rubocop:
          requires:
            - rails/rb-deps
```