Last active
December 15, 2015 20:41
-
-
Save jeremywrowe/5320537 to your computer and use it in GitHub Desktop.
Show leaked instance variables in cucumber. A terrible hack but sometimes that is what ya need to do :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cucumber_instance_variables = [] | |
Before do | |
$cucumber_instance_variables = instance_variables | |
end | |
After do | |
test_variables = instance_variables - $cucumber_instance_variables | |
message = "[WARN] the following test variables could be leaking #{leaked_variables.join(', ')}" | |
puts message if test_variables.any? and ENV['SHOW_TEST_VARS'] | |
test_variables.each {|v| instance_variable_set v, nil } | |
$cucumber_instance_variables = [] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment