Don't execute the before test code for every test without using a before all block

Don't execute the before test code for every test without using a before all block

I want to execute some before code and test the result with multiple it statements without having to run the before code.

I want to execute some before code and test the result with multiple it statements without having to run the before code.

context 'context A' do
   context 'context A.1' do
     before(:each) do
        # Doing a lot of things and using let variables,...
     end

 it 'T1: test thing 1'
 it 'T2: test thing 2'
 it 'T3: test thing 3'

end

context 'context B.1' do before(:each) do # Doing a lot of things and using let variables,... end

 it 'T1: test thing 1'
 it 'T2: test thing 2'
 it 'T3: test thing 3'

end end

If you look to the execution it looks something like:

before A.1 - T1 - before A.1 - T2 - before A.1 - T3 - before B.1 - T1 - ...

But i want:

before A.1 - T1 - T2 - T3 - before B.1 - T1 - T2 - T3

I tried to use a before(:all) but i cannot use it because i use a lot of let variables. You get following error because a let should change in every context.

RuntimeError: let declaration var1 accessed in a before(:context) hook at:

I could combine all tests in one it statement but i don't want that, i want to see which particalur test fails. The only solution i see is to get rid of all the let variables but this wil result in massive code blocks in the before(:all).

Can i get the behaviour i want in an other way? Or do i have to look at things in another way?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to Setup Development Environment for Ruby on Rails App using Docker

This Docker Compose tutorial will show you how to set up a development environment for a Ruby on Rails application using Docker. You will create multiple containers – for the application itself, the PostgreSQL database, Redis, and a Sidekiq service – with Docker Compose. Creating a development setup for your Rails application using Docker containers