Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for an _appropriate_ way to tell if all of the examples in a given ExampleGroup are being executed #53

Open
nevinera opened this issue Jun 6, 2023 · 0 comments

Comments

@nevinera
Copy link
Contributor

nevinera commented Jun 6, 2023

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.

@JonRowe JonRowe transferred this issue from rspec/rspec-core Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant