Prerequisites
Create .env file at the root of the project directory. Copy the content of .env.template.erb to .env then update the username and password based on your database credentials. To send a post feedback email to the blog post author, request SENDGRID_API_KEY from admin/owner or create your own SENDGRID_API_KEY and add single sender verification then update SENDGRID_FROM_EMAIL and SENDGRID_FROM_NAME
Install dependencies and setup database
bin/setupRe-enable git hooks (Run this command only if you've already set up the application prior to the migration from husky to lefthook)
git config --unset core.hooksPathRun lefthook install to sync the git hooks
Populate database with sample data
bin/rake db:populate_sample_dataStart local web server
bin/devGo to http://localhost:3000
GitHub actions are setup to lint, test, and deploy the application.
You can also run these actions locally before pushing to see if your run is likely to fail. See the following gems / commands for more info.
-
Brakeman - Security audit application code
bin/brakeman --no-pager
-
Brakeman: Ignoring False Positives - Creating and Managing an Ignore File
bin/brakeman -I --no-pager
-
Bundler Audit - Security audit dependencies
bin/bundler-audit --update
-
Rubocop Rails Omakase - Ruby Linter
bin/rubocop
Note: Some linters like
ESLint,Prettier, etc. will automatically run onpre-commitgit hook.
Setup test database
bin/rails db:test:prepareDefault: Run all spec files (i.e., those matching spec/**/*_spec.rb)
bin/rspecor with --fail-fast option to stop running the test suite on the first failed test. You may add a parameter to tell RSpec to stop running the test suite after N failed tests, for example: --fail-fast=3
bin/rspec --fail-fastRun all spec files in a single directory (recursively)
bin/rspec spec/modelsRun a single spec file
bin/rspec spec/models/post_spec.rbRun a single example from a spec file (by line number)
bin/rspec spec/models/post_spec.rb:6Use the plain-English descriptions to generate a report of where the application conforms to (or fails to meet) the spec
bin/rspec --format documentationbin/rspec --format documentation spec/models/post_spec.rbSee all options for running specs
bin/rspec --helpSimpleCov is a code coverage analysis tool for Ruby. It uses Ruby's built-in Coverage library to gather code coverage data, but makes processing its results much easier by providing a clean API to filter, group, merge, format, and display those results, giving you a complete code coverage suite that can be set up with just a couple lines of code. SimpleCov/Coverage track covered ruby code, gathering coverage for common templating solutions like erb, slim and haml is not supported.
After running your tests, open coverage/index.html in the browser of your choice. For example, in a Mac Terminal,
run the following command from your application's root directory:
open coverage/index.htmlin a Debian/Ubuntu Terminal,
xdg-open coverage/index.htmlNote: This guide can help if you're unsure which command your particular operating system requires.