RSpec clear_examples almost works in a complex setup with Runner.run in a loop.
Created by: guyboertje
In the Logstash product we use rake and rspec to run many specs on the main project and the 100 or so plugins that have their own rspec suite.
We thank the rspec community for their continued work on this important library.
When run individually each plugin spec suite runs fine with the set of helpers required correctly.
If I attempt to automate these with a loop using RSpec::Core::Runner.run(rspec_args)
and RSpec.clear_examples
it almost works.
- the deprecation warnings are not cleared and continue to be reported in a cumulative manner (i know but we have tech debt and a smallish team). I was able to use
--deprecation-out
to reduce the output in the console. - the shared_examples from
require ..../shared_examples
are removed by theworld.reset
method doing@shared_example_group_registry = nil
NOTE: commenting this line out worked for me. - the
--out
setting did not work because the IO is closed after the first loop iteration andclear_examples
does not reopen the IO. I had to pipe the stdout output to a file.
It is important in our case to have the output go to a file because with JRuby stack traces etc. we can't always scroll back in the console.
It is debatable whether the randomized seed should be reset by clear_examples
.
I tried to change some code with an eye to a PR (its always nice to get fixes with issues, we know) but the finding of how to clear the calls in the DeprecationReporterBuffer
defeated me.
May I suggest a method called something like reset_before_rerun
that is clear_examples
and more? It would better reveal the intention of the functionality.
Previous discussion - https://github.com/rspec/rspec-core/issues/1700