Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Latest commit

 

History

History
90 lines (56 loc) · 3.62 KB

native_setup.md

File metadata and controls

90 lines (56 loc) · 3.62 KB

Native Setup

Quick Reference

  1. Install Dependencies
  1. Setup database
  2. Start server
  3. Run tests
  4. Check style

Install Dependencies

Git

Git is a distributed version control system. This is how our code is stored and managed. Git can be frustrating, but it is an essential tool. If you want to learn more about Git, a great resource is Think Like a Git. If you find yourself in a real git pickle, see "Oh, shit, git!". If you have already installed Git as a part of the Docker Toolbox, you don't need to install it again using the following link.

You are now ready for the actual OperationCode Backend code base.

  • The common practice is to make a copy of the GitHub repository you want to work on (known as forking the repo), make your changes, and then request to merge those changes back into the project (known as a pull request).

  • Forking a repo is done through GitHub's web UI. It can be found in the top right corner of the OperationCode Backend's GitHub page.

  • The following commands will pull down the source code from your forked repo.

  • Make sure to replace [YOUR-GITHUB-NAME] with your GitHub name. (example: https://github.com/iserbit/operationcode_backend.git)

git clone https://github.com/[YOUR-GITHUB-NAME]/operationcode_backend.git operationcode-upstream
cd operationcode-upstream
git remote add upstream https://github.com/OperationCode/operationcode_backend.git

Ruby Version Manager

RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments.

  1. Install RVM.
  2. You may need to restart terminal after the installation for the changes to take effect.
  3. Install the ruby version specified in the .ruby-version file. You can check the version by running ruby -v
  4. Ensure ruby gemset from .ruby-gemset is applied. Run rvm gemset list. If a different gemset is applied, just run dir=`pwd` && cd .. && cd $dir

Bundler

Bundler is a dependency manager that ensures that the gems you need are present in the environment.

  1. Install Bundler gem install bundler
  2. Run bundle install to install all of the gems in your Gemfile.

Postgres

Postgres is an open source object-relational database.

  • Download and install PostgreSQL if you don't have it already.

Database Setup

  1. Run bin/rails db:create
  2. Run bin/rails db:migrate
  3. Run bin/rails db:seed

Start Server

To run the OperationCode Backend development environment simply type:

bin/rails server

You can now visit any route available from bin/rails routes. For example http://localhost:3000/api/v1/status and you should see the corresponding data returned.

Testing

Unit tests are utilized with minitest gem. All the tests are defined in the test folder.

  1. Run RAILS_ENV=test bin/rails db:test:prepare
  2. Run bin/rails test

Linting

Use rubocop to check ruby code style and formatting. It's appying the rules from the Ruby Style Guide.

  1. Run rubocop
  2. To autocorrect run rubocop -a