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?

ruby

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Pros & Cons you must know before using Ruby on Rails for your startup

Click here, free ruby on rails course videos for you. It shows you best way to complete Ruby certification. OnlineITGuru guides you towards easy Web script

Explain Ruby on rails MVC

Our Ruby on Rails Training will provide you to learn about Rails and web applications development with realty. Our Ruby on Rails Course also includes live sessions.

Metaprogramming in Ruby

What is Metaprogramming? Have you ever wondered how Rails generates methods based on the models you’ve defined? This is done using Metaprogramming.Metaprogramming is writing programs that write programs. For example, when a User model is defined in Rails with email as an attribute, a method called find_by_email will be generated.