-
Notifications
You must be signed in to change notification settings - Fork 0
Testing Guide
This page explains how to run, write, and maintain tests for the StateForce project.
- Unit tests: Test individual models, services, and utility classes.
- Integration tests: Test interactions between multiple components, such as controllers and database.
- System/Feature tests: Simulate user interactions with the application through the UI.
To run all tests:
bundle exec rspecYou can run a specific test file:
bundle exec rspec spec/path/to/your_spec.rbOr run only tests matching a description:
bundle exec rspec -e "description"- Ensure you have copied
.env.testor set up the correct environment variables for testing. - The test database is separate from development and production. It will be created and migrated automatically.
To prepare the test database:
rails db:create RAILS_ENV=test
rails db:migrate RAILS_ENV=test- Place unit and integration tests under
spec/models,spec/controllers, etc. - Use FactoryBot for creating test data.
- Use fixtures or test doubles for external services (e.g., Google OAuth2, Redis).
- Follow the Rspec Rails Guide for best practices.
- Run RuboCop to check for linting and style violations:
bundle exec rubocop- All pull requests must pass the test suite before merging.
- Failed tests should be addressed promptly.
- If tests are failing unexpectedly, check for missing migrations or pending schema changes.
- Sometimes clearing the test database can help:
rails db:drop db:create db:migrate RAILS_ENV=testWe are always looking for feedback and contributions to improve StateForce. Feel free to open issues, suggest edits, or submit pull requests to the repository.
- Repo: StateForce GitHub
- Contact: martinmendozadev@gmail.com
If you encounter issues or need assistance, please reach out via:
- Email: martinmendozadev@gmail.com
- GitHub Issues: Submit an Issue
This documentation and the StateForce platform are licensed under the Apache License 2.0.
Thank you for using StateForce! π¨
Together, we are improving emergency response operations in real-time.
Welcome to the StateForce Wiki! Use this sidebar to navigate through the documentation.
This sidebar provides quick access to all the documentation pages. For detailed information, click on the desired section.