diff --git a/compose.yaml b/compose.yaml index 1f2afff23..7bf27a3d4 100644 --- a/compose.yaml +++ b/compose.yaml @@ -3,6 +3,7 @@ services: profiles: - offline - dev + - test image: postgres:11 restart: unless-stopped ports: @@ -35,6 +36,24 @@ services: - ./data/media:/media - ./data/import/media:/api/import/media + test: + profiles: [test] + image: terrastories/devcore:latest + entrypoint: ["bundle", "exec", "rspec"] + restart: no + stdin_open: true + tty: true + depends_on: + - db + environment: + - RAILS_ENV=test + volumes: + - bundler:/usr/local/bundle + - ./rails:/api + - ./data/media:/media + - ./data/import/media:/api/import/media + - ./map:/api/public/map:ro + nginx-proxy: profiles: - offline diff --git a/documentation/DEVELOPMENT.md b/documentation/DEVELOPMENT.md index 3c52a5063..69b93361f 100644 --- a/documentation/DEVELOPMENT.md +++ b/documentation/DEVELOPMENT.md @@ -45,26 +45,14 @@ Please check [ESLint editor-integrations page](https://eslint.org/docs/user-guid Terrastories uses RSpec for testing and we try to have unit tests for as many components of the application as possible. -You can run RSpec tests in the Docker `web` container. There are different ways to do this. - -If you already have a container running: - -``` -docker compose exec -e RAILS_ENV=test web bundle exec rspec ``` - -(You can also run `RAILS_ENV=test bundle exec rspec` in a running container shell if you prefer.) - -If you want to boot a separate container for tests, and then take it down: - +docker compose run --rm test ``` -docker compose run --rm -e RAILS_ENV=test web bundle exec rspec -``` -We also support Javascript unit testing, with Enzyme for snapshots. +If you wish to run a specific test or test file, you may pass that as the first argument: ``` -docker compose exec web yarn test +docker compose run --rm test spec/path/to/my_spec.rb:line ``` ## Working with Explore Terrastories