Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

In rspec 2.0.0.beta.9 instance variables not available in after(:all) #33

Closed
rsim opened this Issue Jun 3, 2010 · 7 comments

Comments

Projects
None yet
3 participants

rsim commented Jun 3, 2010

Starting from rspec 2.0.0.beta.9 if instance variables are set in before(:all) then they are not available in after(:all). See example https://gist.github.com/52f61da8b461d6c8b8e7

In 2.0.0.beta.8 it is working fine. And it is issue just with after(:all), in after(:each) instance variables are visible.

This is quite critical as I was using instance variables to destroy test data in database that were created in before(:all).

fevrisn commented Jun 3, 2010

I'm experiencing the same thing. It also seems to wipe the before(:all) variables after its run a nested describe/context block (causing the following nested blocks to fail).
https://gist.github.com/e6f77ca3c46e62722298

rsim commented Jun 3, 2010

Checked that the same issue is in rspec 2.0.0.beta.10 which is just released.

Owner

dchelimsky commented Jun 3, 2010

This opens up a significant can of worms that I'll follow up with later.

For the short run, you can work around it using $global_variables instead of @instance_variables.

rsim commented Jun 3, 2010

That would be very bad if @instance_variables would not work in before(:all) and after(:all) blocks which is very common pattern in lot of applications. And that would not be easy to replace it in all existing applications. And also it is not very intuitive if something that you create in before(:all) is not available in after(:all).

I would be very happy if it would work in the same way as previously :)

Owner

dchelimsky commented Jun 3, 2010

It'll get fixed - but it might not be right away. I was just suggesting a workaround until it is.

rsim commented Jun 3, 2010

OK, thanks :) I was afraid that it will stay this way. Currently I can use 2.0.0.beta.8 version.

Owner

dchelimsky commented Jun 4, 2010

Ensure that state set in before(:all) is available in after(:all)

Closed by c1542d0.

timcharper pushed a commit to timcharper/rspec-core that referenced this issue Aug 19, 2011

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment