I am trying to run an RSpec test, and I want to detect if the test failed in the after
method. I have something like this right now:
after(:each
I was looking for how to check if success for all examples in a group in a after(:context)
/ after(:all)
block. Here's what I came up with:
after(:all) do |example_group|
all_groups = example_group.class.descendants
failed_examples = all_groups.map(&:examples).flatten.select(&:exception)
if failed_examples.empty?
# runs only if there are no failures
do('something')
end
end