Request for an _appropriate_ way to tell if all of the examples in a given ExampleGroup are being executed
Created by: nevinera
I'm not certain if this belongs in an issue, or if I should be starting a conversation in a mailing list somewhere instead (please do correct me if I'm using your issue tracker wrong!).
I'm building a gem that uses the Coverage library to perform some coverage checks after each (configured) top-level ExampleGroup, using before(:context)
and after(:context)
. There are other issues I'm still working out around making it give more pleasant errors, but the rough idea is that you can mark an ExampleGroup with cover_it: true
and your test suite will fail if that class isn't 100% covered by the tests in that example group.
And it works! But.. in order to make it not fail every time someone runs rspec spec/foo_spec.rb:35
or rspec -e "foo"
, etc, I had to use some methods on ExampleGroup that are marked with @private
, which is obviously Bad and Wrong :-)
all_examples = context_class.descendants.flat_map(&:examples)
filtered_examples = context_class.descendant_filtered_examples
all_examples.sort == filtered_examples.sort
So.. first of all, did I miss anything? Is there an existing public api method like any_filtered?
somewhere that I could be using? Secondly, how stable is that undocumented bit of api - will I regret relying on it in a year or so? And thirdly, would a pull-request to add a public method like any_filtered?
be acceptable? I'm happy to contribute something like that, but I don't want to pester you with an implementation if it wouldn't match the intent of the library.