Skip to content

Development Testing

Luca Brügger edited this page May 10, 2022 · 6 revisions

Development Testing

⚠️ make sure you have completed the docker development setup

There's 3 different kinds of tests in Cryptopus:

Unit-/Controller Tests

Those are the Ruby-Land tests and are for testing the Rails backend.

To run a specific test file:

docker-compose exec rails bash
rspec spec/controllers/session_controller_spec.rb

or for even a specific test case, add the line number

rspec spec/controllers/session_controller_spec.rb:42

backend specs reside all in the spec folder:

folder content
controllers controller tests
integration backend/api tests independent from controllers
migrations tests for db migrations
policies tests for pundit policies

End to End / System Tests

Those tests are running the full stack. So there's a webbrowser (firefox) startet in the background and tests are clicking/navigating through the application.

Preparation

⚠️ Make sure to run these commands before running the test when there's changes in the ember frontend

docker-compose exec ember yarn build --prod
docker-compose exec rails ./bin/prepare-frontend.sh

Run Tests

docker-compose exec rails bash
rspec --tag type:system spec/system/settings_system_spec.rb

for running system specs with visible browser (for debugging)

HEADLESS=false rspec --tag type:system spec/system/settings_system_spec.rb

Frontend Specs

Simply visit localhost:4200/tests
Edited tests will automatically restart when saved.

Clone this wiki locally