This example shown in the document demonstrates to preserve the variable while Intercepting the script executed for testing using "When run source".
link for it -> https://github.com/shellspec/shellspec#intercepting
I to reimplement this thing at my end. But it is not working out as expected.
The script im testing is :

The spec file is :

This is the output I am getting :

As this crearly demonstarates that it is failing to preserve the variable name1 and name2.
Here name1 should be "sagar" and name2 should be "sagar". But it is not getting preserved.
It seems that inside "end()" the %preserve is not working as expected.
Please look into this.
Thanks.
This example shown in the document demonstrates to preserve the variable while Intercepting the script executed for testing using "When run source".

link for it -> https://github.com/shellspec/shellspec#intercepting
I to reimplement this thing at my end. But it is not working out as expected.
The script im testing is :
The spec file is :

This is the output I am getting :

As this crearly demonstarates that it is failing to preserve the variable name1 and name2.
Here name1 should be "sagar" and name2 should be "sagar". But it is not getting preserved.
It seems that inside "end()" the %preserve is not working as expected.
Please look into this.
Thanks.