New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instance variables get reset when an exception is raised within before(:all) #558
Comments
The ivars are not getting "reset", they're never getting "stored" because of the exception. Here are the steps that RSpec takes: 1.) Eval the Step 2 is never called because of the exception in step 1. I started working on a fix for this, but then I started thinking "what benefit would this provide?". We shouldn't need to keep access to ivars if an exception happens in a I understand the pain in your situation; you probably have to manually kill the selenium instance. Whatever you're holding in that ivar in the @dchelimsky @myronmarston - do you guys think we should retain access to ivars in |
Okay. That is nice to know. We've fixed the problem by manually catching the exceptions and dealing with it. Retaining access to the ivars in case of an exception would be great, nonetheless. |
After thinking about it some more, it does make sense to make the ivars available, regardless if an exception was raised. We always "ensure" after hooks are run, so we should also ensure ivars are always available. |
yo, it seems to print the correct stuff out when the hook is wrapped in a simple begin rescue like this: Should I manufacture similar blocks for each of the other hooks and make a pull request? |
This is the output from running with that patch applied https://gist.github.com/3770433 |
@samphippen -- Thanks for looking into this! I think rescuing errors like that will have the affect of silencing errors that happen in Instead, I think we want to move the storing of the instance variables into an Want to take a stab at that? |
On 24 Sep 2012, at 04:36, Myron Marston wrote:
I'll take a look and see if I can make it work.
|
I've got a patch that does this: https://gist.github.com/3775318 and output: https://gist.github.com/3775317 Should I manufacture a pull request around this? |
@samphippen, it seems reasonable to me, especially if you can get some specs around it. Thanks! |
Hello everyone,
today, I was debugging some selenium webdriver test code and ran into the following problem: When an instance variable is set within the before(:all) hook and an exception is raised within the same hook, the instance variable is nil when acessed inside the after(:all) hook that gets called after the exception is raised.
Here is a simplified example:
We use the before(:all) hook to set up a selenium browser instance and kill it within after(:all), so we don't need to launch a new instance for every test. This works fine, as long as no exception is thrown within before(:all). Is this intended behavior or a bug? If it is intended: Is there a way to prevent a reset of the mentioned instance variables?
The text was updated successfully, but these errors were encountered: