Created
August 17, 2021 18:51
-
-
Save leandro/5a1d4fb942a50f99a04971218f4fbf4d to your computer and use it in GitHub Desktop.
A way to know which example (in any given rspec file) is being run out of total examples in the spec file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.describe 'whatever' do | |
around do |example| | |
total_examples = example.example_group.parent_groups.last.descendant_filtered_examples.size | |
examples_executed = example.reporter.examples.size | |
do_initial_thing if examples_executed == 1 | |
example.run | |
do_final_thing if examples_executed == total_examples | |
end | |
# the rest of the spec file | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment