Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add instructions to run tests on file changes

Christophe Bliard385a71450789
diff --git a/docs/development/running-tests/README.md b/docs/development/running-tests/README.md
index b010253361d..ab6220205d6 100644
--- a/docs/development/running-tests/README.md
+++ b/docs/development/running-tests/README.md
@@ -298,7 +298,7 @@ You can run the specs with the following commands:
* `SPEC_OPTS="--seed 12935" bundle exec rake spec` Run the core specs with the seed 12935. Use this to control in what order the tests are run to identify order-dependent failures. You will find the seed that Github Actions CI used in their log output.
-
+
## Legacy specs
@@ -351,6 +351,27 @@ Then you can just use `RAILS_ENV=test ./bin/rails parallel:prepare` to prepare t
Run all unit and system tests in parallel with `RAILS_ENV=test ./bin/rails parallel:spec`
+## Automatically run tests when files are modified
+
+To run tests automatically when a file is modified, you can use [watchexec](watchexec https://github.com/watchexec/watchexec) like this:
+
+```
+watchexec --exts rb,erb -- bin/rspec spec/some/path/to/a_particular_spec.rb
+```
+
+This command instructs `watchexec` to watch `.rb` and `.erb` files for modifications in the current folder and its subfolders. Whenever a file modification is reported, the command `bin/rspec spec/some/path/to/a_particular_spec.rb` will be executed.
+
+Stop `watchexec` by pressing `Ctrl+C`.
+
+Set an alias to make it easier to call:
+```
+alias wrspec='watchexec --exts rb,erb -- bin/rspec'
+
+wrspec spec/some/path/to/a_particular_spec.rb
+```
+
+To easily change the RSpec examples being run without relaunching `watchexec` every time, you can focus a particular example or example group with `focus: true`, `fit`, `fdescribe`, and `fcontext`. More details available on [RSpec documentation](https://relishapp.com/rspec/rspec-core/docs/filtering/filter-run-when-matching).
+
## Manual acceptance tests
@@ -372,7 +393,7 @@ One way is to disable the Angular CLI that serves some of the assets when develo
# Precompile the application
./bin/rails assets:precompile
-# Start the application server while disabling the CLI asset host
+# Start the application server while disabling the CLI asset host
OPENPROJECT_CLI_PROXY='' ./bin/rails s -b 0.0.0.0 -p 3000
```