- Install Dependencies
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 apull 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
RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments.
- Install RVM.
- You may need to restart terminal after the installation for the changes to take effect.
- Install the ruby version specified in the
.ruby-version
file. You can check the version by runningruby -v
- Ensure ruby gemset from
.ruby-gemset
is applied. Runrvm gemset list
. If a different gemset is applied, just rundir=`pwd` && cd .. && cd $dir
Bundler is a dependency manager that ensures that the gems you need are present in the environment.
Postgres is an open source object-relational database.
- Download and install PostgreSQL if you don't have it already.
- Run
bin/rails db:create
- Run
bin/rails db:migrate
- Run
bin/rails db:seed
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.
Unit tests are utilized with minitest gem. All the tests are defined in the test
folder.
- Run
RAILS_ENV=test bin/rails db:test:prepare
- Run
bin/rails test
Use rubocop to check ruby code style and formatting. It's appying the rules from the Ruby Style Guide.
- Run
rubocop
- To autocorrect run
rubocop -a