Skip to content

Instantly share code, notes, and snippets.

@lucashour
Last active February 16, 2023 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucashour/2f0ecab074c76d7a107bf6d0db36c404 to your computer and use it in GitHub Desktop.
Save lucashour/2f0ecab074c76d7a107bf6d0db36c404 to your computer and use it in GitHub Desktop.
README sample for a Rails project

Build Status

README

Stack

Backend

  • Ruby version: 3.0.3
  • Rails version: 6.1.7

Frontend

  • Stimulus JS
  • Node 16.13.0
  • Bootstrap 5

Database

  • PostgreSQL

Testing

  • RSpec

Setup

Via native installation

  1. Clone the project.
  2. Create the file config/application.yml with the environment variables (see config/application.yml.sample).
  3. Set the right version for Node (nvm is recommended).
  4. Run bundle install to install the project gems.
  5. Run yarn install to install Yarn dependencies.
  6. Create DB and run migrations with rails db:create db:migrate:with_data.
  7. Run rails db:seed to populate DB with Rails seeds.
  8. Run rails s to run server.
  9. This project is using Webpack so, in order to avoid restarting the server everytime you change any JavaScript content, you need to initialize a development server that will compile JavaScript for Webpack. This can be done by running the following command: ./bin/webpack-dev-server.

Using Docker Compose

  1. Clone the project.
  2. Create the file .env with the environment variables (see .env.sample).
  3. Run docker-compose build to build Docker services.
  4. Create DB and run migrations with docker-compose run app rails db:create db:migrate:with_data.
  5. Run docker-compose run app rails db:seed to populate DB with Rails seeds.
  6. Run docker-compose up to run server.

To install new dependencies, you need to use yarn. E.g. to install jQuery, run yarn add jquery

Running migrations

Since the project is using the (data_migrate) gem, all migrations and rollbacks should be run using the following commands:

rails db:migrate:with_data
rails db:rollback:with_data

Running testing suite

This project is using Rspec with Capybara. To run the entire suite, execute the following command:

bundle exec rspec

If you want to run only the feature tests on a live browser instead of the headless version, you just need to run this command:

CAPYBARA_DRIVER=selenium_chrome bundle exec rspec spec/features

If you want to skip feature tests, you can use this command:

rspec --exclude-pattern "spec/features/**/*_spec.rb"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment