Skip to content

Latest commit

 

History

History
120 lines (86 loc) · 4.74 KB

CONTRIBUTING.md

File metadata and controls

120 lines (86 loc) · 4.74 KB

Contributing

Setting Up Development Environment

1 Fork and clone the repository.

https://help.github.com/articles/fork-a-repo/

2 Install Docker.

(Other Mac or Windows OS? See instructions for Docker Toolbox.)

(Running Linux? See instructions for Docker CE on Linux.)

Trouble with docker? The Troubleshooting Docker wiki outlines solutions for common errors.

3 Build the Docker Containers

Build the containers from any terminal program with:

docker-compose build

Optional: list the containers you just built:

docker ps

You should see two containers: refugerestrooms_web and postgres.

4 Run the Docker Containers

You can now run the app with:

docker-compose up

The web app will be reachable at this address: localhost:3000

(Point your web browser at localhost:3000 or 127.0.0.1:3000, or even [IP address of computer running the container]:3000 from any computer on the same LAN. The last method is useful for testing the app/site on smart phones and tablets.)

5 Do some Development

Files are shared between your computer and the Docker machine. If you update a file on your computer, the change should show up on the Docker machine, and vice-versa.

If you need to run commands on the Docker container directly, run this:

docker-compose run web bash

(This will give you a full interactive terminal session running on the Docker machine. For example, run bundle update to update the Gems in the Gemfile to more recent versions, or rails console to access web objects like Restroom.first.)

Occasionally, you might need to rebuild the Docker machine so it picks up major updates (such as a new version of Ruby, or an updated Gemfile). To do so, run docker-compose down and docker-compose build.

If you want to access the postgres container to reach the psql command line do

docker-compose run db bash
psql -h refugerestrooms_db_1 -U postgres

or equivalently:

docker-compose run db psql -h refugerestrooms_db_1 -U postgres

6 Run the Tests

docker-compose run -e "RAILS_ENV=test" web rake db:migrate:reset spec

(If you want to know if your changes pass our automated testing, before even submitting your changes to RefugeRestrooms on Github, this will let you know.)

If you want to run an individual spec, first log in to the container, then the spec. E.g.:

docker-compose run web bash
rspec spec/models/restroom_spec.rb

This is equivalent, but slower during a code-test-code-test development cycle:

docker-compose run web rspec spec/models/restroom_spec.rb

7 Linting Code

Ruby code is linted with rubocop.

If you want to lint your code before pushing it, you can run:

docker-compose run web rubocop

Some lint issues can be resolved automatically by running:

docker-compose run web rubocop --auto-correct

8 Shut down the Docker Container:

In another terminal window, run:

docker-compose down

(Shutting down the container in this way is safer than exiting with Ctrl + C, and prevents issues with breaking the db container.)

9 Optional tasks:

To clean up encoding problems in the safe2pee data, run (Use rake db:fix_accents[dry_run] to preview the changes.):

docker-compose run rake db:fixaccents

Assets

Testing

Please cover any new code with specs. We prefer code to be covered using RSpec or Capybara.

Now What?

Checkout our Wiki and specifically the newcomers guide.

Please also read our Code of Conduct, which gives guidance on our standards of community and interaction.