rails-starter-template icon indicating copy to clipboard operation
rails-starter-template copied to clipboard

Opinionated Rails 7 starter template using esbuild, tailwindcss, postgresql and hotwired tested with RSpec

Rails starter template

Maintainability Test Coverage

Opiniated Rails setup with the latest Rails, using PostgreSQL, TailwindCSS, Stimulus, Hotwire and RSpec.

Using jsbundling-rails for Javascript, and TailwindCSS through PostCSS with cssbundling-rails. For easy loading of all Stimulus controllers we use esbuild-rails.

You need the following installed:

  • Ruby >= 3
  • Bundler (gem install bundler)
  • Node (brew install node)
  • Yarn (brew install yarn)
  • Overmind (brew install tmux overmind)
  • Postgresql (brew install postgresql start with: brew services start postgresql)
  • Redis (brew install redis start with: brew services start redis)

Optional: Docker to use with the preconfigured dip.yml to setup a dockerized dev environment using dip

Getting started

Initial application setup

Run the setup script that will run the needed setup steps for the application, installing all gems and packages, database preparing etc.

$ bin/setup

Provisioning and interacting with Docker and dip

You need docker and docker-compose installed (for MacOS just use official app).

This app uses the dip CLI, a utility CLI tool for straightforward provisioning and interactions with applications configured by docker-compose.

$ gem install dip
$ dip provision

Take a look at the dip.yml file for the available commands

Development

Will run Overmind (or Foreman if Overmind is not installed), builds all assets automaticly and will start the rails server and sidekiq

$ bin/dev

When using dip:

$ dip up web

Code Guidelines

It uses StandardRB for Ruby to automatically fix code style offenses.

$ bundle exec standardrb

to automatically format Ruby with StandardRB you can run:

$ bundle exec standardrb --fix

For Javascript we use StandardJS.

$ yarn standard

to automatically format the javascript with StandardJS you can run:

$ yarn standard --fix

Running the specs

Inspired by Evil Martians - System of a Test article

To run all the specs you can run:

$ rake

or use RSpec directly with

$ bundle exec rspec

Inside the docker container we have 2 different commands. To just run the unit tests:

$ dip rspec

and to just run the system specs:

$ dip rspec system