Skip to content

TelosLabs/rails-world

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rails World

Ruby Style Guide

About

  • Ruby on Rails 7.1.x
  • Ruby 3.3.x
  • SQLite3
  • SolidQueue
  • Hotwire
  • Import maps
  • Tailwind CSS

Running the application

  1. Run bin/setup (needs to be run only once)
  2. Run bin/dev

or

  1. Run docker compose up

Linting & Formatting

Ruby

We use Standard Ruby for linting and formatting.

ERB

We use ERB Lint to lint our ERB files.

  • Run bundle exec erblint --lint-all to check all ERB files
  • Run bundle exec erblint --lint-all -a to auto-correct offenses. WARNING: This command isn't safe and can break your code.

JavaScript

We use StandardJS to lint our JavaScript files.

Spelling

We use Typos as a spell checker.

  • Install by running brew install typos-cli
  • Run typos to check all files
  • Run typos -w to auto-correct offenses
  • For false positives and other configuration, see the _typos.yml file

Optional - Running linters' auto-fix before a commit

Leftook will execute the linters' auto-fix on staged files and abort the commit if there are offenses that can't be auto-fixed. Run the following commands to enable this flow:

gem install lefthook
lefthook install

Code Quality

Rubycritic

Besides code reviews, we use rubycritic to generate a report of the code quality. Both as a reviewer and as a contributor, you should check the report and address the issues found if the files you are working on have a low score ("D" or "F").

  • You can run it with bundle exec rubycritic

Database consistency

We use DatabaseConsistency to check for inconsistencies between the database schema and the application models.

  • You can run it with bundle exec database_consistency.

Testing

Run tests by using bundle exec rspec.

System specs

  • Headless is the default config. If you want to see the browser you can run the following command: HEADLESS=false bundle exec rspec
  • If you want to pause the execution you can use pause inside an it statement.
  • If you want to see the logs you can use :log, e.g. it "xxx", :log do
  • Use data-test-id to find elements instead of classes/ids, e.g. data-test-id="decline_modal"
  • Use the methods in the DataTestId module to select HTML elements, e.g., find_dti("decline_modal")

Feature Flags

Use ENV variables to enable features, the name should follow the convention "#{feature_name}_ENABLED". For example, to enable the payment feature, use ENV["PAYMENT_ENABLED"]="true".