While executing a long-running test suite with RSpec, I would like to checkout another git branch.
How does RSpec behave in this case? Does it read all files into memory as part of its boot-up process (in which case changing branch would have no effect), or does it read them only when they are needed?
If you checkout while the tests are already running, it will keep executing the specs associated to the previous branch as long as the process doesn't start other processes (e.g. using rake test
may start different test suites in different processes if they are provided as different tasks).
However, if your specs need to access resources outside the Ruby environment at runtime, such as writing/reading a file on the file system, and that resource is not available in the new branch or it's changed, then the specs may return invalid result.
In other words, as long as the specs only relies on code that may be loaded by the Ruby virtual machine when the process is stared, then you'll be fine.
Whether this is recommended or not, that's another story. I would personally avoid it to prevent unplanned side effects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With