New Rails 6.0.3.2 with Rspec, React, and PostgreSQL Project

Standard
Reading Time: < 1 minute

I use Bamboo for my CI/CD so some of this you might not need l will state so in comments.

Create the new project:

-T tells rails to ignore installing a testing framework.

Setup your database by entering info into config/database.yml and create.

And I edit config/database.yml accordingly.

Add Rspec to your Gemfile:

Here are some of my other gem additions for development and testing:

Commands I often run:

rubocop -a // auto correct and check for style errors
brakeman // check for security issues
rubycritic // looks for code smells and complexity
bundler-audit // audit your gems

Install Rspec:

file location: spec/rails_helper.rb

Setup Rspec:

Running Test:

Notice that coverage folder is created.

Generate First Page:

Modify Routes:

File location: config/routes.rb

Running webpacker server for live updates.

./bin/webpacker-dev-server

Update views for React:

File location: app/views/pages/index.html.erb

File location: app/views/layouts/application.html.erb

This should have Hello React! displayed and if you change the jsx file it should live update.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.