TA application, assignment, and matching.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. The entire application is Dockerized, using Ruby 2.5.1 and a Postgres database.
- Docker
- For Linux users only, Docker Compose
We have an init script that installs a linter (rubocop), as well as sets up a precommit hook to have the linter automatically run whenever you make a commit. Clone this repo, navigate into the cloned directory, and run
script/init-setup.sh
To launch the app, simply navigate into the cloned directory and run
docker-compose up
This will launch two containers: a rails app, and a postgres database. Access
the rails app by navigating to http://localhost:3000
If you have an existing image on your machine that needs to be updated, run
docker-compose up --build
To view the STDOUT from a docker container of a running server, you can do
docker-compose logs -tf <image>
, like: docker-compose logs -tf tapp
.
To access the dockerized app, simply run
docker-compose exec tapp sh
To create and setup your local development database, simply navigate into the rails container and run the following rake task. It will create your local database, run all migrations, and populate the db with seed data.
rake db:setup
Once your DB is setup, you can have SQL access to it through your docker container by running
$ psql tapp_development tapp
We use the annotate gem to automatically annotate our models whenever a migration
to run. If you need to annotate manually, run bundle exec annotate -p bottom
inside
the docker container.
We use rubocop for linting and code styling. We have a pre-commit hook ready
that everytime you commit something, rubocop will automatically run on your
staged file to check for styling issues. The configuration is in .rubocop.yml
and you can add more (or change) or current styling with configurations found
on the rubocop documentation. To
run it manually, just call rubocop
or bundle exec rubocop
.
We use RSpec as our testing suite. Our tests for models are located under
spec/models
. Factories are provided by FactoryBot
and are located under
spec/factories
. To run them, go into your local tapp container, and run:
# Get your test database similar to your development database
rake db:test:prepare
# Run entire test suite
rake spec
# Run tests for one specific class do rspec {file_name}
# For example,
rspec spec/models/position_spec.rb
# To run specific test block for a class, do rspec {file_name}:{line_number}
# where line number is the first line the block starts on
# For example,
rspec spec/models/position_spec.rb:17
To get into an interactive shell of any docker image, do docker exec -it <image_name> /bin/sh
Example: docker exec -it tapp_tapp /bin/sh
will allow
you to move into a bash shell of the tapp
application. From there you can
inspect the Gemfile, run rake db:migrate
or open up a rails console.
To keep the Gemfile.lock synced up with what we have on our host machine, run
docker-compose run <image> bundle install
followed by docker-compose up --build
.
Example: docker-compose run tapp bundle install
.
If you need to modify a migration file, please do the following within the docker container:
# Undo a specific version number
rake db:down VERSION=####
where the #### is the version you want to down from rake db:migrate:status
.
Modify your database migration file, then run rake db:migrate
It is sometimes possible that you get a tapp user not created
issue when
creating the db. To resolve this, remove the db
folder from the tmp
directory, and then re-create everything with rake db:setup
If rake db:setup
fails, do rake db:create
to create a new database from
scratch and rake db:migrate
.
This README would normally document whatever steps are necessary to get the application up and running.